diff --git a/fireplace/actions.py b/fireplace/actions.py index df61ff829..591b9a0a2 100644 --- a/fireplace/actions.py +++ b/fireplace/actions.py @@ -1277,7 +1277,6 @@ class Silence(TargetedAction): def do(self, source, target): log.info("Silencing %r", self) self.broadcast(source, EventListener.ON, target) - old_health = target.health target.clear_buffs() for attr in target.silenceable_attributes: if getattr(target, attr): @@ -1286,8 +1285,6 @@ def do(self, source, target): # Wipe the event listeners target._events = [] target.silenced = True - if target.health < old_health: - target.damage = max(target.damage - (old_health - target.health), 0) class Summon(TargetedAction): diff --git a/fireplace/card.py b/fireplace/card.py index cebac3f96..d8b923a74 100644 --- a/fireplace/card.py +++ b/fireplace/card.py @@ -1041,9 +1041,13 @@ 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 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) + super()._set_zone(zone) def apply(self, target): diff --git a/fireplace/dsl/copy.py b/fireplace/dsl/copy.py index 4ff506cb6..7a2167d7b 100644 --- a/fireplace/dsl/copy.py +++ b/fireplace/dsl/copy.py @@ -51,5 +51,8 @@ def copy(self, source, entity): ret.damage = entity.damage for buff in entity.buffs: # Recreate the buff stack - entity.buff(ret, buff.id) + new_buff = buff.source.buff(ret, buff.id) + if buff in source.game.active_aura_buffs: + new_buff.tick = buff.tick + source.game.active_aura_buffs.append(new_buff) return ret diff --git a/tests/test_classic.py b/tests/test_classic.py index 91111f2de..09386ddfd 100644 --- a/tests/test_classic.py +++ b/tests/test_classic.py @@ -3747,3 +3747,48 @@ def test_ysera_awakens(): assert game.player1.hero.health == game.player2.hero.health == 30 - 5 assert len(game.board) == 1 assert ysera.health == 12 + + +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 + + +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