Skip to content

Commit

Permalink
Remove all powers on a Splitting monster on their turn
Browse files Browse the repository at this point in the history
  • Loading branch information
Typhi committed Oct 15, 2024
1 parent 532f530 commit 414ea63
Show file tree
Hide file tree
Showing 5 changed files with 1,209 additions and 5 deletions.
5 changes: 5 additions & 0 deletions rs/calculator/battle_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ def end_turn(self):
if not monster.powers.get(PowerId.BARRICADE, 0):
monster.block = 0

if monster.powers.get(PowerId.SPLIT, 0) and monster.current_hp <= monster.max_hp / 2:
monster.damage = 0
monster.hits = 0
monster.powers = {}

poison = monster.powers.get(PowerId.POISON, 0)
if poison > 0:
monster.powers[PowerId.POISON] -= 1
Expand Down
4 changes: 0 additions & 4 deletions rs/calculator/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ def inflict_damage(self, source, base_damage: int, hits: int, blockable: bool =
self.block += block_to_add
block_to_add -= 1

if self.powers.get(PowerId.SPLIT) and self.current_hp <= self.max_hp / 2:
self.damage = 0
self.hits = 0
del self.powers[PowerId.SPLIT]
if self.powers.get(PowerId.SHIFTING):
self.add_powers({PowerId.STRENGTH: -health_damage_dealt}, source.relics, source.powers)
return times_block_triggered
Expand Down
3 changes: 3 additions & 0 deletions tests/ai/common/handlers/test_battle_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,6 @@ def test_play_less_to_avoid_awkward_time_warp(self):
self.execute_handler_tests(
'battles/specific_comparator_cases/big_fight/time_eater_play_less_to_avoid_inconvenient_time_warp.json',
['end'])

def test_prefer_straight_damage_over_vulnerable_when_splitting(self):
self.execute_handler_tests('battles/general/split_terror_vs_strike.json', ['play 2 0'])
14 changes: 13 additions & 1 deletion tests/calculator/test_calculator_powers.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,22 @@ def test_split_removes_enemy_attack(self):
state.monsters[0].hits = 2
state.monsters[0].current_hp = 46
state.monsters[0].max_hp = 80
state.monsters[0].powers = {PowerId.SPLIT: 1}
state.monsters[0].powers[PowerId.SPLIT] = 1
play = self.when_playing_the_first_card(state)
play.end_turn()
self.see_enemy_does_not_have_power(play, PowerId.SPLIT)
self.see_player_lost_hp(play, 0)

def test_split_removes_enemy_powers(self):
state = self.given_state(CardId.STRIKE_R)
state.monsters[0].current_hp = 46
state.monsters[0].max_hp = 80
state.monsters[0].powers[PowerId.SPLIT] = 1
state.monsters[0].powers[PowerId.VULNERABLE] = 3
play = self.when_playing_the_first_card(state)
play.end_turn()
self.see_enemy_does_not_have_power(play, PowerId.SPLIT)
self.see_enemy_does_not_have_power(play, PowerId.VULNERABLE)
self.see_player_lost_hp(play, 0)

def test_not_quite_split_does_nothing(self):
Expand Down
Loading

0 comments on commit 414ea63

Please sign in to comment.