Skip to content

Commit

Permalink
Rewrite cards played last turn
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Mar 29, 2024
1 parent f8792bc commit 8842ae7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 0 additions & 4 deletions fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,6 @@ def drawn_this_turn(self):
def played_this_turn(self):
return self.turn_played == self.game.turn

@property
def played_last_turn(self):
return self.turn_played == self.controller.last_turn

@property
def zone_position(self):
"""
Expand Down
6 changes: 5 additions & 1 deletion fireplace/dsl/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ def CONTROLLED_BY(selector):

NUM_CARDS_PLAYED_THIS_TURN = Attr(CONTROLLER, GameTag.NUM_CARDS_PLAYED_THIS_TURN)
CARDS_PLAYED_THIS_TURN = AttrValue("played_this_turn") == True # noqa
CARDS_PLAYED_LAST_TURN = AttrValue("played_this_turn") == True # noqa

CARDS_PLAYED_THIS_GAME = FuncSelector(
lambda entities, source: source.controller.cards_played_this_game)
Expand Down Expand Up @@ -623,3 +622,8 @@ def CONTROLLED_BY(selector):
lambda entities, source: sel.evaluate(source).choose_cards
)
)

CARDS_PLAYED_LAST_TURN = FuncSelector(
lambda entities, source:
[e for e in entities if getattr(e, "turn_played", -1) == source.controller.last_turn]
)
11 changes: 11 additions & 0 deletions tests/test_troll.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,14 @@ def test_wartbringer():
game.player1.give(MOONFIRE).play(target=game.player2.hero)
assert wartbringer.powered_up
assert wartbringer.requires_target()


def test_kragwa_the_frog():
game = prepare_empty_game()
frog = game.player1.give("TRL_345")
for _ in range(4):
game.player1.give(MOONFIRE).play(target=game.player2.hero)
game.skip_turn()
assert game.player1.hand == [frog]
frog.play()
assert game.player1.hand == [MOONFIRE] * 4

0 comments on commit 8842ae7

Please sign in to comment.