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

8.4.0.20022 #493

Merged
merged 4 commits into from
Nov 29, 2023
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
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include fireplace/cards/CardDefs.xml
include fireplace/cards/CardDefs.xml
19 changes: 14 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 @@ -813,6 +813,8 @@ def get_target_args(self, source, target):
arg = arg.eval(source.game, source)
assert len(arg) == 1
arg = arg[0]
elif isinstance(arg, LazyValue):
arg = arg.evaluate(source)[0]
return [arg]

def do(self, source, card, target):
Expand Down Expand Up @@ -906,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 @@ -1401,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 @@ -1412,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 @@ -1428,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 @@ -1448,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
11 changes: 6 additions & 5 deletions fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def play(self, *args):

def add_progress(self, card):
if self.data.scripts.add_progress:
return self.data.scripts.add_progress(card)
return self.data.scripts.add_progress(self, card)
self.progress += 1

@property
Expand Down Expand Up @@ -319,7 +319,11 @@ def destroy(self):
def discard(self):
self.log("Discarding %r" % self)
self.tags[enums.DISCARDED] = True
old_zone = self.zone
self.zone = Zone.GRAVEYARD
if old_zone == Zone.HAND:
actions = self.get_actions("discard")
self.game.trigger(self, actions, event_args=None)

def draw(self):
if len(self.controller.hand) >= self.controller.max_hand_size:
Expand Down Expand Up @@ -874,9 +878,6 @@ def get_damage(self, amount, target):
amount *= 2
return amount

def play(self, target=None, index=None, choose=None):
return super().play(target, index, choose)

def _set_zone(self, value):
if value == Zone.PLAY:
value = Zone.GRAVEYARD
Expand Down Expand Up @@ -935,7 +936,7 @@ def _set_zone(self, value):
@property
def events(self):
ret = super().events
if self.zone == Zone.SECRET and not self.exhausted:
if self.zone == Zone.SECRET:
ret += self.data.scripts.quest
return ret

Expand Down
8 changes: 6 additions & 2 deletions fireplace/cards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def merge(id, card, cardscript=None):
scriptnames = (
"activate", "combo", "deathrattle", "draw", "inspire", "play",
"enrage", "update", "powered_up", "outcast", "awaken", "reward",
"add_progress"
"add_progress", "discard"
)

for script in scriptnames:
Expand All @@ -48,7 +48,7 @@ def merge(id, card, cardscript=None):
# Ensure the actions are always iterable
setattr(card.scripts, script, (actions, ))

for script in ("events", "secret"):
for script in ("events", "secret", "quest"):
events = getattr(card.scripts, script, None)
if events is None:
setattr(card.scripts, script, [])
Expand Down Expand Up @@ -161,6 +161,10 @@ def filter(self, **kwargs):
if "type" not in kwargs:
kwargs["type"] = [CardType.SPELL, CardType.WEAPON, CardType.MINION]

if "exclude" in kwargs:
exclude = [card.id for card in kwargs.pop("exclude")]
cards = [card for card in cards if card.id not in exclude]

for attr, value in kwargs.items():
if value is not None:
# What? this doesn't work?
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
17 changes: 5 additions & 12 deletions fireplace/cards/karazhan/collectible.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,13 @@ class KAR_095:

class KAR_096:
"""Prince Malchezaar"""
# TODO
# At the start of the game, if the player has Prince Malchezaar in their deck,
# he will add 5 random collectible legendary cards to the player's deck.
#
# While the selection is random, only cards suitable for the player's class will be chosen,
# and he will not cause there to be more than 1 copy of any given legendary in the deck,
# thus abiding by the game's regular deck-building rules.[1]

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

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


class KAR_097:
Expand Down Expand Up @@ -221,8 +215,7 @@ class KAR_204:

class KAR_205:
"""Silverware Golem"""
class Hand:
events = Discard(SELF).on(Summon(CONTROLLER, "KAR_205"))
discard = Summon(CONTROLLER, Copy(SELF))


class KAR_702:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/tgt/warlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ class AT_027e:
class AT_022:
"""Fist of Jaraxxus"""
play = Hit(RANDOM_ENEMY_CHARACTER, 4)

class Hand:
events = Discard(SELF).on(Hit(RANDOM_ENEMY_CHARACTER, 4))
discard = Hit(RANDOM_ENEMY_CHARACTER, 4)


class AT_024:
Expand Down
6 changes: 3 additions & 3 deletions fireplace/cards/ungoro/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ class UNG_108:

class UNG_111:
"""Living Mana"""
# TODO: need test
def play(self):
count = min(
self.controller.max_mana,
self.game.MAX_MINIONS_ON_FIELD - len(self.controller.field)
)
yield GainMana(CONTROLLER, -count), Summon(CONTROLLER, "UNG_111t1") * count
yield GainEmptyMana(CONTROLLER, -count)
yield Summon(CONTROLLER, "UNG_111t1") * count


class UNG_111t1:
deathrattle = GainMana(CONTROLLER, -1)
deathrattle = GainEmptyMana(CONTROLLER, 1)


class UNG_116:
Expand Down
8 changes: 4 additions & 4 deletions fireplace/cards/ungoro/hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class UNG_915:

class UNG_919:
"""Swamp King Dred"""
# TODO: need test
events = Play(OPPONENT, MINION).after(
Find(Play.CARD + IN_PLAY - MORTALLY_WOUNDED) &
Find(SELF - FROZEN) &
Attack(SELF, Play.CARD)
Find(Play.CARD + IN_PLAY - MORTALLY_WOUNDED) & (
Find(SELF - FROZEN) &
Attack(SELF, Play.CARD)
)
)


Expand Down
6 changes: 2 additions & 4 deletions fireplace/cards/ungoro/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class UNG_024e:

class UNG_028:
"""Open the Waygate"""
# TODO: need test
progress_total = 6
quest = Play(CONTROLLER, SPELL - STARTING_DECK).after(AddProgress(SELF, Play.CARD))
reward = Give(CONTROLLER, "UNG_028t")
Expand All @@ -67,9 +66,8 @@ class UNG_028t:


class UNG_028e:
tags = {
GameTag.EXTRA_TURNS_TAKEN_THIS_GAME: 1
}
def apply(self, target):
target.extra_turns += 1


class UNG_941:
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)))
9 changes: 5 additions & 4 deletions fireplace/cards/ungoro/neutral_legendary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ class UNG_840:

class UNG_843:
"""The Voraxx"""
# TODO: need test
events = Play(CONTROLLER, SPELL).after(
Summon(CONTROLLER, "UNG_999t2t1").then(
Battlecry(Play.CARD, Summon.CARD)
events = Play(CONTROLLER, SPELL, SELF).after(
lambda source, player, spell, target: (
Summon(CONTROLLER, "UNG_999t2t1").then(
Battlecry(spell, Summon.CARD)
),
)
)

Expand Down
2 changes: 0 additions & 2 deletions fireplace/cards/ungoro/priest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class UNG_963:

class UNG_029:
"""Shadow Visions"""
# TODO: need test
play = GenericChoice(CONTROLLER, Copy(RANDOM(DeDuplicate(FRIENDLY_DECK)) * 3))


Expand All @@ -78,7 +77,6 @@ class UNG_854:

class UNG_940:
"""Awaken the Makers"""
# TODO: need test
progress_total = 7
quest = Summon(CONTROLLER, DEATHRATTLE).after(AddProgress(SELF, Summon.CARD))
reward = Give(CONTROLLER, "UNG_940t8")
Expand Down
13 changes: 11 additions & 2 deletions fireplace/cards/ungoro/rogue.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections import defaultdict

from ..utils import *


Expand Down Expand Up @@ -60,12 +62,19 @@ class UNG_060:
class UNG_067:
"""The Caverns Below"""
progress_total = 5
quest = Play(CONTROLLER, MINION).after(AddProgress(SELF, Play.CARD))
reward = Give(CONTROLLER, "UNG_067t1")

def add_progress(self, card):
if not hasattr(self, "card_name_counter"):
self.card_name_counter = dict()
self.card_name_counter[card.data.name] += 1
self.card_name_counter = defaultdict(int)
# 炉石简中汉化组一点都不用心
# 存在部分英文同名但简中不同名的现象
# * NEW1_040t: Gnoll 豺狼人
# * OG_318t: Gnoll 腐化豺狼人
# * TU4a_003: Gnoll 豺狼人
name = card.data.strings[GameTag.CARDNAME]["enUS"]
self.card_name_counter[name] += 1


class UNG_067t1:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/ungoro/shaman.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class UNG_817:
class UNG_942:
"""Unite the Murlocs"""
progress_total = 10
quest = Summon(CONTROLLER, MURLOC).after(AddProgress(SELF))
quest = Summon(CONTROLLER, MURLOC).after(AddProgress(SELF, Play.CARD))
reward = Give(CONTROLLER, "UNG_942t")


Expand Down
9 changes: 2 additions & 7 deletions fireplace/cards/ungoro/warlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ class UNG_835:

class UNG_836:
"""Clutchmother Zavas"""
# TODO: need test
class Hand:
events = Discard(SELF).on(
Give(CONTROLLER, SELF),
Buff(SELF, "UNG_836e")
)
discard = Give(CONTROLLER, SELF), Buff(SELF, "UNG_836e")


UNG_836e = buff(+2, +2)
Expand All @@ -51,7 +46,7 @@ class Hand:
class UNG_829:
"""Lakkari Sacrifice"""
progress_total = 6
quest = Discard(FRIENDLY).after(AddProgress(SELF))
quest = Discard(FRIENDLY).after(AddProgress(SELF, Discard.TARGET))
reward = Give(CONTROLLER, "UNG_829t1")


Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/ungoro/warrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class UNG_927:
class UNG_934:
"""Fire Plume's Heart"""
progress_total = 7
quest = Play(CONTROLLER, TAUNT).after(AddProgress(SELF))
quest = Play(CONTROLLER, TAUNT).after(AddProgress(SELF, Play.CARD))
reward = Give(CONTROLLER, "UNG_934t1")


Expand Down
1 change: 0 additions & 1 deletion fireplace/cards/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
TIMES_SECRETS_PLAYED_THIS_GAME = Count(CARDS_PLAYED_THIS_GAME + SECRET)

DISCOVER = lambda *args: Discover(CONTROLLER, *args).then(Give(CONTROLLER, Discover.CARD))
STARTING_DECK = Attr(CONTROLLER, "starting_deck")

BASIC_HERO_POWERS = [
"CS2_017", "DS1h_292", "CS2_034",
Expand Down
Loading