Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix shudderwock bug #516

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 35 additions & 20 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,21 @@ def get_target_args(self, source, target):
arg = _eval_card(source, arg)[0]
return [arg]

def has_extra_battlecries(self, player, card):
# Brann Bronzebeard
if player.extra_battlecries and card.has_battlecry:
return True

# Spirit of the Shark
if card.type == CardType.MINION:
if player.minion_extra_combos and card.has_combo and player.combo:
return True
if player.minion_extra_battlecries and card.has_battlecry:
return True

return False

def do(self, source, card, target=None):
if source.type == CardType.MINION and (
source.dead or source.silenced or source.zone != Zone.PLAY
):
return
player = source.controller

if card.has_combo and player.combo:
Expand All @@ -922,35 +932,40 @@ def do(self, source, card, target=None):
log.info("Activating %r action targeting %r", card, target)
actions = card.get_actions("play")

if card.requires_target() and target is None:
if len(card.targets):
target = random.choice(card.targets)
else:
log.info("%s battlecry %s don't have a legal target", source, card)
return

if card.battlecry_requires_target() and not target:
log.info("%r requires a target for its battlecry. Will not trigger.")
return

source.target = target
source.game.main_power(source, actions, target)

if (
player.minion_extra_combos and card.type == CardType.MINION and
card.has_combo and player.combo
) or (
player.extra_battlecries and card.has_battlecry
) or (
player.minion_extra_battlecries and card.type == CardType.MINION and
card.has_battlecry
):
if self.has_extra_battlecries(player, card):
source.game.main_power(source, actions, target)

if card.overload:
source.game.queue_actions(card, [Overload(player, card.overload)])


class ExtraBattlecry(Battlecry):
def has_extra_battlecries(self, player, card):
return False

def do(self, source, card, target=None):
if source.type == CardType.MINION and (
source.dead or source.silenced or source.zone != Zone.PLAY
):
return

if target is None:
old_requirements = source.requirements
source.requirements = card.requirements
if source.requires_target():
target = random.choice(source.play_targets)
source.requirements = old_requirements

return super().do(source, card, target)


class PlayHeroPower(TargetedAction):
HERO_POWER = CardArg()
TARGET = ActionArg()
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/gangs/neutral_legendary.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CFM_806:
"""Wrathion"""
play = Draw(CONTROLLER).then(
Find(Draw.CARD + DRAGON) | (
Find(LazyValueSelector(Draw.CARD)) & Battlecry(SELF, None)
Find(LazyValueSelector(Draw.CARD)) & ExtraBattlecry(SELF, None)
)
)

Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/gangs/neutral_rare.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CFM_668:
# Whichever Doppelgangster is played (either the original card or one of the
# uncollectible cards), its Battlecry will summon copies of the two other versions,
# meaning all three versions will always be summoned.[1]
play = Summon(CONTROLLER, ExactCopy(SELF)) * 2
play = SummonBothSides(CONTROLLER, ExactCopy(SELF)) * 2


class CFM_688:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/troll/warrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TRL_321:
class TRL_324:
"""Heavy Metal!"""
# [x]Summon a random minion with Cost equal to your Armor <i>(up to 10).</i>
play = Summon(CONTROLLER, RandomMinion(cost=Max(ARMOR(FRIENDLY_HERO), 10)))
play = Summon(CONTROLLER, RandomMinion(cost=Min(ARMOR(FRIENDLY_HERO), 10)))


class TRL_362:
Expand Down
4 changes: 3 additions & 1 deletion fireplace/cards/witchwood/shaman.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class GIL_820:
"""Shudderwock"""
# [x]<b>Battlecry:</b> Repeat all other <b>Battlecries</b> from cards you played this
# game <i>(targets chosen randomly)</i>.
play = Battlecry(RANDOM(CARDS_PLAYED_THIS_GAME + BATTLECRY - ID("GIL_820")) * 30, None)
play = ExtraBattlecry(
RANDOM(CARDS_PLAYED_THIS_GAME + BATTLECRY - ID("GIL_820")) * 30,
None)


##
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/witchwood/warlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class GIL_825:
play = Hit(ALL_MINIONS - SELF, 2), Dead(ALL_MINIONS) & (
Deaths(),
AddProgress(SELF, None),
FINISH_PROGRESS | Battlecry(SELF, None)
FINISH_PROGRESS | ExtraBattlecry(SELF, None)
)


Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/wog/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OG_313:

class OG_188:
"""Klaxxi Amber-Weaver"""
play = CHECK_CTHUN & Buff(SELF, "OG_188")
play = CHECK_CTHUN & Buff(SELF, "OG_188e")


OG_188e = buff(health=4)
Expand Down
29 changes: 28 additions & 1 deletion tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_nefarian_and_ragnaros_hero():
assert game.player1.hand[0].id == "BRM_030t"


def test_lilian_voss_andragnaros_hero():
def test_lilian_voss_and_ragnaros_hero():
game = prepare_empty_game()
game.end_turn()
game.player2.give("BRM_027").play().destroy()
Expand All @@ -128,3 +128,30 @@ def test_lilian_voss_andragnaros_hero():
assert len(game.player1.hand) == 2
assert game.player1.hand[0].id == MOONFIRE
assert game.player1.hand[0].id == MOONFIRE


def test_darkspeaker_and_shudderwock():
game = prepare_game()
darkspeaker = game.player1.give("OG_102").play()
game.skip_turn()
shudderwock = game.player1.give("GIL_820")
darkspeaker_atk = darkspeaker.atk
darkspeaker_health = darkspeaker.health
shudder_atk = shudderwock.atk
shudder_health = shudderwock.health
shudderwock.play()
assert darkspeaker.atk == shudder_atk
assert darkspeaker.health == shudder_health
assert shudderwock.atk == darkspeaker_atk
assert shudderwock.health == darkspeaker_health


def test_doppelgangster_and_shudderwock():
game = prepare_game()
doppelgangster = game.player1.give("CFM_668").play()
game.skip_turn()
shudderwock = game.player1.give("GIL_820").play()
for i in range(0, 3):
assert game.player1.field[i].id == doppelgangster.id
for i in range(3, 6):
assert game.player1.field[i].id == shudderwock.id
12 changes: 12 additions & 0 deletions tests/test_troll.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,15 @@ def test_mojomaster_zihi():
assert game3.player2.max_mana == 5
assert game3.player1.mana == 10 - zihi.cost
assert game3.player2.mana == 0


def test_heavy_metal():
game = prepare_game()
game.player1.give("TRL_324").play()
assert game.player1.field[0].cost == 0
game.skip_turn()
game.player1.give("LOOT_285t").play()
game.skip_turn()
assert game.player1.hero.armor == 15
game.player1.give("TRL_324").play()
assert game.player1.field[1].cost == 10