Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Dec 13, 2023
1 parent 04bbbd6 commit f924745
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
8 changes: 5 additions & 3 deletions fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,14 @@ def _set_zone(self, zone):
# Can happen if a Destroy is queued after a bounce, for example
self.logger.warning("Trying to remove %r which is already gone", self)
return
old_health = self.owner.health
if hasattr(self.owner, "health"):
old_health = self.owner.health
self.owner.buffs.remove(self)
if self in self.game.active_aura_buffs:
self.game.active_aura_buffs.remove(self)
if self.owner.health < old_health:
self.owner.damage = max(self.owner.damage - (old_health - self.owner.health), 0)
if hasattr(self.owner, "health"):
if self.owner.health < old_health:
self.owner.damage = max(self.owner.damage - (old_health - self.owner.health), 0)

super()._set_zone(zone)

Expand Down
74 changes: 37 additions & 37 deletions tests/test_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3751,44 +3751,44 @@ def test_ysera_awakens():

def test_mirror_entity_aura():
# https://github.com/jleclanche/fireplace/issues/221
game = prepare_game()
game.end_turn()
game.player2.give("CS2_222").play() # Stormwind Champion
game.end_turn()

mirror = game.player1.give("EX1_294")
mirror.play()
game.end_turn()

# Mirror entity copies the exact nature of the card when it hits the field.
blademaster = game.player2.give("CS2_181")
blademaster.play()
assert len(game.player1.field) == 1
assert len(game.player2.field) == 2
assert game.player1.field[0].health == 4
assert game.player1.field[0].max_health == 7
assert game.player2.field[1].health == 4
assert game.player2.field[1].max_health == 8
game = prepare_game()
game.end_turn()
game.player2.give("CS2_222").play() # Stormwind Champion
game.end_turn()

mirror = game.player1.give("EX1_294")
mirror.play()
game.end_turn()

# Mirror entity copies the exact nature of the card when it hits the field.
blademaster = game.player2.give("CS2_181")
blademaster.play()
assert len(game.player1.field) == 1
assert len(game.player2.field) == 2
assert game.player1.field[0].health == 4
assert game.player1.field[0].max_health == 7
assert game.player2.field[1].health == 4
assert game.player2.field[1].max_health == 8


def test_stormwind_champion_heal():
# https://github.com/jleclanche/fireplace/issues/226
game = prepare_game()

goldshire = game.player1.summon(GOLDSHIRE_FOOTMAN)
assert goldshire.atk == 1
assert goldshire.health == 2
stormwind = game.player1.give("CS2_222")
stormwind.play()
assert goldshire.atk == 2
assert goldshire.health == 3

game.player1.give(MOONFIRE).play(target=goldshire)
assert goldshire.atk == 2
assert goldshire.health == 2
game.end_turn()

# Destroy with Fireball
game.player2.give(FIREBALL).play(target=stormwind)
assert goldshire.atk == 1
assert goldshire.health == 2
game = prepare_game()

goldshire = game.player1.summon(GOLDSHIRE_FOOTMAN)
assert goldshire.atk == 1
assert goldshire.health == 2
stormwind = game.player1.give("CS2_222")
stormwind.play()
assert goldshire.atk == 2
assert goldshire.health == 3

game.player1.give(MOONFIRE).play(target=goldshire)
assert goldshire.atk == 2
assert goldshire.health == 2
game.end_turn()

# Destroy with Fireball
game.player2.give(FIREBALL).play(target=stormwind)
assert goldshire.atk == 1
assert goldshire.health == 2

0 comments on commit f924745

Please sign in to comment.