Skip to content

Commit

Permalink
修复部分测试错误
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Nov 29, 2023
1 parent 585621b commit 4211b31
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
17 changes: 12 additions & 5 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def get_args(self, source):
for card in cards:
if isinstance(card, LazyValue):
eval_cards.append(card.evaluate(source)[0])
if isinstance(card, str):
elif isinstance(card, str):
eval_cards.append(source.controller.card(card, source))
else:
eval_cards.append(card)
Expand Down Expand Up @@ -908,10 +908,10 @@ def do(self, source, target, cards):
def choose(self, card):
if card not in self.cards:
raise InvalidAction("%r is not a valid choice (one of %r)" % (card, self.cards))
self.player.choice = self.next_choice
for action in self._callback:
self.source.game.trigger(
self.source, [action], [self.target, self.cards, card])
self.player.choice = self.next_choice


class Draw(TargetedAction):
Expand Down Expand Up @@ -1403,6 +1403,9 @@ class CastSpell(TargetedAction):

def do(self, source, card):
target = None
player = source.controller
old_choice = player.choice
player.choice = None
if card.must_choose_one:
card = random.choice(card.choose_cards)
if card.requires_target():
Expand All @@ -1414,11 +1417,11 @@ def do(self, source, card):
card.target = target
log.info("%s cast spell %s target %s", source, card, target)
source.game.queue_actions(source, [Battlecry(card, card.target)])
player = source.controller
while player.choice:
choice = random.choice(player.choice.cards)
print("Choosing card %r" % (choice))
log.info("Choosing card %r" % (choice))
player.choice.choose(choice)
player.choice = old_choice
source.game.queue_actions(source, [Deaths()])


Expand All @@ -1430,6 +1433,9 @@ class CastSpellTargetsEnemiesIfPossible(TargetedAction):

def do(self, source, card):
target = None
player = source.controller
old_choice = player.choice
player.choice = None
if card.must_choose_one:
card = random.choice(card.choose_cards)
if card.requires_target():
Expand All @@ -1450,8 +1456,9 @@ def do(self, source, card):
player = source.controller
while player.choice:
choice = random.choice(player.choice.cards)
print("Choosing card %r" % (choice))
log.info("Choosing card %r" % (choice))
player.choice.choose(choice)
player.choice = old_choice
source.game.queue_actions(source, [Deaths()])


Expand Down
4 changes: 2 additions & 2 deletions fireplace/cards/gangs/neutral_legendary.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CFM_672:
def play(self):
targets = self.controller.deck.filter(type=CardType.MINION)
if targets:
target = random.sample(targets, 1)
target = random.choice(targets)
target.zone = Zone.SETASIDE
yield Shuffle(CONTROLLER, TARGET)
yield Summon(CONTROLLER, target)
Expand Down Expand Up @@ -84,7 +84,7 @@ class CFM_807:

class CFM_808:
"""Genzo, the Shark"""
events = Attack(SELF).on(DrawUntil(EndTurn.PLAYER, 3))
events = Attack(SELF).on(DrawUntil(PLAYER, 3))


class CFM_902(JadeGolemUtils):
Expand Down
6 changes: 4 additions & 2 deletions fireplace/cards/karazhan/collectible.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ class KAR_095:
class KAR_096:
"""Prince Malchezaar"""
class Deck:
events = GameStart().after(Shuffle(CONTROLLER, RandomLegendaryMinion(exclude=DeDuplicate(STARTING_DECK))) * 5)
events = GameStart().after(
Shuffle(CONTROLLER, RandomLegendaryMinion(exclude=DeDuplicate(STARTING_DECK))) * 5)

class Hand:
events = GameStart().after(Shuffle(CONTROLLER, RandomLegendaryMinion(exclude=DeDuplicate(STARTING_DECK))) * 5)
events = GameStart().after(
Shuffle(CONTROLLER, RandomLegendaryMinion(exclude=DeDuplicate(STARTING_DECK))) * 5)


class KAR_097:
Expand Down
6 changes: 0 additions & 6 deletions fireplace/cards/ungoro/neutral_epic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class UNG_113e:

class UNG_847:
"""Blazecaller"""
requirements = {
PlayReq.REQ_NONSELF_TARGET: 0,
PlayReq.REQ_TARGET_IF_AVAILABE_AND_ELEMENTAL_PLAYED_LAST_TURN: 0}
play = Hit(TARGET, 5)


Expand All @@ -64,7 +61,4 @@ class UNG_848:

class UNG_946:
"""Gluttonous Ooze"""
requirements = {
PlayReq.REQ_FRIENDLY_TARGET: 0,
PlayReq.REQ_MINION_TARGET: 0, PlayReq.REQ_TARGET_WITH_DEATHRATTLE: 0}
play = Destroy(ENEMY_WEAPON).then(GainArmor(FRIENDLY_HERO, ATK(Destroy.TARGET)))
4 changes: 4 additions & 0 deletions fireplace/targeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PlayReq.REQ_TARGET_IF_AVAILABLE_AND_MINIMUM_FRIENDLY_MINIONS,
PlayReq.REQ_TARGET_IF_AVAILABLE_AND_MINIMUM_FRIENDLY_SECRETS,
PlayReq.REQ_TARGET_IF_AVAILABLE_AND_HERO_ATTACKED_THIS_TURN,
PlayReq.REQ_TARGET_IF_AVAILABE_AND_ELEMENTAL_PLAYED_LAST_TURN,
)


Expand Down Expand Up @@ -67,6 +68,9 @@ def is_valid_target(self, target, requirements=None):
elif req == PlayReq.REQ_TARGET_MAX_ATTACK:
if target.atk > param or 0:
return False
elif req == PlayReq.REQ_NONSELF_TARGET:
if target is self:
return False
elif req == PlayReq.REQ_TARGET_WITH_RACE:
if target.type != CardType.MINION or target.race != param:
return False
Expand Down
12 changes: 12 additions & 0 deletions tests/test_gangs.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,15 @@ def test_kabal_crystal_runner():
assert runner.cost == runner_cost - 2
runner2 = game.player1.give("CFM_760")
assert runner2.cost == runner_cost - 2


def test_madam_goya():
game = prepare_empty_game()
wisp = game.player1.give(WISP).play()
murloc = game.player1.give(MURLOC)
murloc.shuffle_into_deck()
assert wisp.zone == Zone.PLAY
assert murloc.zone == Zone.DECK
game.player1.give("CFM_672").play(target=wisp)
assert wisp.zone == Zone.DECK
assert murloc.zone == Zone.PLAY
8 changes: 8 additions & 0 deletions tests/test_ungoro.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,11 @@ def test_mage_quest():
game.player2.give(MOONFIRE).play(target=game.player1.hero)
assert quest.progress == 6
assert game.player2.hand[-1].id == "UNG_028t"


def test_blazecaller():
game = prepare_game()
blazecaller1 = game.player1.give("UNG_847").play()
game.end_turn()
game.end_turn()
blazecaller1 = game.player1.give("UNG_847").play(target=blazecaller1)

0 comments on commit 4211b31

Please sign in to comment.