diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 99de0db..60bba0a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -122,7 +122,7 @@ fn search(index: i64) -> SearchResult { { let row_result = PokemonDataLearnset { id: row.read::("id"), - learset_id: row.read::("learnset_id"), + learnset_id: row.read::("learnset_id"), name: row.read::<&str, _>("name").to_string(), types: serde_json::from_str(row.read::<&str, _>("types")).unwrap_or(vec![0]), power: row.read::("power"), diff --git a/src-tauri/src/model.rs b/src-tauri/src/model.rs index bc60d5b..2abf7f6 100644 --- a/src-tauri/src/model.rs +++ b/src-tauri/src/model.rs @@ -19,7 +19,7 @@ pub struct SearchResult { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PokemonDataLearnset { pub id: i64, - pub learset_id: i64, + pub learnset_id: i64, pub name: String, pub types: Vec, pub power: i64, diff --git a/src/App.svelte b/src/App.svelte index ff2829c..12a32d3 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -4,19 +4,20 @@ import "carbon-components-svelte/css/g80.css"; let player1Data; let player2Data; + let attackId;
- +
- +
- +
diff --git a/src/lib/DamageCalculator.svelte b/src/lib/DamageCalculator.svelte index e88cef4..912a308 100644 --- a/src/lib/DamageCalculator.svelte +++ b/src/lib/DamageCalculator.svelte @@ -6,6 +6,7 @@ export let player1Data: PokemonData | undefined; export let player2Data: PokemonData | undefined; + export let attackId: number | undefined; let attackData; $: { if (myValue > 0 && myValue !== currentValue) { @@ -15,6 +16,14 @@ console.log(attackData); }); } + if (!!attackId) { + invoke("search_move", { index: attackId }).then((r) => { + currentValue = myValue = attackId; + attackData = r; + console.log(attackData); + attackId = undefined; + }); + } } let attack_direction = "p1p2"; let total_max_damage = 0; diff --git a/src/lib/DisplayData.svelte b/src/lib/DisplayData.svelte index 9935f9b..e5ea9cd 100644 --- a/src/lib/DisplayData.svelte +++ b/src/lib/DisplayData.svelte @@ -6,6 +6,7 @@ import SpecialIcon from "../assets/tokushu.png"; import BuffIcon from "../assets/henka.png"; export let pokemonData: PokemonDBData | undefined; + export let attackId: number | undefined; function v_validator(v) { if (typeof v !== "number") { return null; @@ -618,10 +619,27 @@ - +
{#each pokemonData.learnset as learnset} - - + { + console.log("passing" + learnset.name); + console.log(learnset.learnset_id); + console.log(attackId); + attackId = learnset.learnset_id; + console.log(attackId); + }} + > + @@ -675,8 +693,8 @@ } .vd-input { width: 50px; - padding-left:0; - padding-right:0; + padding-left: 0; + padding-right: 0; height: 8px; } .abilities_table { @@ -700,4 +718,17 @@ vertical-align: middle; min-height: 25px; } + .learnset { + width: 90%; + } + .learnset > tr:hover { + width: 90%; + background-color: rgba(255, 255, 255, 0.5); + cursor: pointer; + } + .learnset > tr > td { + border: 1px solid; + vertical-align: middle; + min-height: 25px; + } diff --git a/src/lib/MainWrapper.svelte b/src/lib/MainWrapper.svelte index 4365872..d33b10c 100644 --- a/src/lib/MainWrapper.svelte +++ b/src/lib/MainWrapper.svelte @@ -24,6 +24,7 @@ }; console.log(pokemonStatus); } + export let attackId: number | undefined; let myValue; let currentValue = 0; let pokemonData: PokemonDBData | undefined; @@ -78,6 +79,7 @@ bind:spatk_final bind:spdef_final bind:spd_final + bind:attackId />
a
a {@html generate_type(learnset.types)} {learnset.name} {learnset.power}