diff --git a/fireplace/actions.py b/fireplace/actions.py index 82a817c0b..ad37a8b7b 100644 --- a/fireplace/actions.py +++ b/fireplace/actions.py @@ -1166,8 +1166,8 @@ class SetMana(TargetedAction): def do(self, source, target, amount): old_mana = target.mana target.max_mana = amount - if old_mana > target.mana: - target.used_mana -= old_mana - target.mana + target.used_mana = max( + 0, target.max_mana - target.overload_locked - old_mana + target.temp_mana) class Give(TargetedAction): @@ -1485,9 +1485,16 @@ def do(self, source, target, cost): if cost <= 0: return tiger = target.controller.card("TRL_309t") - tiger.atk = cost - tiger.max_health = cost - tiger.cost = cost + tiger.custom_card = True + + def create_custom_card(tiger): + tiger.atk = cost + tiger.max_health = cost + tiger.cost = cost + + tiger.create_custom_card = create_custom_card + tiger.create_custom_card(tiger) + if tiger.is_summonable(): source.game.queue_actions(source, [Summon(target, tiger)]) @@ -1628,14 +1635,13 @@ def do(self, source, card, targets): if card.must_choose_one: card = random.choice(card.choose_cards) for target in targets: - if not target: - if card.requires_target(): - if len(card.targets): - if target not in card.targets: - target = random.choice(card.targets) - else: - log.info("%s cast spell %s don't have a legal target", source, card) - return + if card.requires_target() and not target: + if len(card.targets) > 0: + if target not in card.targets: + target = random.choice(card.targets) + else: + log.info("%s cast spell %s don't have a legal target", source, card) + return card.target = target card.zone = Zone.PLAY log.info("%s cast spell %s target %s", source, card, target) @@ -1648,43 +1654,6 @@ def do(self, source, card, targets): source.game.queue_actions(source, [Deaths()]) -class CastSpellTargetsEnemiesIfPossible(TargetedAction): - """ - Cast a spell target random targets enemies if possible - """ - CARD = CardArg() - - 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(): - targets = card.targets - if len(targets) > 0: - enemy_targets = list(filter( - lambda item: item.controller != source.controller, targets)) - if len(enemy_targets) > 0: - target = random.choice(enemy_targets) - else: - target = random.choice(targets) - else: - log.info("%s cast spell %s don't have a legal target", source, card) - return - 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) - log.info("Choosing card %r" % (choice)) - player.choice.choose(choice) - player.choice = old_choice - source.game.queue_actions(source, [Deaths()]) - - class Evolve(TargetedAction): """ Transform your minions into random minions that cost (\a amount) more @@ -1864,32 +1833,6 @@ def choose(self, card): self.trigger_choice_callback() -class Upgrade(TargetedAction): - """ - Upgrade cards - """ - TARGET = ActionArg - AMOUNT = IntArg() - - def do(self, source, target): - log.info("Upgrade %s counter to %s", target, target.upgrade_counter + 1) - target.upgrade_counter += 1 - self.broadcast(source, EventListener.AFTER, target, target.upgrade_counter) - - -class Awaken(TargetedAction): - """ - Awaken a dormant minion - """ - TARGET = ActionArg() - - def do(self, source, target): - log.info("%s is awaken", target) - target.turns_in_play = 0 - if target.get_actions("awaken"): - source.game.trigger(target, target.get_actions("awaken"), event_args=None) - - class GameStart(GameAction): """ Setup game diff --git a/fireplace/cards/__init__.py b/fireplace/cards/__init__.py index 0b0671fae..27a730879 100644 --- a/fireplace/cards/__init__.py +++ b/fireplace/cards/__init__.py @@ -107,11 +107,6 @@ def merge(id, card, cardscript=None): if hasattr(cardscript, "entourage"): card.entourage = cardscript.entourage - if hasattr(cardscript, "dormant"): - card.dormant = cardscript.dormant - else: - card.dormant = 0 - if hasattr(cardscript, "progress_total"): card.scripts.progress_total = cardscript.progress_total else: diff --git a/fireplace/game.py b/fireplace/game.py index cb62e3b39..47ef71c64 100644 --- a/fireplace/game.py +++ b/fireplace/game.py @@ -6,7 +6,7 @@ from hearthstone.enums import BlockType, CardType, PlayState, State, Step, Zone from .actions import ( - Attack, Awaken, BeginTurn, Death, EndTurn, EventListener, GameStart, Play + Attack, BeginTurn, Death, EndTurn, EventListener, GameStart, Play ) from .card import THE_COIN from .entity import Entity @@ -376,12 +376,6 @@ def _begin_turn(self, player): character.damaged_this_turn = 0 character.healed_this_turn = 0 - for minion in player.field: - if minion.dormant: - minion.dormant -= 1 - if not minion.dormant: - self.queue_actions(self, [Awaken(minion)]) - player.draw() self.manager.step(self.next_step, Step.MAIN_END) diff --git a/tests/test_kobolds.py b/tests/test_kobolds.py index 5dfbef473..2dd93d548 100644 --- a/tests/test_kobolds.py +++ b/tests/test_kobolds.py @@ -159,3 +159,12 @@ def test_dragons_fury(): assert wisp.dead assert not mech.dead assert mech.health == 1 + + +def test_unstable_evolution(): + game = prepare_game() + game.player1.give(WISP).play() + game.player1.give("LOOT_504") + evolution = game.player1.hand[-1] + evolution.play(target=game.player1.field[0]) + assert game.player1.field[0].cost == 1 diff --git a/tests/test_misc.py b/tests/test_misc.py index 77c7d0908..6170551df 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,3 +1,4 @@ +from full_game import test_full_game from utils import * diff --git a/tests/test_troll.py b/tests/test_troll.py index a3c677536..045c100b5 100644 --- a/tests/test_troll.py +++ b/tests/test_troll.py @@ -204,3 +204,62 @@ def test_zuljin(): assert game.player1.temp_mana == 0 game.player1.give("TRL_065").play() assert game.player1.temp_mana == 1 + + +def test_sulthraze(): + game = prepare_game() + wisps = [game.player1.give(WISP).play() for _ in range(4)] + game.end_turn() + game.player2.give("TRL_325").play() + for wisp in wisps: + assert game.player2.hero.can_attack() + game.player2.hero.attack(wisp) + assert not game.player2.hero.can_attack() + + +def test_summon_tiger(): + game = prepare_game() + game.player1.give("TRL_309").play() + game.player1.give(FIREBALL).play(target=game.player2.hero) + tiger = game.player1.field[1] + assert tiger.cost == 4 + assert tiger.atk == 4 + assert tiger.health == 4 + game.player1.give(SILENCE).play(target=tiger) + assert tiger.cost == 4 + assert tiger.atk == 4 + assert tiger.health == 4 + game.end_turn() + + game.player2.give("EX1_564").play(target=tiger) + copy_tiger = game.player2.field[0] + assert copy_tiger.cost == 4 + assert copy_tiger.atk == 4 + assert copy_tiger.health == 4 + + +def test_mojomaster_zihi(): + game = prepare_game() + zihi = game.player1.give("TRL_564").play() + assert game.player1.max_mana == 5 + assert game.player2.max_mana == 5 + assert game.player1.mana == 10 - zihi.cost + assert game.player2.mana == 5 + + game2 = prepare_game(game_class=Game) + for _ in range(5): + game2.player1.give(THE_COIN).play() + game2.player1.give("TRL_564").play() + assert game2.player1.max_mana == 5 + assert game2.player2.max_mana == 5 + assert game2.player1.mana == 0 + assert game2.player2.mana == 0 + + game3 = prepare_game(game_class=Game) + for _ in range(10): + game3.player1.give(THE_COIN).play() + game3.player1.give("TRL_564").play() + assert game3.player1.max_mana == 5 + assert game3.player2.max_mana == 5 + assert game3.player1.mana == 10 - zihi.cost + assert game3.player2.mana == 0 diff --git a/tests/test_wog.py b/tests/test_wog.py index a141f8cb8..212472fea 100644 --- a/tests/test_wog.py +++ b/tests/test_wog.py @@ -686,3 +686,11 @@ def test_thing_from_below(): assert below.cost == below_cost - 2 below.play() assert below.cost == below_cost + + +def test_faceless_shambler(): + game = prepare_game() + wisp = game.player1.give(WISP).play() + faceless = game.player1.give("OG_174").play(target=wisp) + assert faceless.atk == wisp.atk + assert faceless.health == wisp.health