poke_engine/
items.rs

1#![allow(unused_variables)]
2use crate::abilities::Abilities;
3use crate::choices::{Choice, Choices, Effect, MoveCategory, MoveTarget, Secondary, StatBoosts};
4use crate::damage_calc::type_effectiveness_modifier;
5use crate::define_enum_with_from_str;
6use crate::generate_instructions::{get_boost_instruction, immune_to_status};
7use crate::instruction::{
8    ChangeItemInstruction, ChangeStatusInstruction, DamageInstruction, DisableMoveInstruction,
9    HealInstruction, Instruction, StateInstructions,
10};
11use crate::pokemon::PokemonName;
12use crate::state::{Pokemon, PokemonType, Side};
13use crate::state::{PokemonBoostableStat, State, Terrain};
14use crate::state::{PokemonStatus, SideReference};
15use std::cmp;
16
17#[cfg(feature = "gen4")]
18use crate::state::PokemonVolatileStatus;
19
20define_enum_with_from_str! {
21    #[repr(u8)]
22    #[derive(Debug, PartialEq, Clone, Copy)]
23    Items {
24        NONE,
25        UNKNOWNITEM,
26        ABSORBBULB,
27        ADRENALINEORB,
28        ADAMANTORB,
29        ADAMANTCRYSTAL,
30        AIRBALLOON,
31        ASSAULTVEST,
32        BABIRIBERRY,
33        BLACKBELT,
34        BLACKSLUDGE,
35        BLACKGLASSES,
36        BLANKPLATE,
37        BOOSTERENERGY,
38        CELLBATTERY,
39        CHARCOAL,
40        CHARTIBERRY,
41        CHILANBERRY,
42        CHOICEBAND,
43        CHOICESPECS,
44        CHOICESCARF,
45        CHOPLEBERRY,
46        COBABERRY,
47        COLBURBERRY,
48        CUSTAPBERRY,
49        DRAGONFANG,
50        DRAGONSCALE,
51        DREADPLATE,
52        EARTHPLATE,
53        ELECTRICSEED,
54        EXPERTBELT,
55        EVIOLITE,
56        FAIRYFEATHER,
57        FISTPLATE,
58        FLAMEORB,
59        GRASSYSEED,
60        HABANBERRY,
61        KASIBBERRY,
62        KEBIABERRY,
63        LEFTOVERS,
64        LIFEORB,
65        LUSTROUSORB,
66        LUSTROUSGLOBE,
67        METALCOAT,
68        MISTYSEED,
69        MUSCLEBAND,
70        MYSTICWATER,
71        NEVERMELTICE,
72        PINKBOW,
73        POLKADOTBOW,
74        OCCABERRY,
75        ODDINCENSE,
76        PASSHOBERRY,
77        PAYAPABERRY,
78        POISONBARB,
79        POWERHERB,
80        PSYCHICSEED,
81        PUNCHINGGLOVE,
82        RINDOBERRY,
83        ROSELIBERRY,
84        ROCKYHELMET,
85        SEAINCENSE,
86        SHARPBEAK,
87        SPELLTAG,
88        MIRACLESEED,
89        SHELLBELL,
90        SHUCABERRY,
91        SILKSCARF,
92        SILVERPOWDER,
93        SKYPLATE,
94        SOFTSAND,
95        SOULDEW,
96        GRISEOUSORB,
97        GRISEOUSCORE,
98        TANGABERRY,
99        THROATSPRAY,
100        THICKCLUB,
101        TOXICORB,
102        TOXICPLATE,
103        TWISTEDSPOON,
104        HARDSTONE,
105        METALPOWDER,
106        WACANBERRY,
107        WAVEINCENSE,
108        MAGNET,
109        WEAKNESSPOLICY,
110        WISEGLASSES,
111        BLUNDERPOLICY,
112        HEAVYDUTYBOOTS,
113        CLEARAMULET,
114        PROTECTIVEPADS,
115        SHEDSHELL,
116        YACHEBERRY,
117        STONEPLATE,
118        INSECTPLATE,
119        SPOOKYPLATE,
120        IRONBALL,
121        IRONPLATE,
122        FLAMEPLATE,
123        SPLASHPLATE,
124        MEADOWPLATE,
125        ZAPPLATE,
126        MINDPLATE,
127        ICICLEPLATE,
128        DRACOPLATE,
129        PIXIEPLATE,
130        LIGHTBALL,
131        FOCUSSASH,
132        LUMBERRY,
133        SITRUSBERRY,
134        PETAYABERRY,
135        SALACBERRY,
136        LIECHIBERRY,
137        NORMALGEM,
138        BUGGEM,
139        ELECTRICGEM,
140        FIGHTINGGEM,
141        GHOSTGEM,
142        PSYCHICGEM,
143        FLYINGGEM,
144        STEELGEM,
145        ICEGEM,
146        POISONGEM,
147        FIREGEM,
148        DRAGONGEM,
149        GROUNDGEM,
150        WATERGEM,
151        DARKGEM,
152        ROCKGEM,
153        GRASSGEM,
154        FAIRYGEM,
155        BUGMEMORY,
156        FIGHTINGMEMORY,
157        GHOSTMEMORY,
158        PSYCHICMEMORY,
159        FLYINGMEMORY,
160        STEELMEMORY,
161        ICEMEMORY,
162        POISONMEMORY,
163        FIREMEMORY,
164        DRAGONMEMORY,
165        GROUNDMEMORY,
166        WATERMEMORY,
167        DARKMEMORY,
168        ROCKMEMORY,
169        GRASSMEMORY,
170        FAIRYMEMORY,
171        ELECTRICMEMORY,
172        WELLSPRINGMASK,
173        HEARTHFLAMEMASK,
174        CORNERSTONEMASK,
175        WIDELENS,
176        LOADEDDICE,
177    },
178    default = UNKNOWNITEM
179}
180
181pub fn get_choice_move_disable_instructions(
182    pkmn: &Pokemon,
183    side_ref: &SideReference,
184    move_name: &Choices,
185) -> Vec<Instruction> {
186    let mut moves_to_disable = vec![];
187    let mut iter = pkmn.moves.into_iter();
188    while let Some(p) = iter.next() {
189        if &p.id != move_name && p.disabled == false {
190            moves_to_disable.push(Instruction::DisableMove(DisableMoveInstruction {
191                side_ref: *side_ref,
192                move_index: iter.pokemon_move_index,
193            }));
194        }
195    }
196    moves_to_disable
197}
198
199fn damage_reduction_berry(
200    defending_pkmn: &mut Pokemon,
201    attacking_side_ref: &SideReference,
202    choice: &mut Choice,
203    berry: Items,
204    pkmn_type: &PokemonType,
205    instructions: &mut StateInstructions,
206) {
207    if &choice.move_type == pkmn_type
208        && type_effectiveness_modifier(pkmn_type, &defending_pkmn) > 1.0
209    {
210        instructions
211            .instruction_list
212            .push(Instruction::ChangeItem(ChangeItemInstruction {
213                side_ref: attacking_side_ref.get_other_side(),
214                current_item: berry,
215                new_item: Items::NONE,
216            }));
217        defending_pkmn.item = Items::NONE;
218        choice.base_power /= 2.0;
219    }
220}
221
222/*
223NormalGem, FlyingGem, etc.
224*/
225fn power_up_gem(
226    attacking_side_ref: &SideReference,
227    attacking_pkmn: &mut Pokemon,
228    choice: &mut Choice,
229    gem_type: PokemonType,
230    instructions: &mut StateInstructions,
231) {
232    if &choice.move_type == &gem_type {
233        #[cfg(feature = "gen5")]
234        {
235            choice.base_power *= 1.5;
236        }
237        #[cfg(not(feature = "gen5"))]
238        {
239            choice.base_power *= 1.3;
240        }
241
242        instructions
243            .instruction_list
244            .push(Instruction::ChangeItem(ChangeItemInstruction {
245                side_ref: *attacking_side_ref,
246                current_item: attacking_pkmn.item,
247                new_item: Items::NONE,
248            }));
249        attacking_pkmn.item = Items::NONE;
250    }
251}
252
253/*
254Regarding berries:
255    most berries (lum, sitrus, etc) activate right away when applicable, but there isn't
256    logic in this engine to implement that. Attempting to activate these berries before the user's
257    move AND at the end-of-turn should be accurate enough for a simulation. The item is
258    removed after this is triggered so only one will take effect
259*/
260fn lum_berry(
261    side_ref: &SideReference,
262    attacking_side: &mut Side,
263    instructions: &mut StateInstructions,
264) {
265    let active_index = attacking_side.active_index;
266    let active_pkmn = attacking_side.get_active();
267    instructions
268        .instruction_list
269        .push(Instruction::ChangeStatus(ChangeStatusInstruction {
270            side_ref: *side_ref,
271            pokemon_index: active_index,
272            new_status: PokemonStatus::NONE,
273            old_status: active_pkmn.status,
274        }));
275    active_pkmn.status = PokemonStatus::NONE;
276    instructions
277        .instruction_list
278        .push(Instruction::ChangeItem(ChangeItemInstruction {
279            side_ref: *side_ref,
280            current_item: Items::LUMBERRY,
281            new_item: Items::NONE,
282        }));
283    active_pkmn.item = Items::NONE;
284}
285
286fn sitrus_berry(
287    side_ref: &SideReference,
288    attacking_side: &mut Side,
289    instructions: &mut StateInstructions,
290) {
291    let active_pkmn = attacking_side.get_active();
292    let heal_amount = cmp::min(active_pkmn.maxhp / 4, active_pkmn.maxhp - active_pkmn.hp);
293    instructions
294        .instruction_list
295        .push(Instruction::Heal(HealInstruction {
296            side_ref: *side_ref,
297            heal_amount: heal_amount,
298        }));
299    active_pkmn.hp += heal_amount;
300    instructions
301        .instruction_list
302        .push(Instruction::ChangeItem(ChangeItemInstruction {
303            side_ref: *side_ref,
304            current_item: Items::SITRUSBERRY,
305            new_item: Items::NONE,
306        }));
307    active_pkmn.item = Items::NONE;
308}
309
310fn boost_berry(
311    side_ref: &SideReference,
312    attacking_side: &mut Side,
313    stat: PokemonBoostableStat,
314    instructions: &mut StateInstructions,
315) {
316    if let Some(ins) = get_boost_instruction(&attacking_side, &stat, &1, side_ref, side_ref) {
317        match stat {
318            PokemonBoostableStat::Attack => attacking_side.attack_boost += 1,
319            PokemonBoostableStat::Defense => attacking_side.defense_boost += 1,
320            PokemonBoostableStat::SpecialAttack => attacking_side.special_attack_boost += 1,
321            PokemonBoostableStat::SpecialDefense => attacking_side.special_defense_boost += 1,
322            PokemonBoostableStat::Speed => attacking_side.speed_boost += 1,
323            PokemonBoostableStat::Accuracy => attacking_side.accuracy_boost += 1,
324            PokemonBoostableStat::Evasion => attacking_side.evasion_boost += 1,
325        }
326        instructions.instruction_list.push(ins);
327    }
328    let attacker = attacking_side.get_active();
329    instructions
330        .instruction_list
331        .push(Instruction::ChangeItem(ChangeItemInstruction {
332            side_ref: *side_ref,
333            current_item: attacker.item,
334            new_item: Items::NONE,
335        }));
336    attacking_side.get_active().item = Items::NONE;
337}
338
339pub fn item_before_move(
340    state: &mut State,
341    choice: &mut Choice,
342    side_ref: &SideReference,
343    instructions: &mut StateInstructions,
344) {
345    let (attacking_side, defending_side) = state.get_both_sides(side_ref);
346    let active_pkmn = attacking_side.get_active();
347    let defending_pkmn = defending_side.get_active();
348    match defending_pkmn.item {
349        Items::CHOPLEBERRY => damage_reduction_berry(
350            defending_pkmn,
351            side_ref,
352            choice,
353            Items::CHOPLEBERRY,
354            &PokemonType::FIGHTING,
355            instructions,
356        ),
357        Items::BABIRIBERRY => damage_reduction_berry(
358            defending_pkmn,
359            side_ref,
360            choice,
361            Items::BABIRIBERRY,
362            &PokemonType::STEEL,
363            instructions,
364        ),
365        Items::CHARTIBERRY => damage_reduction_berry(
366            defending_pkmn,
367            side_ref,
368            choice,
369            Items::CHARTIBERRY,
370            &PokemonType::ROCK,
371            instructions,
372        ),
373        Items::CHILANBERRY => {
374            // no type effectiveness check for chilan
375            if &choice.move_type == &PokemonType::NORMAL {
376                instructions.instruction_list.push(Instruction::ChangeItem(
377                    ChangeItemInstruction {
378                        side_ref: side_ref.get_other_side(),
379                        current_item: Items::CHILANBERRY,
380                        new_item: Items::NONE,
381                    },
382                ));
383                defending_pkmn.item = Items::NONE;
384                choice.base_power /= 2.0;
385            }
386        }
387        Items::COBABERRY => damage_reduction_berry(
388            defending_pkmn,
389            side_ref,
390            choice,
391            Items::COBABERRY,
392            &PokemonType::FLYING,
393            instructions,
394        ),
395        Items::COLBURBERRY => damage_reduction_berry(
396            defending_pkmn,
397            side_ref,
398            choice,
399            Items::COLBURBERRY,
400            &PokemonType::DARK,
401            instructions,
402        ),
403        Items::HABANBERRY => damage_reduction_berry(
404            defending_pkmn,
405            side_ref,
406            choice,
407            Items::HABANBERRY,
408            &PokemonType::DRAGON,
409            instructions,
410        ),
411        Items::KASIBBERRY => damage_reduction_berry(
412            defending_pkmn,
413            side_ref,
414            choice,
415            Items::KASIBBERRY,
416            &PokemonType::GHOST,
417            instructions,
418        ),
419        Items::KEBIABERRY => damage_reduction_berry(
420            defending_pkmn,
421            side_ref,
422            choice,
423            Items::KEBIABERRY,
424            &PokemonType::POISON,
425            instructions,
426        ),
427        Items::OCCABERRY => damage_reduction_berry(
428            defending_pkmn,
429            side_ref,
430            choice,
431            Items::OCCABERRY,
432            &PokemonType::FIRE,
433            instructions,
434        ),
435        Items::PASSHOBERRY => damage_reduction_berry(
436            defending_pkmn,
437            side_ref,
438            choice,
439            Items::PASSHOBERRY,
440            &PokemonType::WATER,
441            instructions,
442        ),
443        Items::PAYAPABERRY => damage_reduction_berry(
444            defending_pkmn,
445            side_ref,
446            choice,
447            Items::PAYAPABERRY,
448            &PokemonType::PSYCHIC,
449            instructions,
450        ),
451        Items::RINDOBERRY => damage_reduction_berry(
452            defending_pkmn,
453            side_ref,
454            choice,
455            Items::RINDOBERRY,
456            &PokemonType::GRASS,
457            instructions,
458        ),
459        Items::ROSELIBERRY => damage_reduction_berry(
460            defending_pkmn,
461            side_ref,
462            choice,
463            Items::ROSELIBERRY,
464            &PokemonType::FAIRY,
465            instructions,
466        ),
467        Items::SHUCABERRY => damage_reduction_berry(
468            defending_pkmn,
469            side_ref,
470            choice,
471            Items::SHUCABERRY,
472            &PokemonType::GROUND,
473            instructions,
474        ),
475        Items::TANGABERRY => damage_reduction_berry(
476            defending_pkmn,
477            side_ref,
478            choice,
479            Items::TANGABERRY,
480            &PokemonType::BUG,
481            instructions,
482        ),
483        Items::WACANBERRY => damage_reduction_berry(
484            defending_pkmn,
485            side_ref,
486            choice,
487            Items::WACANBERRY,
488            &PokemonType::ELECTRIC,
489            instructions,
490        ),
491        Items::YACHEBERRY => damage_reduction_berry(
492            defending_pkmn,
493            side_ref,
494            choice,
495            Items::YACHEBERRY,
496            &PokemonType::ICE,
497            instructions,
498        ),
499        _ => {}
500    }
501    match active_pkmn.item {
502        Items::NORMALGEM => power_up_gem(
503            side_ref,
504            active_pkmn,
505            choice,
506            PokemonType::NORMAL,
507            instructions,
508        ),
509        Items::BUGGEM => power_up_gem(
510            side_ref,
511            active_pkmn,
512            choice,
513            PokemonType::BUG,
514            instructions,
515        ),
516        Items::ELECTRICGEM => power_up_gem(
517            side_ref,
518            active_pkmn,
519            choice,
520            PokemonType::ELECTRIC,
521            instructions,
522        ),
523        Items::FIGHTINGGEM => power_up_gem(
524            side_ref,
525            active_pkmn,
526            choice,
527            PokemonType::FIGHTING,
528            instructions,
529        ),
530        Items::GHOSTGEM => power_up_gem(
531            side_ref,
532            active_pkmn,
533            choice,
534            PokemonType::GHOST,
535            instructions,
536        ),
537        Items::PSYCHICGEM => power_up_gem(
538            side_ref,
539            active_pkmn,
540            choice,
541            PokemonType::PSYCHIC,
542            instructions,
543        ),
544        Items::FLYINGGEM => power_up_gem(
545            side_ref,
546            active_pkmn,
547            choice,
548            PokemonType::FLYING,
549            instructions,
550        ),
551        Items::STEELGEM => power_up_gem(
552            side_ref,
553            active_pkmn,
554            choice,
555            PokemonType::STEEL,
556            instructions,
557        ),
558        Items::ICEGEM => power_up_gem(
559            side_ref,
560            active_pkmn,
561            choice,
562            PokemonType::ICE,
563            instructions,
564        ),
565        Items::POISONGEM => power_up_gem(
566            side_ref,
567            active_pkmn,
568            choice,
569            PokemonType::POISON,
570            instructions,
571        ),
572        Items::FIREGEM => power_up_gem(
573            side_ref,
574            active_pkmn,
575            choice,
576            PokemonType::FIRE,
577            instructions,
578        ),
579        Items::DRAGONGEM => power_up_gem(
580            side_ref,
581            active_pkmn,
582            choice,
583            PokemonType::DRAGON,
584            instructions,
585        ),
586        Items::GROUNDGEM => power_up_gem(
587            side_ref,
588            active_pkmn,
589            choice,
590            PokemonType::GROUND,
591            instructions,
592        ),
593        Items::WATERGEM => power_up_gem(
594            side_ref,
595            active_pkmn,
596            choice,
597            PokemonType::WATER,
598            instructions,
599        ),
600        Items::DARKGEM => power_up_gem(
601            side_ref,
602            active_pkmn,
603            choice,
604            PokemonType::DARK,
605            instructions,
606        ),
607        Items::ROCKGEM => power_up_gem(
608            side_ref,
609            active_pkmn,
610            choice,
611            PokemonType::ROCK,
612            instructions,
613        ),
614        Items::GRASSGEM => power_up_gem(
615            side_ref,
616            active_pkmn,
617            choice,
618            PokemonType::GRASS,
619            instructions,
620        ),
621        Items::FAIRYGEM => power_up_gem(
622            side_ref,
623            active_pkmn,
624            choice,
625            PokemonType::FAIRY,
626            instructions,
627        ),
628        Items::LUMBERRY if active_pkmn.status != PokemonStatus::NONE => {
629            lum_berry(side_ref, attacking_side, instructions)
630        }
631        Items::SITRUSBERRY
632            if active_pkmn.ability == Abilities::GLUTTONY
633                && active_pkmn.hp <= active_pkmn.maxhp / 2 =>
634        {
635            sitrus_berry(side_ref, attacking_side, instructions)
636        }
637        Items::SITRUSBERRY if active_pkmn.hp <= active_pkmn.maxhp / 4 => {
638            sitrus_berry(side_ref, attacking_side, instructions)
639        }
640        Items::PETAYABERRY if active_pkmn.hp <= active_pkmn.maxhp / 4 => boost_berry(
641            side_ref,
642            attacking_side,
643            PokemonBoostableStat::SpecialAttack,
644            instructions,
645        ),
646        Items::LIECHIBERRY if active_pkmn.hp <= active_pkmn.maxhp / 4 => boost_berry(
647            side_ref,
648            attacking_side,
649            PokemonBoostableStat::Attack,
650            instructions,
651        ),
652        Items::SALACBERRY if active_pkmn.hp <= active_pkmn.maxhp / 4 => boost_berry(
653            side_ref,
654            attacking_side,
655            PokemonBoostableStat::Speed,
656            instructions,
657        ),
658        Items::CUSTAPBERRY => {
659            if active_pkmn.hp <= active_pkmn.maxhp / 4 {
660                active_pkmn.item = Items::NONE;
661                instructions.instruction_list.push(Instruction::ChangeItem(
662                    ChangeItemInstruction {
663                        side_ref: *side_ref,
664                        current_item: Items::CUSTAPBERRY,
665                        new_item: Items::NONE,
666                    },
667                ));
668            }
669        }
670        Items::CHOICESPECS | Items::CHOICEBAND | Items::CHOICESCARF => {
671            let ins = get_choice_move_disable_instructions(active_pkmn, side_ref, &choice.move_id);
672            for i in ins {
673                state.apply_one_instruction(&i);
674                instructions.instruction_list.push(i);
675            }
676        }
677        Items::PROTECTIVEPADS => {
678            choice.flags.contact = false;
679        }
680        _ => {}
681    }
682}
683
684pub fn item_on_switch_in(
685    state: &mut State,
686    side_ref: &SideReference,
687    instructions: &mut StateInstructions,
688) {
689    let switching_in_side = state.get_side_immutable(side_ref);
690    let switching_in_pkmn = switching_in_side.get_active_immutable();
691    match switching_in_pkmn.item {
692        Items::ELECTRICSEED => {
693            if state.terrain_is_active(&Terrain::ELECTRICTERRAIN) {
694                if let Some(boost_instruction) = get_boost_instruction(
695                    &switching_in_side,
696                    &PokemonBoostableStat::Defense,
697                    &1,
698                    side_ref,
699                    side_ref,
700                ) {
701                    state.apply_one_instruction(&boost_instruction);
702                    instructions.instruction_list.push(boost_instruction);
703                    state.get_side(side_ref).get_active().item = Items::NONE;
704                    instructions.instruction_list.push(Instruction::ChangeItem(
705                        ChangeItemInstruction {
706                            side_ref: side_ref.clone(),
707                            current_item: Items::ELECTRICSEED,
708                            new_item: Items::NONE,
709                        },
710                    ));
711                }
712            }
713        }
714        Items::GRASSYSEED => {
715            if state.terrain_is_active(&Terrain::GRASSYTERRAIN) {
716                if let Some(boost_instruction) = get_boost_instruction(
717                    &switching_in_side,
718                    &PokemonBoostableStat::Defense,
719                    &1,
720                    side_ref,
721                    side_ref,
722                ) {
723                    state.apply_one_instruction(&boost_instruction);
724                    instructions.instruction_list.push(boost_instruction);
725                    state.get_side(side_ref).get_active().item = Items::NONE;
726                    instructions.instruction_list.push(Instruction::ChangeItem(
727                        ChangeItemInstruction {
728                            side_ref: side_ref.clone(),
729                            current_item: Items::GRASSYSEED,
730                            new_item: Items::NONE,
731                        },
732                    ));
733                }
734            }
735        }
736        Items::MISTYSEED => {
737            if state.terrain_is_active(&Terrain::MISTYTERRAIN) {
738                if let Some(boost_instruction) = get_boost_instruction(
739                    &switching_in_side,
740                    &PokemonBoostableStat::SpecialDefense,
741                    &1,
742                    side_ref,
743                    side_ref,
744                ) {
745                    state.apply_one_instruction(&boost_instruction);
746                    instructions.instruction_list.push(boost_instruction);
747                    state.get_side(side_ref).get_active().item = Items::NONE;
748                    instructions.instruction_list.push(Instruction::ChangeItem(
749                        ChangeItemInstruction {
750                            side_ref: side_ref.clone(),
751                            current_item: Items::MISTYSEED,
752                            new_item: Items::NONE,
753                        },
754                    ));
755                }
756            }
757        }
758        Items::PSYCHICSEED => {
759            if state.terrain_is_active(&Terrain::PSYCHICTERRAIN) {
760                if let Some(boost_instruction) = get_boost_instruction(
761                    &switching_in_side,
762                    &PokemonBoostableStat::SpecialDefense,
763                    &1,
764                    side_ref,
765                    side_ref,
766                ) {
767                    state.apply_one_instruction(&boost_instruction);
768                    instructions.instruction_list.push(boost_instruction);
769                    state.get_side(side_ref).get_active().item = Items::NONE;
770                    instructions.instruction_list.push(Instruction::ChangeItem(
771                        ChangeItemInstruction {
772                            side_ref: side_ref.clone(),
773                            current_item: Items::PSYCHICSEED,
774                            new_item: Items::NONE,
775                        },
776                    ));
777                }
778            }
779        }
780        _ => {}
781    }
782}
783
784pub fn item_end_of_turn(
785    state: &mut State,
786    side_ref: &SideReference,
787    instructions: &mut StateInstructions,
788) {
789    let attacking_side = state.get_side(side_ref);
790    let active_pkmn = attacking_side.get_active();
791    match active_pkmn.item {
792        Items::LUMBERRY if active_pkmn.status != PokemonStatus::NONE => {
793            lum_berry(side_ref, attacking_side, instructions)
794        }
795        Items::SITRUSBERRY if active_pkmn.hp <= active_pkmn.maxhp / 2 => {
796            sitrus_berry(side_ref, attacking_side, instructions)
797        }
798        Items::BLACKSLUDGE => {
799            if active_pkmn.has_type(&PokemonType::POISON) {
800                if active_pkmn.hp < active_pkmn.maxhp {
801                    let heal_amount =
802                        cmp::min(active_pkmn.maxhp / 16, active_pkmn.maxhp - active_pkmn.hp);
803                    let ins = Instruction::Heal(HealInstruction {
804                        side_ref: side_ref.clone(),
805                        heal_amount: heal_amount,
806                    });
807                    active_pkmn.hp += heal_amount;
808                    instructions.instruction_list.push(ins);
809                }
810            } else {
811                let damage_amount =
812                    cmp::min(active_pkmn.maxhp / 16, active_pkmn.maxhp - active_pkmn.hp);
813                let ins = Instruction::Damage(DamageInstruction {
814                    side_ref: side_ref.clone(),
815                    damage_amount: damage_amount,
816                });
817                active_pkmn.hp -= damage_amount;
818                instructions.instruction_list.push(ins);
819            }
820        }
821        Items::FLAMEORB => {
822            if !immune_to_status(state, &MoveTarget::User, side_ref, &PokemonStatus::BURN) {
823                let side = state.get_side(side_ref);
824                let ins = Instruction::ChangeStatus(ChangeStatusInstruction {
825                    side_ref: side_ref.clone(),
826                    pokemon_index: side.active_index,
827                    new_status: PokemonStatus::BURN,
828                    old_status: PokemonStatus::NONE,
829                });
830                side.get_active().status = PokemonStatus::BURN;
831                instructions.instruction_list.push(ins);
832            }
833        }
834        Items::LEFTOVERS => {
835            let attacker = state.get_side(side_ref).get_active();
836            if attacker.hp < attacker.maxhp {
837                let heal_amount = cmp::min(attacker.maxhp / 16, attacker.maxhp - attacker.hp);
838                let ins = Instruction::Heal(HealInstruction {
839                    side_ref: side_ref.clone(),
840                    heal_amount: heal_amount,
841                });
842                attacker.hp += heal_amount;
843                instructions.instruction_list.push(ins);
844            }
845        }
846        Items::TOXICORB => {
847            if !immune_to_status(state, &MoveTarget::User, side_ref, &PokemonStatus::TOXIC) {
848                let side = state.get_side(side_ref);
849                let ins = Instruction::ChangeStatus(ChangeStatusInstruction {
850                    side_ref: side_ref.clone(),
851                    pokemon_index: side.active_index,
852                    new_status: PokemonStatus::TOXIC,
853                    old_status: PokemonStatus::NONE,
854                });
855                side.get_active().status = PokemonStatus::TOXIC;
856                instructions.instruction_list.push(ins);
857            }
858        }
859        _ => {}
860    }
861}
862
863pub fn item_modify_attack_against(
864    state: &State,
865    attacking_choice: &mut Choice,
866    attacking_side_ref: &SideReference,
867) {
868    let (attacking_side, defending_side) = state.get_both_sides_immutable(attacking_side_ref);
869    match defending_side.get_active_immutable().item {
870        Items::ABSORBBULB => {
871            if attacking_choice.move_type == PokemonType::WATER {
872                attacking_choice.add_or_create_secondaries(Secondary {
873                    chance: 100.0,
874                    effect: Effect::Boost(StatBoosts {
875                        attack: 0,
876                        defense: 0,
877                        special_attack: 1,
878                        special_defense: 0,
879                        speed: 0,
880                        accuracy: 0,
881                    }),
882                    target: MoveTarget::Opponent,
883                });
884                attacking_choice.add_or_create_secondaries(Secondary {
885                    chance: 100.0,
886                    effect: Effect::RemoveItem,
887                    target: MoveTarget::Opponent,
888                });
889            }
890        }
891        Items::AIRBALLOON => {
892            if attacking_choice.move_type == PokemonType::GROUND
893                && attacking_choice.move_id != Choices::THOUSANDARROWS
894            {
895                attacking_choice.base_power = 0.0;
896            } else {
897                attacking_choice.add_or_create_secondaries(Secondary {
898                    chance: 100.0,
899                    effect: Effect::RemoveItem,
900                    target: MoveTarget::Opponent,
901                });
902            }
903        }
904        Items::ASSAULTVEST => {
905            if attacking_choice.targets_special_defense() {
906                attacking_choice.base_power /= 1.5;
907            }
908        }
909        Items::METALPOWDER if attacking_side.get_active_immutable().id == PokemonName::DITTO => {
910            attacking_choice.base_power /= 1.5;
911        }
912        Items::CELLBATTERY => {
913            if attacking_choice.move_type == PokemonType::ELECTRIC {
914                attacking_choice.add_or_create_secondaries(Secondary {
915                    chance: 100.0,
916                    effect: Effect::Boost(StatBoosts {
917                        attack: 1,
918                        defense: 0,
919                        special_attack: 0,
920                        special_defense: 0,
921                        speed: 0,
922                        accuracy: 0,
923                    }),
924                    target: MoveTarget::Opponent,
925                });
926                attacking_choice.add_or_create_secondaries(Secondary {
927                    chance: 100.0,
928                    effect: Effect::RemoveItem,
929                    target: MoveTarget::Opponent,
930                });
931            }
932        }
933        Items::EVIOLITE => {
934            attacking_choice.base_power /= 1.5;
935        }
936        Items::ROCKYHELMET => {
937            if attacking_choice.flags.contact {
938                attacking_choice.add_or_create_secondaries(Secondary {
939                    chance: 100.0,
940                    effect: Effect::Heal(-0.166),
941                    target: MoveTarget::User,
942                })
943            }
944        }
945        Items::WEAKNESSPOLICY => {
946            if attacking_choice.category != MoveCategory::Status
947                && type_effectiveness_modifier(
948                    &attacking_choice.move_type,
949                    &defending_side.get_active_immutable(),
950                ) > 1.0
951            {
952                attacking_choice.add_or_create_secondaries(Secondary {
953                    chance: 100.0,
954                    effect: Effect::Boost(StatBoosts {
955                        attack: 2,
956                        defense: 0,
957                        special_attack: 2,
958                        special_defense: 0,
959                        speed: 0,
960                        accuracy: 0,
961                    }),
962                    target: MoveTarget::Opponent,
963                });
964                attacking_choice.add_or_create_secondaries(Secondary {
965                    chance: 100.0,
966                    effect: Effect::RemoveItem,
967                    target: MoveTarget::Opponent,
968                });
969            }
970        }
971        Items::SOULDEW => {
972            if defending_side.get_active_immutable().id == PokemonName::LATIOS
973                || defending_side.get_active_immutable().id == PokemonName::LATIAS
974            {
975                #[cfg(any(feature = "gen3", feature = "gen4", feature = "gen5", feature = "gen6"))]
976                if attacking_choice.category == MoveCategory::Special {
977                    attacking_choice.base_power /= 1.5;
978                }
979            }
980        }
981        _ => {}
982    }
983}
984
985pub fn item_modify_attack_being_used(
986    state: &State,
987    attacking_choice: &mut Choice,
988    attacking_side_ref: &SideReference,
989) {
990    let (attacking_side, defending_side) = state.get_both_sides_immutable(attacking_side_ref);
991    match attacking_side.get_active_immutable().item {
992        Items::WELLSPRINGMASK => match attacking_side.get_active_immutable().id {
993            PokemonName::OGERPONWELLSPRING | PokemonName::OGERPONWELLSPRINGTERA => {
994                attacking_choice.base_power *= 1.2;
995            }
996            _ => {}
997        },
998        Items::HEARTHFLAMEMASK => match attacking_side.get_active_immutable().id {
999            PokemonName::OGERPONHEARTHFLAME | PokemonName::OGERPONHEARTHFLAMETERA => {
1000                attacking_choice.base_power *= 1.2;
1001            }
1002            _ => {}
1003        },
1004        Items::CORNERSTONEMASK => match attacking_side.get_active_immutable().id {
1005            PokemonName::OGERPONCORNERSTONE | PokemonName::OGERPONCORNERSTONETERA => {
1006                attacking_choice.base_power *= 1.2;
1007            }
1008            _ => {}
1009        },
1010        #[cfg(feature = "gen3")]
1011        Items::BLACKBELT => {
1012            if attacking_choice.move_type == PokemonType::FIGHTING {
1013                attacking_choice.base_power *= 1.1;
1014            }
1015        }
1016        #[cfg(any(
1017            feature = "gen4",
1018            feature = "gen5",
1019            feature = "gen6",
1020            feature = "gen7",
1021            feature = "gen8",
1022            feature = "gen9"
1023        ))]
1024        Items::BLACKBELT => {
1025            if attacking_choice.move_type == PokemonType::FIGHTING {
1026                attacking_choice.base_power *= 1.2;
1027            }
1028        }
1029        #[cfg(feature = "gen3")]
1030        Items::BLACKGLASSES => {
1031            if attacking_choice.move_type == PokemonType::DARK {
1032                attacking_choice.base_power *= 1.1;
1033            }
1034        }
1035        #[cfg(any(
1036            feature = "gen4",
1037            feature = "gen5",
1038            feature = "gen6",
1039            feature = "gen7",
1040            feature = "gen8",
1041            feature = "gen9"
1042        ))]
1043        Items::BLACKGLASSES => {
1044            if attacking_choice.move_type == PokemonType::DARK {
1045                attacking_choice.base_power *= 1.2;
1046            }
1047        }
1048        #[cfg(feature = "gen3")]
1049        Items::CHARCOAL => {
1050            if attacking_choice.move_type == PokemonType::FIRE {
1051                attacking_choice.base_power *= 1.1;
1052            }
1053        }
1054        #[cfg(any(
1055            feature = "gen4",
1056            feature = "gen5",
1057            feature = "gen6",
1058            feature = "gen7",
1059            feature = "gen8",
1060            feature = "gen9"
1061        ))]
1062        Items::CHARCOAL => {
1063            if attacking_choice.move_type == PokemonType::FIRE {
1064                attacking_choice.base_power *= 1.2;
1065            }
1066        }
1067        Items::CHOICEBAND => {
1068            if attacking_choice.category == MoveCategory::Physical {
1069                attacking_choice.base_power *= 1.5;
1070            }
1071        }
1072        Items::CHOICESPECS => {
1073            if attacking_choice.category == MoveCategory::Special {
1074                attacking_choice.base_power *= 1.5;
1075            }
1076        }
1077        #[cfg(feature = "gen3")]
1078        Items::DRAGONFANG | Items::DRAGONSCALE => {
1079            if attacking_choice.move_type == PokemonType::DRAGON {
1080                attacking_choice.base_power *= 1.1;
1081            }
1082        }
1083        #[cfg(any(
1084            feature = "gen4",
1085            feature = "gen5",
1086            feature = "gen6",
1087            feature = "gen7",
1088            feature = "gen8",
1089            feature = "gen9"
1090        ))]
1091        Items::DRAGONFANG | Items::DRAGONSCALE => {
1092            if attacking_choice.move_type == PokemonType::DRAGON {
1093                attacking_choice.base_power *= 1.2;
1094            }
1095        }
1096        Items::EXPERTBELT => {
1097            if type_effectiveness_modifier(
1098                &attacking_choice.move_type,
1099                &defending_side.get_active_immutable(),
1100            ) > 1.0
1101            {
1102                attacking_choice.base_power *= 1.2;
1103            }
1104        }
1105        Items::FAIRYFEATHER => {
1106            if attacking_choice.move_type == PokemonType::FAIRY {
1107                attacking_choice.base_power *= 1.2;
1108            }
1109        }
1110        Items::LIFEORB => {
1111            if attacking_choice.category != MoveCategory::Status {
1112                attacking_choice.base_power *= 1.3;
1113
1114                #[cfg(feature = "gen4")]
1115                if !defending_side
1116                    .volatile_statuses
1117                    .contains(&PokemonVolatileStatus::SUBSTITUTE)
1118                    && attacking_side.get_active_immutable().ability != Abilities::MAGICGUARD
1119                {
1120                    attacking_choice.add_or_create_secondaries(Secondary {
1121                        chance: 100.0,
1122                        effect: Effect::Heal(-0.1),
1123                        target: MoveTarget::User,
1124                    });
1125                }
1126
1127                #[cfg(not(feature = "gen4"))]
1128                if attacking_side.get_active_immutable().ability != Abilities::MAGICGUARD {
1129                    attacking_choice.add_or_create_secondaries(Secondary {
1130                        chance: 100.0,
1131                        effect: Effect::Heal(-0.1),
1132                        target: MoveTarget::User,
1133                    });
1134                }
1135            }
1136        }
1137        #[cfg(feature = "gen3")]
1138        Items::METALCOAT => {
1139            if attacking_choice.move_type == PokemonType::STEEL {
1140                attacking_choice.base_power *= 1.1;
1141            }
1142        }
1143        #[cfg(any(
1144            feature = "gen4",
1145            feature = "gen5",
1146            feature = "gen6",
1147            feature = "gen7",
1148            feature = "gen8",
1149            feature = "gen9"
1150        ))]
1151        Items::METALCOAT => {
1152            if attacking_choice.move_type == PokemonType::STEEL {
1153                attacking_choice.base_power *= 1.2;
1154            }
1155        }
1156        Items::MUSCLEBAND => {
1157            if attacking_choice.category == MoveCategory::Physical {
1158                attacking_choice.base_power *= 1.1;
1159            }
1160        }
1161        #[cfg(feature = "gen3")]
1162        Items::MYSTICWATER => {
1163            if attacking_choice.move_type == PokemonType::WATER {
1164                attacking_choice.base_power *= 1.1;
1165            }
1166        }
1167        #[cfg(any(
1168            feature = "gen4",
1169            feature = "gen5",
1170            feature = "gen6",
1171            feature = "gen7",
1172            feature = "gen8",
1173            feature = "gen9"
1174        ))]
1175        Items::MYSTICWATER => {
1176            if attacking_choice.move_type == PokemonType::WATER {
1177                attacking_choice.base_power *= 1.2;
1178            }
1179        }
1180        #[cfg(feature = "gen3")]
1181        Items::NEVERMELTICE => {
1182            if attacking_choice.move_type == PokemonType::ICE {
1183                attacking_choice.base_power *= 1.1;
1184            }
1185        }
1186        #[cfg(any(
1187            feature = "gen4",
1188            feature = "gen5",
1189            feature = "gen6",
1190            feature = "gen7",
1191            feature = "gen8",
1192            feature = "gen9"
1193        ))]
1194        Items::NEVERMELTICE => {
1195            if attacking_choice.move_type == PokemonType::ICE {
1196                attacking_choice.base_power *= 1.2;
1197            }
1198        }
1199        Items::PINKBOW | Items::POLKADOTBOW => {
1200            if attacking_choice.move_type == PokemonType::NORMAL {
1201                attacking_choice.base_power *= 1.1;
1202            }
1203        }
1204        Items::ODDINCENSE => {
1205            if attacking_choice.move_type == PokemonType::PSYCHIC {
1206                attacking_choice.base_power *= 1.2;
1207            }
1208        }
1209        #[cfg(feature = "gen3")]
1210        Items::POISONBARB => {
1211            if attacking_choice.move_type == PokemonType::POISON {
1212                attacking_choice.base_power *= 1.1;
1213            }
1214        }
1215        #[cfg(any(
1216            feature = "gen4",
1217            feature = "gen5",
1218            feature = "gen6",
1219            feature = "gen7",
1220            feature = "gen8",
1221            feature = "gen9"
1222        ))]
1223        Items::POISONBARB => {
1224            if attacking_choice.move_type == PokemonType::POISON {
1225                attacking_choice.base_power *= 1.2;
1226            }
1227        }
1228        Items::PUNCHINGGLOVE => {
1229            if attacking_choice.flags.punch {
1230                attacking_choice.base_power *= 1.1;
1231                attacking_choice.flags.contact = false
1232            }
1233        }
1234        Items::SEAINCENSE => {
1235            if attacking_choice.move_type == PokemonType::WATER {
1236                attacking_choice.base_power *= 1.2;
1237            }
1238        }
1239        #[cfg(feature = "gen3")]
1240        Items::SHARPBEAK => {
1241            if attacking_choice.move_type == PokemonType::FLYING {
1242                attacking_choice.base_power *= 1.1;
1243            }
1244        }
1245        #[cfg(any(
1246            feature = "gen4",
1247            feature = "gen5",
1248            feature = "gen6",
1249            feature = "gen7",
1250            feature = "gen8",
1251            feature = "gen9"
1252        ))]
1253        Items::SHARPBEAK => {
1254            if attacking_choice.move_type == PokemonType::FLYING {
1255                attacking_choice.base_power *= 1.2;
1256            }
1257        }
1258        Items::SHELLBELL => {
1259            attacking_choice.drain = Some(0.125);
1260        }
1261        Items::SILKSCARF => {
1262            if attacking_choice.move_type == PokemonType::NORMAL {
1263                attacking_choice.base_power *= 1.2;
1264            }
1265        }
1266        #[cfg(feature = "gen3")]
1267        Items::SILVERPOWDER => {
1268            if attacking_choice.move_type == PokemonType::BUG {
1269                attacking_choice.base_power *= 1.1;
1270            }
1271        }
1272        #[cfg(any(
1273            feature = "gen4",
1274            feature = "gen5",
1275            feature = "gen6",
1276            feature = "gen7",
1277            feature = "gen8",
1278            feature = "gen9"
1279        ))]
1280        Items::SILVERPOWDER => {
1281            if attacking_choice.move_type == PokemonType::BUG {
1282                attacking_choice.base_power *= 1.2;
1283            }
1284        }
1285        #[cfg(feature = "gen3")]
1286        Items::SOFTSAND => {
1287            if attacking_choice.move_type == PokemonType::GROUND {
1288                attacking_choice.base_power *= 1.1;
1289            }
1290        }
1291        #[cfg(any(
1292            feature = "gen4",
1293            feature = "gen5",
1294            feature = "gen6",
1295            feature = "gen7",
1296            feature = "gen8",
1297            feature = "gen9"
1298        ))]
1299        Items::SOFTSAND => {
1300            if attacking_choice.move_type == PokemonType::GROUND {
1301                attacking_choice.base_power *= 1.2;
1302            }
1303        }
1304        #[cfg(feature = "gen3")]
1305        Items::SPELLTAG => {
1306            if attacking_choice.move_type == PokemonType::GHOST {
1307                attacking_choice.base_power *= 1.1;
1308            }
1309        }
1310        #[cfg(any(
1311            feature = "gen4",
1312            feature = "gen5",
1313            feature = "gen6",
1314            feature = "gen7",
1315            feature = "gen8",
1316            feature = "gen9"
1317        ))]
1318        Items::SPELLTAG => {
1319            if attacking_choice.move_type == PokemonType::GHOST {
1320                attacking_choice.base_power *= 1.2;
1321            }
1322        }
1323        #[cfg(feature = "gen3")]
1324        Items::MIRACLESEED => {
1325            if attacking_choice.move_type == PokemonType::GRASS {
1326                attacking_choice.base_power *= 1.1;
1327            }
1328        }
1329        #[cfg(any(
1330            feature = "gen4",
1331            feature = "gen5",
1332            feature = "gen6",
1333            feature = "gen7",
1334            feature = "gen8",
1335            feature = "gen9"
1336        ))]
1337        Items::MIRACLESEED => {
1338            if attacking_choice.move_type == PokemonType::GRASS {
1339                attacking_choice.base_power *= 1.2;
1340            }
1341        }
1342        Items::SOULDEW => {
1343            if attacking_side.get_active_immutable().id == PokemonName::LATIOS
1344                || attacking_side.get_active_immutable().id == PokemonName::LATIAS
1345            {
1346                #[cfg(any(feature = "gen3", feature = "gen4", feature = "gen5", feature = "gen6"))]
1347                if attacking_choice.category == MoveCategory::Special {
1348                    attacking_choice.base_power *= 1.5;
1349                }
1350
1351                #[cfg(not(any(
1352                    feature = "gen3",
1353                    feature = "gen4",
1354                    feature = "gen5",
1355                    feature = "gen6"
1356                )))]
1357                if attacking_choice.move_type == PokemonType::DRAGON
1358                    || attacking_choice.move_type == PokemonType::PSYCHIC
1359                {
1360                    attacking_choice.base_power *= 1.2;
1361                }
1362            }
1363        }
1364        Items::GRISEOUSORB | Items::GRISEOUSCORE => {
1365            if [PokemonName::GIRATINAORIGIN, PokemonName::GIRATINA]
1366                .contains(&attacking_side.get_active_immutable().id)
1367            {
1368                if attacking_choice.move_type == PokemonType::DRAGON
1369                    || attacking_choice.move_type == PokemonType::GHOST
1370                {
1371                    attacking_choice.base_power *= 1.2;
1372                }
1373            }
1374        }
1375        Items::LUSTROUSORB | Items::LUSTROUSGLOBE => {
1376            if [PokemonName::PALKIAORIGIN, PokemonName::PALKIA]
1377                .contains(&attacking_side.get_active_immutable().id)
1378            {
1379                if attacking_choice.move_type == PokemonType::DRAGON
1380                    || attacking_choice.move_type == PokemonType::WATER
1381                {
1382                    attacking_choice.base_power *= 1.2;
1383                }
1384            }
1385        }
1386        Items::ADAMANTORB | Items::ADAMANTCRYSTAL => {
1387            if [PokemonName::DIALGAORIGIN, PokemonName::DIALGA]
1388                .contains(&attacking_side.get_active_immutable().id)
1389            {
1390                if attacking_choice.move_type == PokemonType::DRAGON
1391                    || attacking_choice.move_type == PokemonType::STEEL
1392                {
1393                    attacking_choice.base_power *= 1.2;
1394                }
1395            }
1396        }
1397        Items::THROATSPRAY => {
1398            if attacking_choice.flags.sound {
1399                attacking_choice.add_or_create_secondaries(Secondary {
1400                    chance: 100.0,
1401                    effect: Effect::Boost(StatBoosts {
1402                        attack: 0,
1403                        defense: 0,
1404                        special_attack: 1,
1405                        special_defense: 0,
1406                        speed: 0,
1407                        accuracy: 0,
1408                    }),
1409                    target: MoveTarget::User,
1410                });
1411                attacking_choice.add_or_create_secondaries(Secondary {
1412                    chance: 100.0,
1413                    effect: Effect::RemoveItem,
1414                    target: MoveTarget::User,
1415                });
1416            }
1417        }
1418        Items::THICKCLUB => match attacking_side.get_active_immutable().id {
1419            PokemonName::CUBONE
1420            | PokemonName::MAROWAK
1421            | PokemonName::MAROWAKALOLA
1422            | PokemonName::MAROWAKALOLATOTEM => {
1423                attacking_choice.base_power *= 2.0;
1424            }
1425            _ => {}
1426        },
1427        #[cfg(feature = "gen3")]
1428        Items::TWISTEDSPOON => {
1429            if attacking_choice.move_type == PokemonType::PSYCHIC {
1430                attacking_choice.base_power *= 1.1;
1431            }
1432        }
1433        #[cfg(any(
1434            feature = "gen4",
1435            feature = "gen5",
1436            feature = "gen6",
1437            feature = "gen7",
1438            feature = "gen8",
1439            feature = "gen9"
1440        ))]
1441        Items::TWISTEDSPOON => {
1442            if attacking_choice.move_type == PokemonType::PSYCHIC {
1443                attacking_choice.base_power *= 1.2;
1444            }
1445        }
1446        #[cfg(feature = "gen3")]
1447        Items::HARDSTONE => {
1448            if attacking_choice.move_type == PokemonType::ROCK {
1449                attacking_choice.base_power *= 1.1;
1450            }
1451        }
1452        #[cfg(any(
1453            feature = "gen4",
1454            feature = "gen5",
1455            feature = "gen6",
1456            feature = "gen7",
1457            feature = "gen8",
1458            feature = "gen9"
1459        ))]
1460        Items::HARDSTONE => {
1461            if attacking_choice.move_type == PokemonType::ROCK {
1462                attacking_choice.base_power *= 1.2;
1463            }
1464        }
1465        Items::WAVEINCENSE => {
1466            if attacking_choice.move_type == PokemonType::WATER {
1467                attacking_choice.base_power *= 1.2;
1468            }
1469        }
1470        #[cfg(feature = "gen3")]
1471        Items::MAGNET => {
1472            if attacking_choice.move_type == PokemonType::ELECTRIC {
1473                attacking_choice.base_power *= 1.1;
1474            }
1475        }
1476        #[cfg(any(
1477            feature = "gen4",
1478            feature = "gen5",
1479            feature = "gen6",
1480            feature = "gen7",
1481            feature = "gen8",
1482            feature = "gen9"
1483        ))]
1484        Items::MAGNET => {
1485            if attacking_choice.move_type == PokemonType::ELECTRIC {
1486                attacking_choice.base_power *= 1.2;
1487            }
1488        }
1489        Items::WISEGLASSES => {
1490            if attacking_choice.category == MoveCategory::Special {
1491                attacking_choice.base_power *= 1.1;
1492            }
1493        }
1494        Items::FISTPLATE => {
1495            if attacking_choice.move_id == Choices::JUDGMENT {
1496                attacking_choice.move_type = PokemonType::FIGHTING;
1497            }
1498            if attacking_choice.move_type == PokemonType::FIGHTING {
1499                attacking_choice.base_power *= 1.2;
1500            }
1501        }
1502        Items::SKYPLATE => {
1503            if attacking_choice.move_id == Choices::JUDGMENT {
1504                attacking_choice.move_type = PokemonType::FLYING;
1505            }
1506            if attacking_choice.move_type == PokemonType::FLYING {
1507                attacking_choice.base_power *= 1.2;
1508            }
1509        }
1510        Items::TOXICPLATE => {
1511            if attacking_choice.move_id == Choices::JUDGMENT {
1512                attacking_choice.move_type = PokemonType::POISON;
1513            }
1514            if attacking_choice.move_type == PokemonType::POISON {
1515                attacking_choice.base_power *= 1.2;
1516            }
1517        }
1518        Items::EARTHPLATE => {
1519            if attacking_choice.move_id == Choices::JUDGMENT {
1520                attacking_choice.move_type = PokemonType::GROUND;
1521            }
1522            if attacking_choice.move_type == PokemonType::GROUND {
1523                attacking_choice.base_power *= 1.2;
1524            }
1525        }
1526        Items::STONEPLATE => {
1527            if attacking_choice.move_id == Choices::JUDGMENT {
1528                attacking_choice.move_type = PokemonType::ROCK;
1529            }
1530            if attacking_choice.move_type == PokemonType::ROCK {
1531                attacking_choice.base_power *= 1.2;
1532            }
1533        }
1534        Items::INSECTPLATE => {
1535            if attacking_choice.move_id == Choices::JUDGMENT {
1536                attacking_choice.move_type = PokemonType::BUG;
1537            }
1538            if attacking_choice.move_type == PokemonType::BUG {
1539                attacking_choice.base_power *= 1.2;
1540            }
1541        }
1542        Items::SPOOKYPLATE => {
1543            if attacking_choice.move_id == Choices::JUDGMENT {
1544                attacking_choice.move_type = PokemonType::GHOST;
1545            }
1546            if attacking_choice.move_type == PokemonType::GHOST {
1547                attacking_choice.base_power *= 1.2;
1548            }
1549        }
1550        Items::IRONPLATE => {
1551            if attacking_choice.move_id == Choices::JUDGMENT {
1552                attacking_choice.move_type = PokemonType::STEEL;
1553            }
1554            if attacking_choice.move_type == PokemonType::STEEL {
1555                attacking_choice.base_power *= 1.2;
1556            }
1557        }
1558        Items::FLAMEPLATE => {
1559            if attacking_choice.move_id == Choices::JUDGMENT {
1560                attacking_choice.move_type = PokemonType::FIRE;
1561            }
1562            if attacking_choice.move_type == PokemonType::FIRE {
1563                attacking_choice.base_power *= 1.2;
1564            }
1565        }
1566        Items::SPLASHPLATE => {
1567            if attacking_choice.move_id == Choices::JUDGMENT {
1568                attacking_choice.move_type = PokemonType::WATER;
1569            }
1570            if attacking_choice.move_type == PokemonType::WATER {
1571                attacking_choice.base_power *= 1.2;
1572            }
1573        }
1574        Items::MEADOWPLATE => {
1575            if attacking_choice.move_id == Choices::JUDGMENT {
1576                attacking_choice.move_type = PokemonType::GRASS;
1577            }
1578            if attacking_choice.move_type == PokemonType::GRASS {
1579                attacking_choice.base_power *= 1.2;
1580            }
1581        }
1582        Items::ZAPPLATE => {
1583            if attacking_choice.move_id == Choices::JUDGMENT {
1584                attacking_choice.move_type = PokemonType::ELECTRIC;
1585            }
1586            if attacking_choice.move_type == PokemonType::ELECTRIC {
1587                attacking_choice.base_power *= 1.2;
1588            }
1589        }
1590        Items::MINDPLATE => {
1591            if attacking_choice.move_id == Choices::JUDGMENT {
1592                attacking_choice.move_type = PokemonType::PSYCHIC;
1593            }
1594            if attacking_choice.move_type == PokemonType::PSYCHIC {
1595                attacking_choice.base_power *= 1.2;
1596            }
1597        }
1598        Items::ICICLEPLATE => {
1599            if attacking_choice.move_id == Choices::JUDGMENT {
1600                attacking_choice.move_type = PokemonType::ICE;
1601            }
1602            if attacking_choice.move_type == PokemonType::ICE {
1603                attacking_choice.base_power *= 1.2;
1604            }
1605        }
1606        Items::DRACOPLATE => {
1607            if attacking_choice.move_id == Choices::JUDGMENT {
1608                attacking_choice.move_type = PokemonType::DRAGON;
1609            }
1610            if attacking_choice.move_type == PokemonType::DRAGON {
1611                attacking_choice.base_power *= 1.2;
1612            }
1613        }
1614        Items::DREADPLATE => {
1615            if attacking_choice.move_id == Choices::JUDGMENT {
1616                attacking_choice.move_type = PokemonType::DARK;
1617            }
1618            if attacking_choice.move_type == PokemonType::DARK {
1619                attacking_choice.base_power *= 1.2;
1620            }
1621        }
1622        Items::PIXIEPLATE => {
1623            if attacking_choice.move_id == Choices::JUDGMENT {
1624                attacking_choice.move_type = PokemonType::FAIRY;
1625            }
1626            if attacking_choice.move_type == PokemonType::FAIRY {
1627                attacking_choice.base_power *= 1.2;
1628            }
1629        }
1630        Items::LIGHTBALL => {
1631            if attacking_side
1632                .get_active_immutable()
1633                .id
1634                .is_pikachu_variant()
1635            {
1636                attacking_choice.base_power *= 2.0;
1637            }
1638        }
1639        _ => {}
1640    }
1641}