Skip to content

Commit 2b69cbd

Browse files
author
Taylor Rodríguez
authored
Add Hidden Power display for Crystal (#62)
1 parent 525f134 commit 2b69cbd

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

reader_core/src/crystal/draw.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ pub fn draw_rng(reader: &Gen2Reader) {
4040
pub fn draw_pkx(pkx: &Pk2) {
4141
pnp::println!("Species: {}", pkx.species);
4242
pnp::println!(color = get_shiny_color(pkx.shiny), "Shiny: {}", pkx.shiny);
43+
pnp::println!(
44+
"HPower: {} {}",
45+
pkx.hidden_power_type,
46+
pkx.hidden_power_base
47+
);
4348
pnp::println!(color = get_iv_color(pkx.hp), "HP DV: {}", pkx.hp);
4449
pnp::println!(color = get_iv_color(pkx.atk), "Atk DV: {}", pkx.atk);
4550
pnp::println!(color = get_iv_color(pkx.def), "Def DV: {}", pkx.def);

reader_core/src/crystal/pk2.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ const NATURE_LOOKUP: [&str; 25] = [
259259
"Calm", "Gentle", "Sassy", "Careful", "Quirky",
260260
];
261261

262+
const HIDDEN_POWER_LOOKUP: [&str; 16] = [
263+
"Fighting", "Flying", "Poison", "Ground", "Rock", "Bug", "Ghost", "Steel", "Fire", "Water",
264+
"Grass", "Electric", "Psychic", "Ice", "Dragon", "Dark",
265+
];
266+
262267
pub struct Pk2 {
263268
pub spec_index: u8,
264269
pub species: &'static str,
@@ -270,6 +275,8 @@ pub struct Pk2 {
270275
pub spc: u8,
271276
pub hp: u8,
272277
pub shiny: bool,
278+
pub hidden_power_type: &'static str,
279+
pub hidden_power_base: u8,
273280
}
274281

275282
impl Pk2 {
@@ -302,6 +309,16 @@ impl Pk2 {
302309
spc,
303310
hp: ((atk & 1) * 8) + ((def & 1) * 4) + ((spe & 1) * 2) + (spc & 1),
304311
shiny,
312+
hidden_power_type: HIDDEN_POWER_LOOKUP
313+
.get(((atk & 3) << 2 | def & 3) as usize)
314+
.unwrap_or(&"Unknown"),
315+
hidden_power_base: 31
316+
+ (5 * ((atk >> 3) << 3
317+
| (def >> 3) << 2
318+
| (spe >> 3) << 1
319+
| (spc >> 3))
320+
+ (spc & 3))
321+
/ 2,
305322
}
306323
}
307324
}

0 commit comments

Comments
 (0)