Skip to content

Commit

Permalink
13.4.0.29349 (#513)
Browse files Browse the repository at this point in the history
* [WIP] Rastakhan's Rumble

* [WIP] Overkill

* [WIP]

* Update whizbang deck

* [WIP] all implement, need test

* fix bug

* fix bugs

* fix bug

* fix bug

* fix bugs

* Update README.md

* fix bugs

* fix bugs

* fix bug
  • Loading branch information
shinoi2 authored Jan 8, 2024
1 parent 56d634d commit d9fbed9
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 29 deletions.
45 changes: 24 additions & 21 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ class Heal(TargetedAction):

def do(self, source, target, amount):
if source.controller.healing_as_damage:
return source.game.queue_actions(source, [Hit(target, amount)])
return source.game.queue_actions(source.controller, [Hit(target, amount)])

amount = source.get_heal(amount, target)
amount = min(amount, target.damage)
Expand Down Expand Up @@ -1609,15 +1609,15 @@ class CastSpell(TargetedAction):

def get_target_args(self, source, target):
ret = super().get_target_args(source, target)
spell_target = None
spell_target = [None]
if ret:
spell_target = ret[0][0]
spell_target = ret[0]
else:
if target.target:
return [target.target]
return [spell_target]

def do(self, source, card, target=None):
def do(self, source, card, targets):
if source.type == CardType.MINION and (
source.dead or source.silenced or source.zone != Zone.PLAY
):
Expand All @@ -1628,23 +1628,25 @@ def do(self, source, card, target=None):
player.choice = None
if card.must_choose_one:
card = random.choice(card.choose_cards)
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
card.target = target
card.zone = Zone.PLAY
log.info("%s cast spell %s target %s", source, card, target)
source.game.queue_actions(source, [Battlecry(card, card.target)])
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()])
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
card.target = target
card.zone = Zone.PLAY
log.info("%s cast spell %s target %s", source, card, target)
source.game.queue_actions(source, [Battlecry(card, card.target)])
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 CastSpellTargetsEnemiesIfPossible(TargetedAction):
Expand Down Expand Up @@ -1838,6 +1840,7 @@ def done(self):
new_card.requirements.update(card1.requirements)
new_card.requirements.update(card2.requirements)
new_card.data.scripts.play = card1.data.scripts.play + card2.data.scripts.play
new_card.requirements = card1.requirements | card2.requirements
new_card.tags[GameTag.CARDTEXT_ENTITY_0] = card1.data.strings[GameTag.CARDTEXT]
new_card.tags[GameTag.CARDTEXT_ENTITY_1] = card2.data.strings[GameTag.CARDTEXT]
self.player.give(new_card)
Expand Down
6 changes: 5 additions & 1 deletion fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def requires_target(self):
"""
if self.has_combo and PlayReq.REQ_TARGET_FOR_COMBO in self.requirements:
if self.controller.combo:
return True
return bool(self.play_targets)
if PlayReq.REQ_TARGET_IF_AVAILABLE in self.requirements:
return bool(self.play_targets)
if PlayReq.REQ_TARGET_IF_AVAILABLE_AND_DRAGON_IN_HAND in self.requirements:
Expand Down Expand Up @@ -545,6 +545,10 @@ def requires_target(self):
if req is not None:
if self not in self.controller.cards_drawn_this_turn:
return bool(self.play_targets)
req = self.requirements.get(PlayReq.REQ_DRAG_TO_PLAY_PRE29933)
if req is not None:
if all(card.cost % 2 == 0 for card in self.controller.deck):
return bool(self.play_targets)
# req = self.requirements.get(
# PlayReq.REQ_TARGET_IF_AVAILABLE_AND_PLAYER_HEALTH_CHANGED_THIS_TURN)
# if req is not None:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


year = ZodiacYear.RAVEN
default_language = "enUS"
default_language = "zhCN"


class CardDB(dict):
Expand Down
3 changes: 2 additions & 1 deletion fireplace/cards/boomsday/priest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class BOT_529e:
class BOT_567:
"""Zerek's Cloning Gallery"""
# Summon a 1/1 copy of_each minion in your_deck.
play = Summon(CONTROLLER, Buff(Copy(FRIENDLY_DECK + MINION), "BOT_567e"))
play = Summon(CONTROLLER, Copy(FRIENDLY_DECK + MINION)).then(
Buff(Summon.CARD, "BOT_567e"))


class BOT_567e:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/troll/rogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TRL_126:
"""Captain Hooktusk"""
# <b>Battlecry:</b> Summon 3 Pirates from your deck. Give them <b>Rush</b>.
play = Summon(CONTROLLER, RANDOM(FRIENDLY_DECK + PIRATE) * 3).then(
GivRush(Summon.CARD)
GiveRush(Summon.CARD)
)


Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
GiveWindfury = lambda target: SetTag(target, (GameTag.WINDFURY, ))
GivePoisonous = lambda target: SetTag(target, (GameTag.POISONOUS, ))
GiveLifesteal = lambda target: SetTag(target, (GameTag.LIFESTEAL, ))
GivRush = lambda target: SetTag(target, (GameTag.RUSH, ))
GiveRush = lambda target: SetTag(target, (GameTag.RUSH, ))


CLEAVE = Hit(TARGET_ADJACENT, ATK(SELF))
Expand Down
10 changes: 8 additions & 2 deletions fireplace/cards/witchwood/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
class GIL_116:
"""Arcane Keysmith"""
# <b>Battlecry:</b> <b>Discover</b> a <b>Secret</b>. Put it into the battlefield.
play = Discover(CONTROLLER, RandomSpell(secret=True)).then(
Summon(CONTROLLER, Discover.CARD)
play = WITH_SECRECTS & (
Discover(CONTROLLER, RandomSpell(secret=True)).then(
Summon(CONTROLLER, Discover.CARD)
)
) | (
Discover(CONTROLLER, RandomSpell(secret=True, card_class=CardClass.MAGE)).then(
Summon(CONTROLLER, Discover.CARD)
)
)


Expand Down
1 change: 1 addition & 0 deletions fireplace/targeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
PlayReq.REQ_TARGET_IF_AVAILABLE_AND_HAS_OVERLOADED_MANA,
PlayReq.REQ_TARGET_IF_AVAILABLE_AND_DRAWN_THIS_TURN,
PlayReq.REQ_TARGET_IF_AVAILABLE_AND_NOT_DRAWN_THIS_TURN,
PlayReq.REQ_DRAG_TO_PLAY_PRE29933,
# PlayReq.REQ_TARGET_IF_AVAILABLE_AND_PLAYER_HEALTH_CHANGED_THIS_TURN,
# PlayReq.REQ_TARGET_IF_AVAILABLE_AND_SOUL_FRAGMENT_IN_DECK,
# PlayReq.REQ_TARGET_IF_AVAILABLE_AND_BOUGHT_RACE_THIS_TURN,
Expand Down
3 changes: 2 additions & 1 deletion fireplace/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ def play_turn(game):
card = random.choice(card.choose_cards)
if not card.is_playable():
continue
print("Playing %r" % card)
if card.requires_target():
target = random.choice(card.targets)
print("Playing %r on %r" % (card, target))
print("Target on %r" % target)
card.play(target=target)

while player.choice:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_boomsday.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,8 @@ def test_holomancer():
def test_flarks_boom_zooka():
game = prepare_game()
game.player1.give("BOT_429").play()


def test_zereks_cloning_gallery_when_empty():
game = prepare_empty_game()
game.player1.give("BOT_567").play()
11 changes: 11 additions & 0 deletions tests/test_icecrown.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,14 @@ def test_phantom_freebooter():
freebooter.play()
assert freebooter.atk == atk + weapon.atk
assert freebooter.health == health + weapon.durability


def test_plague_scientist():
game = prepare_game()
game.player1.give(MOONFIRE).play(target=game.player2.hero)
scientist = game.player1.give("ICC_809")
assert not scientist.requires_target()
assert not scientist.targets
wisp = game.player1.give(WISP).play()
assert scientist.requires_target()
assert scientist.targets == [wisp]
8 changes: 8 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,11 @@ def test_copy_voljin():
voljin_copy = game.player2.field[0]
assert voljin_copy.atk == voljin.atk
assert voljin_copy.health == voljin.health


def test_lifesteal_and_auchenai():
game = prepare_game()
game.player1.give("EX1_591").play()
game.player1.give("TRL_512").play(target=game.player2.hero)
assert game.player1.hero.health == 29
assert game.player2.hero.health == 29
20 changes: 20 additions & 0 deletions tests/test_witchwood.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,23 @@ def test_shudderwock():
shudderwock = game.player1.give("GIL_820")
shudderwock.play()
assert len(game.player1.hand) == hand + 2


def test_lady_in_white():
game = prepare_game()
game.player1.give("GIL_840").play()
for card in game.player1.deck:
if card.type == CardType.MINION:
assert card.atk == card.health


def test_murkspark_eel():
game = prepare_game()
eel = game.player1.give("GIL_530")
assert not eel.requires_target()
eel.play()

game = prepare_empty_game()
eel = game.player1.give("GIL_530")
assert eel.requires_target()
eel.play(target=game.player2.hero)

0 comments on commit d9fbed9

Please sign in to comment.