terastal dropdown added
This commit is contained in:
@@ -13,6 +13,26 @@
|
|||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
const available_type = [
|
||||||
|
{ id: 1 },
|
||||||
|
{ id: 2 },
|
||||||
|
{ id: 3 },
|
||||||
|
{ id: 4 },
|
||||||
|
{ id: 5 },
|
||||||
|
{ id: 6 },
|
||||||
|
{ id: 7 },
|
||||||
|
{ id: 8 },
|
||||||
|
{ id: 9 },
|
||||||
|
{ id: 10 },
|
||||||
|
{ id: 11 },
|
||||||
|
{ id: 12 },
|
||||||
|
{ id: 13 },
|
||||||
|
{ id: 14 },
|
||||||
|
{ id: 15 },
|
||||||
|
{ id: 16 },
|
||||||
|
{ id: 17 },
|
||||||
|
{ id: 18 }
|
||||||
|
]
|
||||||
function d_validator(d) {
|
function d_validator(d) {
|
||||||
if (typeof d !== "number") {
|
if (typeof d !== "number") {
|
||||||
return null;
|
return null;
|
||||||
@@ -165,6 +185,7 @@
|
|||||||
}
|
}
|
||||||
function generate_weakness(types) {
|
function generate_weakness(types) {
|
||||||
let parsed_types = JSON.parse(types);
|
let parsed_types = JSON.parse(types);
|
||||||
|
console.log(parsed_types)
|
||||||
let type_compatibility = defense_types[parsed_types[0] - 1];
|
let type_compatibility = defense_types[parsed_types[0] - 1];
|
||||||
if (parsed_types.length > 1) {
|
if (parsed_types.length > 1) {
|
||||||
let second_type_compatibility = defense_types[parsed_types[1] - 1];
|
let second_type_compatibility = defense_types[parsed_types[1] - 1];
|
||||||
@@ -239,7 +260,9 @@
|
|||||||
export let spatk_final = 0;
|
export let spatk_final = 0;
|
||||||
export let spdef_final = 0;
|
export let spdef_final = 0;
|
||||||
export let spd_final = 0;
|
export let spd_final = 0;
|
||||||
|
export let terastype = [0];
|
||||||
|
|
||||||
|
let selected_terastype = 0;
|
||||||
let atk_plus = false;
|
let atk_plus = false;
|
||||||
let def_plus = false;
|
let def_plus = false;
|
||||||
let spatk_plus = false;
|
let spatk_plus = false;
|
||||||
@@ -264,21 +287,36 @@
|
|||||||
<div class="data-container">
|
<div class="data-container">
|
||||||
{#if pokemonData && pokemonData.id && pokemonData.id > 0}
|
{#if pokemonData && pokemonData.id && pokemonData.id > 0}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<img src={`data:image/png;base64,${pokemonData.thumbnail}`} alt={pokemonData.jap_name} width="15%"/>
|
<table class="pokemon-data">
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<table>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>{pokemonData.name}</b></td>
|
<td rowspan="3" class="picture"><img src={`data:image/png;base64,${pokemonData.thumbnail}`} alt={pokemonData.jap_name} width="85%"/></td>
|
||||||
|
<td class="pokemon-title">名前</td>
|
||||||
|
<td class="pokemon-name">{pokemonData.name}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="pokemon-title">タイプ</td>
|
||||||
<td style="display: flex;">{@html generate_type(JSON.parse(pokemonData.types))}</td>
|
<td style="display: flex;">{@html generate_type(JSON.parse(pokemonData.types))}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="pokemon-title">テラスタル</td>
|
||||||
|
<td style="display: flex;">
|
||||||
|
<select bind:value={selected_terastype} on:change="{() => terastype = [selected_terastype]}">
|
||||||
|
<option value={0}>
|
||||||
|
なし
|
||||||
|
</option>
|
||||||
|
{#each available_type as curr_type}
|
||||||
|
<option value={curr_type.id}>
|
||||||
|
{@html generate_type([curr_type.id])}
|
||||||
|
</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<table class="weakness">
|
<table class="weakness">
|
||||||
{#each generate_weakness(pokemonData.types) as row, i}
|
{#each generate_weakness(terastype[0] === 0 ? pokemonData.types : JSON.stringify(terastype)) as row, i}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{generate_damage_value(i)}</td>
|
<td>{generate_damage_value(i)}</td>
|
||||||
<td style="display: flex; flex-wrap: wrap;">
|
<td style="display: flex; flex-wrap: wrap;">
|
||||||
@@ -369,6 +407,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.pokemon-data {
|
||||||
|
width:90%;
|
||||||
|
}
|
||||||
|
.pokemon-title {
|
||||||
|
width: 20%;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.pokemon-name {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.picture {
|
||||||
|
width:20%;
|
||||||
|
}
|
||||||
.data-container {
|
.data-container {
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
}
|
}
|
||||||
pokemonStatus = {
|
pokemonStatus = {
|
||||||
types: pokemonData?.types ? pokemonData.types : [],
|
types: pokemonData?.types ? pokemonData.types : [],
|
||||||
|
terastype: terastype,
|
||||||
hp: hp_final,
|
hp: hp_final,
|
||||||
atk: atk_final,
|
atk: atk_final,
|
||||||
def: def_final,
|
def: def_final,
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
let myValue;
|
let myValue;
|
||||||
let currentValue = 0;
|
let currentValue = 0;
|
||||||
let pokemonData;
|
let pokemonData;
|
||||||
|
let terastype = [0];
|
||||||
let hp_final = 0;
|
let hp_final = 0;
|
||||||
let atk_final = 0;
|
let atk_final = 0;
|
||||||
let def_final = 0;
|
let def_final = 0;
|
||||||
@@ -32,6 +34,7 @@
|
|||||||
let spd_final = 0;
|
let spd_final = 0;
|
||||||
export let pokemonStatus = {
|
export let pokemonStatus = {
|
||||||
types: [],
|
types: [],
|
||||||
|
terastype: [0],
|
||||||
hp: 0,
|
hp: 0,
|
||||||
atk: 0,
|
atk: 0,
|
||||||
def: 0,
|
def: 0,
|
||||||
@@ -66,6 +69,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<DisplayData
|
<DisplayData
|
||||||
{pokemonData}
|
{pokemonData}
|
||||||
|
bind:terastype
|
||||||
bind:hp_final
|
bind:hp_final
|
||||||
bind:atk_final
|
bind:atk_final
|
||||||
bind:def_final
|
bind:def_final
|
||||||
|
|||||||
Reference in New Issue
Block a user