Skip to content

Commit

Permalink
Redemption has a low priority
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Mar 28, 2024
1 parent 8e88a1f commit 2709aca
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
16 changes: 10 additions & 6 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/classic/paladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
))
Expand Down
4 changes: 2 additions & 2 deletions fireplace/cards/troll/warlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
)
Expand All @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_mechanics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions tests/test_tgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 2709aca

Please sign in to comment.