Compare commits
2 Commits
20a3a0bbe4
...
42b6f6af20
| Author | SHA1 | Date | |
|---|---|---|---|
| 42b6f6af20 | |||
| 8d8911a4a2 |
@@ -225,26 +225,8 @@ fn search_learnset(index: i64) -> Vec<PokemonDataLearnset> {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn search(index: i64) -> SearchResult {
|
fn search(index: i64) -> SearchResult {
|
||||||
let connection = sqlite::open("./pokemon.db").unwrap();
|
let connection = sqlite::open("./pokemon.db").unwrap();
|
||||||
let mut learnset: Vec<PokemonDataLearnset> = vec![];
|
let learnset = search_learnset(index.clone());
|
||||||
let move_query = "SELECT pl.id, pl.learnset_id, l.name, l.types, l.power, l.category FROM pokemon__learnset pl JOIN learnset l on pl.learnset_id = l.id WHERE pl.pokemon_id = ? ORDER BY usage DESC";
|
|
||||||
for row in connection
|
|
||||||
.prepare(move_query)
|
|
||||||
.unwrap()
|
|
||||||
.into_iter()
|
|
||||||
.bind((1, index))
|
|
||||||
.unwrap()
|
|
||||||
.map(|row| row.unwrap())
|
|
||||||
{
|
|
||||||
let row_result = PokemonDataLearnset {
|
|
||||||
id: row.read::<i64, _>("id"),
|
|
||||||
learnset_id: row.read::<i64, _>("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::<i64, _>("power"),
|
|
||||||
category: row.read::<i64, _>("category"),
|
|
||||||
};
|
|
||||||
learnset.push(row_result)
|
|
||||||
}
|
|
||||||
let query = "SELECT * FROM pokemon WHERE id = ?";
|
let query = "SELECT * FROM pokemon WHERE id = ?";
|
||||||
for row in connection
|
for row in connection
|
||||||
.prepare(query)
|
.prepare(query)
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ impl From<(PokemonDataToSave, SearchResult)> for PokemonDataToLoad {
|
|||||||
special_defense_buff: 0,
|
special_defense_buff: 0,
|
||||||
speed_buff: 0,
|
speed_buff: 0,
|
||||||
item: value.0.item,
|
item: value.0.item,
|
||||||
learnset: vec![],
|
learnset: value.1.learnset,
|
||||||
terastype: vec![0]
|
terastype: vec![0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,7 @@
|
|||||||
<button
|
<button
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
invoke("load_json").then((d) => {
|
invoke("load_json").then((d) => {
|
||||||
|
// fix this type issue
|
||||||
pokemonDataArray = d;
|
pokemonDataArray = d;
|
||||||
pokemonData = pokemonDataArray[index];
|
pokemonData = pokemonDataArray[index];
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user