From cf526bb11bc0588845a794522f64b46e70684fbb Mon Sep 17 00:00:00 2001 From: Hansoo Date: Sun, 29 Jan 2023 19:17:55 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E8=A3=9C?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/DamageCalculator.svelte | 9 +++++++++ src/lib/DisplayData.svelte | 26 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/lib/DamageCalculator.svelte b/src/lib/DamageCalculator.svelte index 8c6daf3..28f5e39 100644 --- a/src/lib/DamageCalculator.svelte +++ b/src/lib/DamageCalculator.svelte @@ -20,6 +20,7 @@ let total_min_damage = 0; let total_max_damage_percentage = 0; let total_min_damage_percentage = 0; + let item_magnification = 1.0; function calculate_damage() { let attacker; let defender; @@ -190,6 +191,8 @@ data.minDamage = Math.trunc(data.minDamage * magnification_terastype); data.maxDamage = Math.trunc(data.maxDamage * magnification); data.minDamage = Math.trunc(data.minDamage * magnification); + data.maxDamage = Math.trunc(data.maxDamage * item_magnification); + data.minDamage = Math.trunc(data.minDamage * item_magnification); return data; } @@ -250,6 +253,12 @@ bind:group={attack_direction} /> P2 ->> P1 + + + diff --git a/src/lib/DisplayData.svelte b/src/lib/DisplayData.svelte index b691487..b35125a 100644 --- a/src/lib/DisplayData.svelte +++ b/src/lib/DisplayData.svelte @@ -13,6 +13,18 @@ } return v; } + function level_validator(v) { + if (typeof v !== "number") { + return null; + } + if (v > 100) { + return 100; + } + if (v < 1) { + return 1; + } + return v; + } const available_type = [ { id: 1 }, { id: 2 }, @@ -47,6 +59,7 @@ } $: { // validator + level = level_validator(level); hp_v = v_validator(hp_v); atk_v = v_validator(atk_v); def_v = v_validator(def_v); @@ -261,7 +274,7 @@ export let spdef_final = 0; export let spd_final = 0; export let terastype = [0]; - + let level = 50; let selected_terastype = 0; let atk_plus = false; let def_plus = false; @@ -275,10 +288,12 @@ let spdef_minus = false; let spd_minus = false; function calculate_hp(stat, v, d) { - return Math.floor(((stat*2+v+(d/4))*0.5)+50+10) + // floor({(種族値+個体値)×2+min(63,floor(floor(1+√努力値)÷4))}×レベル÷100)+レベル+10 + return Math.floor(((stat*2+v+(d/4))*(level/100))+level+10) } function other_stats(stat, v, d, p) { - return Math.floor((((stat*2+v+(d/4))*0.5)+5)*p) + // floor({(種族値+個体値)×2+min(63,floor(floor(1+√努力値)÷4))}×レベル÷100)+5 + return Math.floor((((stat*2+v+(d/4))*(level/100))+5)*p) } let abilities = []; let abilities_description = []; @@ -397,6 +412,11 @@ {pokemonData.hp + pokemonData.attack + pokemonData.defense + pokemonData.special_attack + pokemonData.special_defense + pokemonData.speed} + + Level + + + {:else}