From b709ca838f8201ead9b8672a5c7f878aff9178ba Mon Sep 17 00:00:00 2001 From: Hansoo Date: Mon, 6 Feb 2023 02:34:22 +0900 Subject: [PATCH] some more improvements --- src-tauri/tauri.conf.json | 2 +- src/lib/DamageCalculator.svelte | 12 +- src/lib/DisplayData.svelte | 241 +++++++++++++++++++++----------- src/lib/MainWrapper.svelte | 75 ++++++---- src/model/PokemonStatus.ts | 15 +- 5 files changed, 229 insertions(+), 116 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3085cbb..6aed3c2 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "pokemon-data-displayer", - "version": "0.0.5" + "version": "0.0.6" }, "tauri": { "allowlist": { diff --git a/src/lib/DamageCalculator.svelte b/src/lib/DamageCalculator.svelte index 7d3c51b..a294d84 100644 --- a/src/lib/DamageCalculator.svelte +++ b/src/lib/DamageCalculator.svelte @@ -33,8 +33,8 @@ let total_min_damage_percentage = 0; let item_magnification = 1.0; function calculate_damage() { - let attacker; - let defender; + let attacker: PokemonStatus; + let defender: PokemonStatus; let atk_value; let def_value; if ( @@ -56,11 +56,11 @@ } // 物理or特殊の判定 if (attackData.category === 1) { - atk_value = attacker.atk; - def_value = defender.def; + atk_value = attacker.attack; + def_value = defender.defense; } else { - atk_value = attacker.spatk; - def_value = defender.spdef; + atk_value = attacker.special_attack; + def_value = defender.special_defense; } // debug diff --git a/src/lib/DisplayData.svelte b/src/lib/DisplayData.svelte index c335e85..478a37f 100644 --- a/src/lib/DisplayData.svelte +++ b/src/lib/DisplayData.svelte @@ -437,8 +437,8 @@ > {hp_final} - + - - + + + - ATK @@ -482,6 +482,17 @@ /> +      + {#each Array.from({length: 6}, (_, i) => i - 6) as i} + + { pokemonData.attack_buff = i; }}>▼ + {/each} + + { pokemonData.attack_buff = 0; }}>・ + {#each Array.from({length: 6}, (_, i) => i) as i} + + { pokemonData.attack_buff = i+1; }}>▲ + {/each} DEF @@ -517,143 +528,187 @@ /> - + + + /> + + +      + {#each Array.from({length: 6}, (_, i) => i - 6) as i} + + { pokemonData.defense_buff = i; }}>▼ + {/each} + + { pokemonData.defense_buff = 0; }}>・ + {#each Array.from({length: 6}, (_, i) => i) as i} + + { pokemonData.defense_buff = i+1; }}>▲ + {/each} S.ATK {pokemonData.special_attack} - + + - + + + + + + /> + + {spatk_final} - + + - + + + + + + /> + + +      + {#each Array.from({length: 6}, (_, i) => i - 6) as i} + + { pokemonData.special_attack_buff = i; }}>▼ + {/each} + + { pokemonData.special_attack_buff = 0; }}>・ + {#each Array.from({length: 6}, (_, i) => i) as i} + + { pokemonData.special_attack_buff = i+1; }}>▲ + {/each} S.DEF {pokemonData.special_defense} - + + - + + + + + + /> + + {spdef_final} - + + - + + + + + + /> + + +      + {#each Array.from({length: 6}, (_, i) => i - 6) as i} + + { pokemonData.special_defense_buff = i; }}>▼ + {/each} + + { pokemonData.special_defense_buff = 0; }}>・ + {#each Array.from({length: 6}, (_, i) => i) as i} + + { pokemonData.special_defense_buff = i+1; }}>▲ + {/each} SPD {pokemonData.speed} - + + - + + + + + + /> + + {spd_final} - + + - + + + + + + /> + + +      + {#each Array.from({length: 6}, (_, i) => i - 6) as i} + + { pokemonData.speed_buff = i; }}>▼ + {/each} + + { pokemonData.speed_buff = 0; }}>・ + {#each Array.from({length: 6}, (_, i) => i) as i} + + { pokemonData.speed_buff = i+1; }}>▲ + {/each} TOTAL @@ -756,6 +811,11 @@ padding-left: 10px; width: 50%; } + .plus-minus-column { + text-align: center; + padding-left: 10px; + width: 50%; + } .vd-input { width: 50px; padding-left: 0; @@ -785,6 +845,27 @@ min-height: 25px; padding: 2px; } + .cursor-pointer { + cursor: pointer; + } + .minus:hover { + color: pink; + transition: font-size .5s ease; + font-size: 1.1em; + } + .plus:hover { + color: lightgreen; + transition: font-size .5s ease; + font-size: 1.1em; + } + .red { + color: red; + font-weight: bold; + } + .green { + color: green; + font-weight: bold; + } .learnset { width: 90%; } diff --git a/src/lib/MainWrapper.svelte b/src/lib/MainWrapper.svelte index fe95003..7b680ce 100644 --- a/src/lib/MainWrapper.svelte +++ b/src/lib/MainWrapper.svelte @@ -6,9 +6,8 @@ import type { PokemonDBData, PokemonData } from "src/model/PokemonData"; import type { ItemData, ItemEffect } from "../model/ItemData"; $: { - if (myValue > 0 && myValue !== currentValue) { + if (myValue > 0) { invoke("search", { index: myValue }).then((r: PokemonDBData) => { - currentValue = myValue; pokemonData = { id: r.id, name: r.name, @@ -53,7 +52,6 @@ speed_buff: 0, }; pokemonDataArray[index] = pokemonData; - console.log(currentValue); myValue = undefined; }); } @@ -61,19 +59,23 @@ types: pokemonData ? pokemonData.types : [], terastype: pokemonData ? pokemonData.terastype : [0], hp: hp_final, - atk: atk_final, - def: def_final, - spatk: spatk_final, - spdef: spdef_final, - spd: spd_final, - item: pokemonData? pokemonData.item : 0, + attack: atk_final, + defense: def_final, + special_attack: spatk_final, + special_defense: spdef_final, + speed: spd_final, + attack_buff: pokemonData ? pokemonData.attack_buff : 0, + defense_buff: pokemonData ? pokemonData.defense_buff : 0, + special_attack_buff: pokemonData ? pokemonData.special_attack_buff : 0, + special_defense_buff: pokemonData ? pokemonData.special_defense_buff : 0, + speed_buff: pokemonData ? pokemonData.speed_buff : 0, + item: pokemonData ? pokemonData.item : 0, }; } export let attackId: number | undefined; export let items: ItemData[]; let myValue; let index = 0; - let currentValue = 0; let pokemonData: PokemonData | undefined; let pokemonDataArray: PokemonData[] = []; let hp_final = 0; @@ -86,11 +88,16 @@ types: [], terastype: [0], hp: 0, - atk: 0, - def: 0, - spatk: 0, - spdef: 0, - spd: 0, + attack: 0, + defense: 0, + special_attack: 0, + special_defense: 0, + speed: 0, + attack_buff: 0, + defense_buff: 0, + special_attack_buff: 0, + special_defense_buff: 0, + speed_buff: 0, item: 0, }; async function getItems(keyword) { @@ -134,6 +141,7 @@ pokemonData = pokemonDataArray[i]; }} > + {#if pokemonDataArray[i]} {/each} -
-
- +
+ +
+
@@ -171,6 +187,10 @@
diff --git a/src/model/PokemonStatus.ts b/src/model/PokemonStatus.ts index 30bb873..dfacead 100644 --- a/src/model/PokemonStatus.ts +++ b/src/model/PokemonStatus.ts @@ -4,10 +4,15 @@ export interface PokemonStatus { types: number[], terastype: number[], hp: number, - atk: number, - def: number, - spatk: number, - spdef: number, - spd: number, + attack: number, + defense: number, + special_attack: number, + special_defense: number, + speed: number, + attack_buff: number, + defense_buff: number, + special_attack_buff: number, + special_defense_buff: number, + speed_buff: number, item: number, };