some more fixes for data consistency

This commit is contained in:
2023-02-06 01:50:05 +09:00
parent 97bdcff481
commit c35d4d5ce1
7 changed files with 339 additions and 177 deletions

View File

@@ -21,28 +21,53 @@
special_attack: r.special_attack,
special_defense: r.special_defense,
speed: r.speed,
hp_v: 31,
attack_v: 31,
defense_v: 31,
special_attack_v: 31,
special_defense_v: 31,
speed_v: 31,
hp_d: 0,
attack_d: 0,
defense_d: 0,
special_attack_d: 0,
special_defense_d: 0,
speed_d: 0,
learnset: r.learnset,
item: 0,
terastype: [0],
attack_plus: false,
attack_minus: false,
defense_plus: false,
defense_minus: false,
special_attack_plus: false,
special_attack_minus: false,
special_defense_plus: false,
special_defense_minus: false,
speed_plus: false,
speed_minus: false,
attack_buff: 0,
defense_buff: 0,
special_attack_buff: 0,
special_defense_buff: 0,
speed_buff: 0,
};
item = 0;
terastype = [0];
pokemonDataArray[index] = pokemonData;
console.log(pokemonData);
console.log(currentValue);
myValue = undefined;
});
}
pokemonStatus = {
types: pokemonData?.types ? JSON.parse(pokemonData.types) : [],
terastype: terastype,
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: item,
item: pokemonData? pokemonData.item : 0,
};
console.log(pokemonStatus);
}
export let attackId: number | undefined;
export let items: ItemData[];
@@ -51,14 +76,12 @@
let currentValue = 0;
let pokemonData: PokemonData | undefined;
let pokemonDataArray: PokemonData[] = [];
let terastype = [0];
let hp_final = 0;
let atk_final = 0;
let def_final = 0;
let spatk_final = 0;
let spdef_final = 0;
let spd_final = 0;
let item = 0;
export let pokemonStatus: PokemonStatus = {
types: [],
terastype: [0],
@@ -73,7 +96,6 @@
async function getItems(keyword) {
try {
let result = await invoke("autosearch", { keyword });
console.log(result);
return result;
} catch (e) {
console.log(e);
@@ -98,33 +120,43 @@
<div class="pokemon-button-div">
<table class="button-table">
{#each [0, 1, 2, 3, 4, 5] as i}
<tr>
<td>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="pokemon-button {i % 2 === 0 ? "odd" : "even"}" on:click={() => {
index = i;
pokemonData = pokemonDataArray[i];
}}>
{#if pokemonDataArray[i]}
<img
src={`data:image/png;base64,${pokemonDataArray[i].thumbnail}`}
alt={pokemonDataArray[i].name}
width="15%"
/>
{pokemonDataArray[i].name}
{:else}
No Pokemon
{/if}
</div>
</td>
</tr>
<tr>
<td>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="pokemon-button {i == index
? 'active'
: i % 2 === 0
? 'odd'
: 'even'}"
on:click={() => {
index = i;
pokemonData = pokemonDataArray[i];
}}
>
{#if pokemonDataArray[i]}
<img
src={`data:image/png;base64,${pokemonDataArray[i].thumbnail}`}
alt={pokemonDataArray[i].name}
width="15%"
/>
{pokemonDataArray[i].name}
{:else}
No Pokemon
{/if}
</div>
</td>
</tr>
{/each}
</table>
<div>
<button>Save</button> <button>Load</button><br />
<button on:click={() => {pokemonData = undefined; pokemonDataArray = []; index = 0; myValue = undefined;}}>Clear</button>
</div>
</div>
<div class="display-data">
<DisplayData
{pokemonData}
bind:terastype
bind:hp_final
bind:atk_final
bind:def_final
@@ -132,7 +164,6 @@
bind:spdef_final
bind:spd_final
bind:attackId
bind:item
{items}
/>
</div>
@@ -156,32 +187,44 @@
height: 759px;
overflow-y: scroll;
}
.pokemon-button {
.pokemon-button {
padding: 10px;
border-top-left-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
height: 50px;
justify-content: center;
height: 50px;
-webkit-user-select: none; /* Safari */
-ms-user-select: none; /* IE 10 and IE 11 */
user-select: none; /* Standard syntax */
border-right: 2px solid white;
border-bottom: 1px solid black;
}
.active {
background-color: #d1be01;
cursor: unset;
color: black;
font-weight: bold;
text-shadow: 1px 1px 1px white;
}
.odd {
color: black;
background-color: azure;
color: white;
background-color: #f5453d;
}
.odd:hover {
color: black;
background-color:aquamarine;
transition: background-color 1s ease;
color: white;
background-color: #f7bbb8;
transition: background-color .5s ease;
cursor: pointer;
}
.even {
color: black;
background-color: beige;
color: white;
background-color: #3d3094;
}
.even:hover {
color: black;
background-color:burlywood;
transition: background-color 1s ease;
color: white;
background-color: #b6b4ff;
transition: background-color .5s ease;
cursor: pointer;
}
</style>