From 8caac7797bbf775cbbf3bd2ead5a6b801a73dd0f Mon Sep 17 00:00:00 2001 From: shinoi2 Date: Mon, 4 Dec 2023 15:10:12 +0800 Subject: [PATCH] Add . Fix some card and test --- fireplace/card.py | 1 + fireplace/cards/icecrown/warrior.py | 4 +- fireplace/cards/kobolds/__init__.py | 1 + fireplace/cards/kobolds/neutral_legendary.py | 39 ++++++++++++++++++++ fireplace/cards/ungoro/mage.py | 2 +- fireplace/cards/ungoro/shaman.py | 2 +- fireplace/dsl/copy.py | 13 ++++--- fireplace/utils.py | 22 +++++++++-- tests/test_ungoro.py | 7 ++++ 9 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 fireplace/cards/kobolds/__init__.py create mode 100644 fireplace/cards/kobolds/neutral_legendary.py diff --git a/fireplace/card.py b/fireplace/card.py index 5419ca0dd..dfbadc02b 100644 --- a/fireplace/card.py +++ b/fireplace/card.py @@ -761,6 +761,7 @@ def play(self, target=None, index=None, choose=None): if armor: self.game.cheat_action(self, [actions.GainArmor(self, armor)]) + class Minion(Character): charge = boolean_property("charge") has_inspire = boolean_property("has_inspire") diff --git a/fireplace/cards/icecrown/warrior.py b/fireplace/cards/icecrown/warrior.py index 4d23ec645..25580b01a 100644 --- a/fireplace/cards/icecrown/warrior.py +++ b/fireplace/cards/icecrown/warrior.py @@ -6,7 +6,7 @@ class ICC_062: """Mountainfire Armor""" - deathrattle = CurrentPlayer(OPPONENT) & GainArmor(CONTROLLER, 6) + deathrattle = CurrentPlayer(OPPONENT) & GainArmor(FRIENDLY_HERO, 6) class ICC_238: @@ -47,7 +47,7 @@ class ICC_281: class ICC_837: """Bring It On!""" - play = GainArmor(CONTROLLER, 10), Buff(ENEMY_HAND + MINION, "ICC_837e") + play = GainArmor(FRIENDLY_HERO, 10), Buff(ENEMY_HAND + MINION, "ICC_837e") class ICC_837e: diff --git a/fireplace/cards/kobolds/__init__.py b/fireplace/cards/kobolds/__init__.py new file mode 100644 index 000000000..0a27081a0 --- /dev/null +++ b/fireplace/cards/kobolds/__init__.py @@ -0,0 +1 @@ +from .neutral_legendary import * diff --git a/fireplace/cards/kobolds/neutral_legendary.py b/fireplace/cards/kobolds/neutral_legendary.py new file mode 100644 index 000000000..a7eb9dfbd --- /dev/null +++ b/fireplace/cards/kobolds/neutral_legendary.py @@ -0,0 +1,39 @@ +from ..utils import * + + +## +# Minions + +class LOOT_357: + """Marin the Fox""" + play = Summon(OPPONENT, "LOOT_357l") + + +class LOOT_357l: + entourage = ["LOOT_998h", "LOOT_998j", "LOOT_998l", "LOOT_998k"] + deathrattle = Give(OPPONENT, RandomEntourage()) + + +class LOOT_998h: + play = Draw(CONTROLLER).then(Give(CONTROLLER, Copy(Draw.CARD)) * ( + MAX_HAND_SIZE(CONTROLLER) - Count(FRIENDLY_HAND) + )) + + +class LOOT_998j: + play = Discover(CONTROLLER, RandomLegendaryMinion()).then( + Summon(CONTROLLER, Discover.CARD) * 2 + ) + + +class LOOT_998l: + play = (Draw(CONTROLLER) * 3).then(Buff(Draw.CARD, "LOOT_998le")) + + +class LOOT_998le: + cost = SET(0) + events = REMOVED_IN_PLAY + + +class LOOT_998k: + play = Morph(FRIENDLY_HAND, RandomLegendaryMinion()) diff --git a/fireplace/cards/ungoro/mage.py b/fireplace/cards/ungoro/mage.py index 510f44a5f..acc56ac25 100644 --- a/fireplace/cards/ungoro/mage.py +++ b/fireplace/cards/ungoro/mage.py @@ -87,7 +87,7 @@ class UNG_948: PlayReq.REQ_FRIENDLY_TARGET: 0, PlayReq.REQ_MINION_TARGET: 0, PlayReq.REQ_TARGET_TO_PLAY: 0} - play = Summon(TARGET, ExactCopy(TARGET)) + play = Summon(CONTROLLER, ExactCopy(TARGET)) class UNG_955: diff --git a/fireplace/cards/ungoro/shaman.py b/fireplace/cards/ungoro/shaman.py index 35d3f6c2d..6c3bd8759 100644 --- a/fireplace/cards/ungoro/shaman.py +++ b/fireplace/cards/ungoro/shaman.py @@ -81,7 +81,7 @@ class UNG_942: class UNG_942t: play = Give(CONTROLLER, RandomMurloc()) * ( - MAX_HAND_SIZE(CONTROLLER) - Count(IN_HAND + FRIENDLY) + MAX_HAND_SIZE(CONTROLLER) - Count(FRIENDLY_HAND) ) diff --git a/fireplace/dsl/copy.py b/fireplace/dsl/copy.py index 1b0144df6..4ff506cb6 100644 --- a/fireplace/dsl/copy.py +++ b/fireplace/dsl/copy.py @@ -1,3 +1,5 @@ +from hearthstone.enums import CardType + from ..logging import log from .lazynum import LazyValue @@ -41,11 +43,12 @@ def copy(self, source, entity): ret = super().copy(source, entity) if self.id: ret = source.controller.card(self.id, source) - for k in entity.silenceable_attributes: - v = getattr(entity, k) - setattr(ret, k, v) - ret.silenced = entity.silenced - ret.damage = entity.damage + if entity.type == CardType.MINION: + for k in entity.silenceable_attributes: + v = getattr(entity, k) + setattr(ret, k, v) + ret.silenced = entity.silenced + ret.damage = entity.damage for buff in entity.buffs: # Recreate the buff stack entity.buff(ret, buff.id) diff --git a/fireplace/utils.py b/fireplace/utils.py index 936027f00..f2d760a95 100644 --- a/fireplace/utils.py +++ b/fireplace/utils.py @@ -188,13 +188,22 @@ def play_turn(game): while True: heropower = player.hero.power - if heropower.is_playable() and random.random() < 0.1: + if heropower.is_usable() and random.random() < 0.1: + choose = None + target = None + if heropower.must_choose_one: + choose = random.choice(heropower.choose_cards) if heropower.requires_target(): - heropower.use(target=random.choice(heropower.targets)) - else: - heropower.use() + target = random.choice(heropower.targets) + heropower.use(target=target, choose=choose) continue + # eg. Deathstalker Rexxar + while player.choice: + choice = random.choice(player.choice.cards) + print("Choosing card %r" % (choice)) + player.choice.choose(choice) + # iterate over our hand and play whatever is playable for card in player.hand: if card.is_playable() and random.random() < 0.5: @@ -217,6 +226,11 @@ def play_turn(game): for character in player.characters: if character.can_attack(): character.attack(random.choice(character.targets)) + # eg. Vicious Fledgling + while player.choice: + choice = random.choice(player.choice.cards) + print("Choosing card %r" % (choice)) + player.choice.choose(choice) break diff --git a/tests/test_ungoro.py b/tests/test_ungoro.py index 50d3679ad..b980ecb00 100644 --- a/tests/test_ungoro.py +++ b/tests/test_ungoro.py @@ -278,3 +278,10 @@ def test_blazecaller(): game.end_turn() game.end_turn() blazecaller1 = game.player1.give("UNG_847").play(target=blazecaller1) + + +def test_molten_reflection(): + game = prepare_game() + wisp = game.player1.give(WISP).play() + game.player1.give("UNG_948").play(target=wisp) + assert len(game.player1.field) == 2