changed string to hashmap/record for abilities
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
|
||||
use serde_json::json;
|
||||
@@ -241,7 +242,7 @@ fn search(index: i64) -> SearchResult {
|
||||
name: row.read::<&str, _>("name").to_string(),
|
||||
types: serde_json::from_str(row.read::<&str, _>("types")).unwrap_or(vec![0]),
|
||||
thumbnail: row.read::<&str, _>("thumbnail").to_string(),
|
||||
abilities: row.read::<&str, _>("abilities").to_string(),
|
||||
abilities: serde_json::from_str(row.read::<&str, _>("abilities")).unwrap_or(HashMap::new()),
|
||||
hp: row.read::<i64, _>("hp"),
|
||||
attack: row.read::<i64, _>("attack"),
|
||||
defense: row.read::<i64, _>("defense"),
|
||||
@@ -257,7 +258,7 @@ fn search(index: i64) -> SearchResult {
|
||||
name: "Missigno".to_string(),
|
||||
types: vec![],
|
||||
thumbnail: "".to_string(),
|
||||
abilities: "{}".to_string(),
|
||||
abilities: HashMap::new(),
|
||||
hp: 0,
|
||||
attack: 0,
|
||||
defense: 0,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
@@ -11,7 +13,7 @@ pub struct SearchResult {
|
||||
pub special_attack: i64,
|
||||
pub special_defense: i64,
|
||||
pub speed: i64,
|
||||
pub abilities: String,
|
||||
pub abilities: HashMap<String, String>,
|
||||
pub thumbnail: String,
|
||||
pub learnset: Vec<PokemonDataLearnset>,
|
||||
}
|
||||
@@ -82,7 +84,7 @@ pub struct PokemonDataToLoad {
|
||||
pub name: String,
|
||||
pub types: Vec<i64>,
|
||||
pub thumbnail: String,
|
||||
pub abilities: String,
|
||||
pub abilities: HashMap<String, String>,
|
||||
pub hp: i64,
|
||||
pub attack: i64,
|
||||
pub defense: i64,
|
||||
|
||||
Reference in New Issue
Block a user