From 2709acacbbbab6ed5438ffbbe3a1e06f16a3c88a Mon Sep 17 00:00:00 2001 From: shinoi2 Date: Thu, 28 Mar 2024 09:37:14 +0800 Subject: [PATCH] Redemption has a low priority --- fireplace/actions.py | 16 ++++++++++------ fireplace/cards/classic/paladin.py | 2 +- fireplace/cards/troll/warlock.py | 4 ++-- tests/test_mechanics.py | 9 +++++++++ tests/test_tgt.py | 6 ++++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/fireplace/actions.py b/fireplace/actions.py index d821f890b..b5345aee6 100644 --- a/fireplace/actions.py +++ b/fireplace/actions.py @@ -328,10 +328,12 @@ class Death(GameAction): 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: + if (not self._trigger) and entity.play_counter > target.play_counter: + self._trigger = True + if at == EventListener.ON and target.deathrattles: source.game.queue_actions(target, [Deathrattle(target)]) + if at == EventListener.AFTER and target.type == CardType.MINION and target.reborn: + source.game.queue_actions(target, [Summon(target.controller, RebornCopy(SELF))]) return super()._broadcast(entity, source, at, *args) def do(self, source, cards): @@ -344,13 +346,15 @@ def do(self, source, cards): source.game.check_for_end_game() source.game.refresh_auras() log.info("Processing Deathrattle for %r", card) - self.triggered_dearattle = False + self._trigger = False source.game.manager.game_action(self, source, card) self.broadcast(source, EventListener.ON, card) for card in cards: - if card.dead and card.type == CardType.MINION and card.reborn: - source.game.queue_actions(card, [Summon(card.controller, RebornCopy(SELF))]) + if not card.dead: + continue + self._trigger = False + self.broadcast(source, EventListener.AFTER, card) class EndTurn(GameAction): diff --git a/fireplace/cards/classic/paladin.py b/fireplace/cards/classic/paladin.py index ff0cecebe..4b1ff8960 100644 --- a/fireplace/cards/classic/paladin.py +++ b/fireplace/cards/classic/paladin.py @@ -192,7 +192,7 @@ class EX1_132: class EX1_136: """Redemption""" - secret = Death(FRIENDLY + MINION).on(FULL_BOARD | ( + secret = Death(FRIENDLY + MINION).after(FULL_BOARD | ( Reveal(SELF), Summon(CONTROLLER, Copy(Death.ENTITY)).then(SetCurrentHealth(Summon.CARD, 1)) )) diff --git a/fireplace/cards/troll/warlock.py b/fireplace/cards/troll/warlock.py index 79960cd34..a53cc19ef 100644 --- a/fireplace/cards/troll/warlock.py +++ b/fireplace/cards/troll/warlock.py @@ -16,7 +16,7 @@ class TRL_251: # +1/+1. events = ( OWN_TURN_BEGIN.on(Unstealth(SELF)), - Death(FRIENDLY_MINIONS).after( + Death(FRIENDLY_MINIONS).on( Buff(RANDOM(FRIENDLY_HAND + MINION), "TRL_251e") ) ) @@ -41,7 +41,7 @@ class TRL_253: class TRL_257: """Blood Troll Sapper""" # After a friendly minion dies, deal 2 damage to the enemy hero. - events = Death(FRIENDLY_MINIONS).after(Hit(FRIENDLY_HERO, 2)) + events = Death(FRIENDLY_MINIONS).on(Hit(FRIENDLY_HERO, 2)) class TRL_551: diff --git a/tests/test_mechanics.py b/tests/test_mechanics.py index ded1fca19..205a5ae6f 100644 --- a/tests/test_mechanics.py +++ b/tests/test_mechanics.py @@ -242,6 +242,15 @@ def test_combo(): game.current_player.give("EX1_134").play() +def test_deathrattle_simple(): + game = prepare_game() + loothoarder = game.current_player.give("EX1_096") + loothoarder.play() + cardcount = len(game.current_player.hand) + game.player1.give(MOONFIRE).play(target=loothoarder) + assert len(game.player1.hand) == cardcount + 1 + + def test_deathrattle(): game = prepare_game() loothoarder = game.current_player.give("EX1_096") diff --git a/tests/test_tgt.py b/tests/test_tgt.py index 2265045cc..de255b124 100644 --- a/tests/test_tgt.py +++ b/tests/test_tgt.py @@ -255,7 +255,7 @@ def test_effigy(): summoned_minion.bounce() # assert summoned_minion.is_collectible() game.end_turn() - game.player1.give("EX1_136").play() + redemption = game.player1.give("EX1_136").play() secret_effigy2.play() assert secret_effigy not in game.player1.secrets assert secret_effigy2 in game.player1.secrets @@ -264,7 +264,9 @@ def test_effigy(): game.player1.summon("EX1_110") game.end_turn() game.player2.give("EX1_617").play() - assert secret_effigy2 in game.player1.secrets + # Redemption has a low priority + assert secret_effigy2 not in game.player1.secrets + assert redemption in game.player1.secrets def test_enter_the_coliseum():