TypeScript用のタイプ追加 #2
@@ -2,9 +2,10 @@
|
|||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
import AutoComplete from "simple-svelte-autocomplete";
|
import AutoComplete from "simple-svelte-autocomplete";
|
||||||
import attack_types from "../const/attack_types.json";
|
import attack_types from "../const/attack_types.json";
|
||||||
|
import type { PokemonData } from "../model/PokemonStatus";
|
||||||
|
|
||||||
export let player1Data;
|
export let player1Data: PokemonData | undefined;
|
||||||
export let player2Data;
|
export let player2Data: PokemonData | undefined;
|
||||||
let attackData;
|
let attackData;
|
||||||
$: {
|
$: {
|
||||||
if (myValue > 0 && myValue !== currentValue) {
|
if (myValue > 0 && myValue !== currentValue) {
|
||||||
@@ -62,13 +63,13 @@
|
|||||||
minDamage: 0,
|
minDamage: 0,
|
||||||
// 攻撃側タイプ
|
// 攻撃側タイプ
|
||||||
// TODO: try catchでエラーハンドリング
|
// TODO: try catchでエラーハンドリング
|
||||||
atk_type: JSON.parse(attacker.types), // 配列なのでjson parse
|
atk_type: attacker.types,
|
||||||
atk_terastype: attacker.terastype,
|
atk_terastype: attacker.terastype,
|
||||||
// 防御側タイプ
|
// 防御側タイプ
|
||||||
def_type:
|
def_type:
|
||||||
defender.terastype[0] > 0
|
defender.terastype[0] > 0
|
||||||
? defender.terastype
|
? defender.terastype
|
||||||
: JSON.parse(defender.types),
|
: defender.types,
|
||||||
|
|
||||||
// 技タイプ
|
// 技タイプ
|
||||||
move_type: JSON.parse(attackData.types),
|
move_type: JSON.parse(attackData.types),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
import AutoComplete from "simple-svelte-autocomplete";
|
import AutoComplete from "simple-svelte-autocomplete";
|
||||||
import DisplayData from "./DisplayData.svelte";
|
import DisplayData from "./DisplayData.svelte";
|
||||||
|
import type { PokemonData } from "../model/PokemonStatus";
|
||||||
$: {
|
$: {
|
||||||
if (myValue > 0 && myValue !== currentValue) {
|
if (myValue > 0 && myValue !== currentValue) {
|
||||||
invoke("search", { index: myValue }).then((r) => {
|
invoke("search", { index: myValue }).then((r) => {
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
pokemonStatus = {
|
pokemonStatus = {
|
||||||
types: pokemonData?.types ? pokemonData.types : [],
|
types: pokemonData?.types ? JSON.parse(pokemonData.types) : [],
|
||||||
terastype: terastype,
|
terastype: terastype,
|
||||||
hp: hp_final,
|
hp: hp_final,
|
||||||
atk: atk_final,
|
atk: atk_final,
|
||||||
@@ -32,7 +33,7 @@
|
|||||||
let spatk_final = 0;
|
let spatk_final = 0;
|
||||||
let spdef_final = 0;
|
let spdef_final = 0;
|
||||||
let spd_final = 0;
|
let spd_final = 0;
|
||||||
export let pokemonStatus = {
|
export let pokemonStatus: PokemonData = {
|
||||||
types: [],
|
types: [],
|
||||||
terastype: [0],
|
terastype: [0],
|
||||||
hp: 0,
|
hp: 0,
|
||||||
|
|||||||
10
src/model/PokemonStatus.ts
Normal file
10
src/model/PokemonStatus.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export interface PokemonData {
|
||||||
|
types: number[],
|
||||||
|
terastype: number[],
|
||||||
|
hp: number,
|
||||||
|
atk: number,
|
||||||
|
def: number,
|
||||||
|
spatk: number,
|
||||||
|
spdef: number,
|
||||||
|
spd: number
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user