Skip to content

Commit

Permalink
feat: HealBlock volatile prevents healing moves
Browse files Browse the repository at this point in the history
Also add some missing heal flags to some moves
  • Loading branch information
pmariglia committed Jan 14, 2025
1 parent c3e8790 commit 9bec851
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/choices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,7 @@ lazy_static! {
contact: true,
protect: true,
slicing: true,
heal: true,
..Default::default()
},
drain: Some(0.5),
Expand Down Expand Up @@ -10011,6 +10012,7 @@ lazy_static! {
move_type: PokemonType::GRASS,
flags: Flags {
protect: true,
heal: true,
..Default::default()
},
secondaries: Some(vec![Secondary {
Expand Down Expand Up @@ -13282,6 +13284,7 @@ lazy_static! {
target: MoveTarget::User,
move_type: PokemonType::NORMAL,
flags: Flags {
heal: true,
..Default::default()
},
..Default::default()
Expand Down
6 changes: 6 additions & 0 deletions src/generate_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,12 @@ fn cannot_use_move(state: &State, choice: &Choice, attacking_side_ref: &SideRefe
.contains(&PokemonVolatileStatus::FLINCH)
{
return true;
} else if choice.flags.heal
&& attacking_side
.volatile_statuses
.contains(&PokemonVolatileStatus::HEALBLOCK)
{
return true;
}
false
}
Expand Down
82 changes: 82 additions & 0 deletions tests/test_battle_mechanics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15002,6 +15002,88 @@ fn test_rattled() {
assert_eq!(expected_instructions, vec_of_instructions);
}

#[test]
fn test_healblock_prevents_drainpunch() {
let mut state = State::default();

let vec_of_instructions = set_moves_on_pkmn_and_call_generate_instructions(
&mut state,
Choices::DRAINPUNCH,
Choices::PSYCHICNOISE,
);

let expected_instructions = vec![StateInstructions {
percentage: 100.0,
instruction_list: vec![
Instruction::Damage(DamageInstruction {
side_ref: SideReference::SideOne,
damage_amount: 60,
}),
Instruction::ApplyVolatileStatus(ApplyVolatileStatusInstruction {
side_ref: SideReference::SideOne,
volatile_status: PokemonVolatileStatus::HEALBLOCK,
}),
],
}];
assert_eq!(expected_instructions, vec_of_instructions);
}

#[test]
fn test_healblock_prevents_synthesis() {
let mut state = State::default();

let vec_of_instructions = set_moves_on_pkmn_and_call_generate_instructions(
&mut state,
Choices::SYNTHESIS,
Choices::PSYCHICNOISE,
);

let expected_instructions = vec![StateInstructions {
percentage: 100.0,
instruction_list: vec![
Instruction::Damage(DamageInstruction {
side_ref: SideReference::SideOne,
damage_amount: 60,
}),
Instruction::ApplyVolatileStatus(ApplyVolatileStatusInstruction {
side_ref: SideReference::SideOne,
volatile_status: PokemonVolatileStatus::HEALBLOCK,
}),
],
}];
assert_eq!(expected_instructions, vec_of_instructions);
}

#[test]
fn test_healblock_does_not_prevent_tackle() {
let mut state = State::default();

let vec_of_instructions = set_moves_on_pkmn_and_call_generate_instructions(
&mut state,
Choices::TACKLE,
Choices::PSYCHICNOISE,
);

let expected_instructions = vec![StateInstructions {
percentage: 100.0,
instruction_list: vec![
Instruction::Damage(DamageInstruction {
side_ref: SideReference::SideOne,
damage_amount: 60,
}),
Instruction::ApplyVolatileStatus(ApplyVolatileStatusInstruction {
side_ref: SideReference::SideOne,
volatile_status: PokemonVolatileStatus::HEALBLOCK,
}),
Instruction::Damage(DamageInstruction {
side_ref: SideReference::SideTwo,
damage_amount: 48,
}),
],
}];
assert_eq!(expected_instructions, vec_of_instructions);
}

#[test]
fn test_taunt_into_aromaveil() {
let mut state = State::default();
Expand Down

0 comments on commit 9bec851

Please sign in to comment.