diff --git a/src/App.svelte b/src/App.svelte index c6c3cf3..1570f62 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,6 +1,6 @@ @@ -8,21 +8,14 @@
- +
- +
- +
@@ -42,4 +35,4 @@ flex-direction: row; height: 800px; } - \ No newline at end of file + diff --git a/src/lib/DamageCalculator.svelte b/src/lib/DamageCalculator.svelte index d8824f0..a326447 100644 --- a/src/lib/DamageCalculator.svelte +++ b/src/lib/DamageCalculator.svelte @@ -7,7 +7,6 @@ let attackData; $: { if (myValue > 0 && myValue !== currentValue) { - invoke("search_move", { index: myValue }).then((r) => { currentValue = myValue; attackData = r; @@ -23,7 +22,13 @@ let defender; let atk_value; let def_value; - if (!player1Data || !player2Data || !attackData || (!!attackData && ![1, 2].includes(attackData.category))) { + if ( + !player1Data || + !player2Data || + !attackData || + (!!attackData && ![1, 2].includes(attackData.category)) + ) { + // display some message somewhere console.log("skip"); return; } @@ -53,13 +58,13 @@ minDamage: 0, // 攻撃側タイプ // TODO: try catchでエラーハンドリング - atk_type: JSON.parse(attacker.types),// 配列なのでjson parse + atk_type: JSON.parse(attacker.types), // 配列なのでjson parse // 防御側タイプ def_type: JSON.parse(defender.types), // 技タイプ move_type: JSON.parse(attackData.types), // 範囲の計算で使用する - } + }; // 計算 let d = damage(data); @@ -67,33 +72,35 @@ total_max_damage = d.maxDamage; total_min_damage = d.minDamage; } - function damage(data){ + function damage(data) { // 基本の計算 - var step1 = Math.trunc(data.level * 2 / 5 + 2); - var step2 = Math.trunc(step1 * data.attack_power * data.atk_value / data.def_value); + var step1 = Math.trunc((data.level * 2) / 5 + 2); + var step2 = Math.trunc( + (step1 * data.attack_power * data.atk_value) / data.def_value + ); data.maxDamage = Math.trunc(step2 / 50 + 2); // この時点の計算結果は最大ダメージ // 各種補正かけた結果を返す - return modify(data) + return modify(data); } // 全部一気にやると大変なので、一旦基本計算から - function modify(data){ + function modify(data) { // 範囲補正 // 親子愛補正 // ※svでおやこあいの特性はないのでスキップする // 天気補正 // 急所補正 // 乱数補正 - data.minDamage = getMinDamage(data) + data.minDamage = getMinDamage(data); // タイプ一致補正 - let type_match = false - for (let i = 0; i < data.atk_type.length && !type_match; i++){ - for (let j = 0; j < data.move_type.length && !type_match; j++){ - if (data.atk_type[i] === data.move_type[j]){ + let type_match = false; + for (let i = 0; i < data.atk_type.length && !type_match; i++) { + for (let j = 0; j < data.move_type.length && !type_match; j++) { + if (data.atk_type[i] === data.move_type[j]) { // タイプ一致したら判定終了 type_match = true; - data.maxDamage = Math.trunc(data.maxDamage*1.5) - data.minDamage = Math.trunc(data.minDamage*1.5) + data.maxDamage = Math.trunc(data.maxDamage * 1.5); + data.minDamage = Math.trunc(data.minDamage * 1.5); } } } @@ -101,7 +108,6 @@ // 相性補正 // 相性の計算の関数をとってくる - // やけど補正 // 壁補正 // ブレインフォース補正 @@ -117,15 +123,15 @@ // 半減木の実補正 // その他ダメージ補正(M twice) // ダイマックス技などの軽減(M protect) - return data + return data; } // 乱数補正 // ダメージは、乱数で0.85~1.00をかけた値の範囲で変動する // 1.00はそのままの値なので、 // 0.85をかけた最小ダメージだけを計算する // 少数切り捨て - function getMinDamage(data){ - return Math.trunc(data.maxDamage * 85/100); + function getMinDamage(data) { + return Math.trunc((data.maxDamage * 85) / 100); } async function getItems(keyword) { try { @@ -140,40 +146,58 @@ let myValue; let currentValue = 0; +
- +
- P1 ->> P2 + P1 ->> P2 - P2 ->> P1 + P2 ->> P1
Total Damage: {total_min_damage} ~ {total_max_damage}
{JSON.stringify(player1Data)} - - {JSON.stringify(player2Data)}
{attack_direction} + {JSON.stringify(player2Data)}
+ {attack_direction}
\ No newline at end of file + .calculator { + height: 100px; + width: 100%; + border-top: 2px solid white; + } + diff --git a/src/lib/MainWrapper.svelte b/src/lib/MainWrapper.svelte index 876442f..6b52934 100644 --- a/src/lib/MainWrapper.svelte +++ b/src/lib/MainWrapper.svelte @@ -55,23 +55,23 @@