From 8842ae7dc93ac408bf613f0615804d1560dccd02 Mon Sep 17 00:00:00 2001 From: shinoi2 Date: Fri, 29 Mar 2024 09:51:38 +0800 Subject: [PATCH] Rewrite cards played last turn --- fireplace/card.py | 4 ---- fireplace/dsl/selector.py | 6 +++++- tests/test_troll.py | 11 +++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fireplace/card.py b/fireplace/card.py index fe9d07785..83deab598 100644 --- a/fireplace/card.py +++ b/fireplace/card.py @@ -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): """ diff --git a/fireplace/dsl/selector.py b/fireplace/dsl/selector.py index e724e7025..24751dc28 100644 --- a/fireplace/dsl/selector.py +++ b/fireplace/dsl/selector.py @@ -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) @@ -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] +) diff --git a/tests/test_troll.py b/tests/test_troll.py index 26d6ca4b1..2af09fc65 100644 --- a/tests/test_troll.py +++ b/tests/test_troll.py @@ -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