Skip to content

Commit

Permalink
Fix issue: #91
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Dec 19, 2023
1 parent bc0df30 commit f149410
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
4 changes: 2 additions & 2 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def trigger_choice_callback(self):
class GameAction(Action):
def trigger(self, source):
args = self.get_args(source)
self.do(source, *args)
source.game.manager.game_action(self, source, *args)
self.do(source, *args)


class Attack(GameAction):
Expand Down Expand Up @@ -598,8 +598,8 @@ def _trigger(self, i, source):
log.info("%r triggering %r targeting %r", source, self, targets)
for target in targets:
target_args = self.get_target_args(source, target)
ret.append(self.do(source, target, *target_args))
source.game.manager.targeted_action(self, source, target, *target_args)
ret.append(self.do(source, target, *target_args))

for action in self.callback:
log.info("%r queues up callback %r", self, action)
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/naxxramas/collectible.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FP1_001:

class FP1_002:
"""Haunted Creeper"""
deathrattle = Summon(CONTROLLER, "FP1_002t"), Summon(CONTROLLER, "FP1_002t")
deathrattle = Summon(CONTROLLER, "FP1_002t") * 2


class FP1_003:
Expand Down
14 changes: 9 additions & 5 deletions fireplace/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,23 @@ def play_card(self, card, target, index, choose):
def process_deaths(self):
type = BlockType.DEATHS
cards = []
destroy_cards = []
for card in self.live_entities:
if card.to_be_destroyed:
cards.append(card)
if card._to_be_destroyed:
card.zone = Zone.GRAVEYARD
destroy_cards.append(card)

actions = []
if cards:
self.action_start(type, self, 0, None)
for card in cards:
card.zone = Zone.GRAVEYARD
actions.append(Death(card))
self.check_for_end_game()
if card.to_be_destroyed or card in destroy_cards:
card.zone = Zone.GRAVEYARD
self.check_for_end_game()
self.refresh_auras()
self.trigger(self, [Death(card)], event_args=None)
self.action_end(type, self)
self.trigger(self, actions, event_args=None)

def trigger(self, source, actions, event_args):
"""
Expand Down
36 changes: 24 additions & 12 deletions tests/test_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,18 @@ def test_cult_master_board_clear():
assert len(game.player1.field) == 5
# Whirlwind the board
game.player1.give("EX1_400").play()
assert len(game.player1.hand) == 4

game = prepare_game()
game.player1.discard_hand()
cultmaster = game.player1.give("EX1_595")
cultmaster.play()
for i in range(4):
game.player1.give(WISP).play()
game.player1.give(MOONFIRE).play(target=cultmaster)
assert len(game.player1.field) == 5
# Whirlwind the board
game.player1.give("EX1_400").play()
assert len(game.player1.hand) == 0


Expand Down Expand Up @@ -1903,7 +1915,18 @@ def test_knife_juggler_swipe():
assert juggler.dead
assert creeper.dead
assert len(game.player2.field) == 2
assert game.player1.hero.health == 30
assert game.player1.hero.health == 28

game = prepare_game()
juggler = game.player2.summon("NEW1_019")
creeper = game.player2.summon("FP1_002")
game.current_player.give(MOONFIRE).play(target=creeper)
swipe = game.player1.give("CS2_012")
swipe.play(target=juggler)
assert juggler.dead
assert creeper.dead
assert len(game.player2.field) == 2
assert game.player1.hero.health == 29


def test_leeroy():
Expand Down Expand Up @@ -3810,14 +3833,3 @@ def test_gruul_ragnaros():
assert len(game.player1.field) == 1
assert gruul.atk == 9
assert (gruul.damage == 8) ^ (game.player1.hero.damage == 8)


def test_sorted_deathrattle():
game = prepare_game()
game.player1.give("LOOT_153").play()
game.player1.give("OG_241").play(index=0)
game.end_turn()
game.player2.give("EX1_312").play()
assert len(game.player1.field) == 7
for minion in game.player1.field:
assert minion.id == "LOOT_153t1"
8 changes: 5 additions & 3 deletions tests/test_naxxramas.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def test_avenge_board_clear():

arcane = game.player2.give("CS2_025")
arcane.play()
assert avenge in game.player1.secrets
assert avenge not in game.player1.secrets
assert len(game.player1.field) == 1
assert game.player1.field[0].atk == 4
assert game.player1.field[0].health == 2


def test_baron_rivendare():
Expand Down Expand Up @@ -448,9 +451,8 @@ def test_stalagg_feugen_both_killed():
stalagg.attack(feugen)
assert stalagg.dead
assert feugen.dead
assert len(game.player1.field) == 1
assert len(game.player1.field) == 0
assert len(game.player2.field) == 1
assert game.player1.field[0].id == "FP1_014t"
assert game.player2.field[0].id == "FP1_014t"


Expand Down

0 comments on commit f149410

Please sign in to comment.