From 8cc6b7778aab00cbf409d57753eefa7e64fd2c28 Mon Sep 17 00:00:00 2001 From: shinoi2 Date: Thu, 14 Dec 2023 15:14:35 +0800 Subject: [PATCH] fix issue: https://github.com/jleclanche/fireplace/issues/126 --- fireplace/actions.py | 20 +++++++++++++++++++- fireplace/cards/classic/rogue.py | 2 +- tests/test_misc.py | 21 +++++++++++++++++++++ tests/test_tgt.py | 9 +++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/fireplace/actions.py b/fireplace/actions.py index 30894544c..aa395b028 100644 --- a/fireplace/actions.py +++ b/fireplace/actions.py @@ -301,10 +301,20 @@ class Death(GameAction): """ ENTITY = ActionArg() + def _broadcast(self, entity, source, at, *args): + # https://github.com/jleclanche/fireplace/issues/126 + target = args[0] + if (not self.triggered_dearattle) and entity.play_counter > target.play_counter: + self.triggered_dearattle = True + if target.deathrattles: + source.game.queue_actions(target.controller, [Deathrattle(target)]) + return super()._broadcast(entity, source, at, *args) + def do(self, source, target): log.info("Processing Death for %r", target) + self.triggered_dearattle = False self.broadcast(source, EventListener.ON, target) - if target.deathrattles: + if (not self.triggered_dearattle) and target.deathrattles: source.game.queue_actions(target.controller, [Deathrattle(target)]) @@ -1316,6 +1326,14 @@ def do(self, source, target, cards): continue if card.controller != target: card.controller = target + # Poisoned Blade + if ( + card.controller.weapon and + card.controller.weapon.id == "AT_034" and + source.type == CardType.HERO_POWER and + card.type == CardType.WEAPON + ): + continue if card.zone != Zone.PLAY: if source.type == CardType.MINION and source.zone == Zone.PLAY: source_index = source.controller.field.index(source) diff --git a/fireplace/cards/classic/rogue.py b/fireplace/cards/classic/rogue.py index 6cdbd1734..1473c719d 100644 --- a/fireplace/cards/classic/rogue.py +++ b/fireplace/cards/classic/rogue.py @@ -6,7 +6,7 @@ class CS2_083b: """Dagger Mastery""" - activate = Find(FRIENDLY_WEAPON + ID("AT_034")) | Summon(CONTROLLER, "CS2_082") + activate = Summon(CONTROLLER, "CS2_082") # Sharpened (Unused) diff --git a/tests/test_misc.py b/tests/test_misc.py index 13a3bf589..ace98cd5a 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -45,3 +45,24 @@ def test_silence(): assert minion.health == 4 game.player1.give("CS2_203").play(target=minion) assert minion.health == 4 + + +def test_anubar_ambusher_cult_master(): + # https://github.com/jleclanche/fireplace/issues/126 + game = prepare_game() + game.player1.discard_hand() + cultmaster1 = game.player1.summon("EX1_595") + ambusher1 = game.player1.summon("FP1_026") + assert len(game.player1.hand) == 0 + ambusher1.destroy() + assert len(game.player1.hand) == 2 + assert cultmaster1 in game.player1.hand + game.end_turn(); game.end_turn() + + game.player1.discard_hand() + ambusher2 = game.player1.summon("FP1_026") + cultmaster2 = game.player1.summon("EX1_595") + assert len(game.player1.hand) == 0 + ambusher2.destroy() + assert len(game.player1.hand) == 1 + assert cultmaster2 in game.player1.hand diff --git a/tests/test_tgt.py b/tests/test_tgt.py index 79faac15f..71c013a97 100644 --- a/tests/test_tgt.py +++ b/tests/test_tgt.py @@ -869,3 +869,12 @@ def test_arcane_blast(): game.player1.field[-1].destroy() game.player1.give("AT_004").play(target=minion) assert minion.damage == 2 + 4 + 6 + 4 + + +def test_poisoned_blade(): + game = prepare_game(CardClass.ROGUE, CardClass.ROGUE) + blade = game.player1.give("AT_034").play() + atk = blade.atk + game.player1.hero.power.use() + assert game.player1.weapon.id == "AT_034" + assert game.player1.weapon.atk == atk + 1