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

Update some card implementations #505

Merged
merged 1 commit into from
Dec 14, 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
41 changes: 4 additions & 37 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ def trigger(self, source):
times = times.evaluate(source)
elif isinstance(times, Action):
times = times.trigger(source)[0]
elif isinstance(times, Selector):
times = times.eval(source.game, source)

for i in range(times):
ret += self._trigger(i, source)
Expand Down Expand Up @@ -1409,24 +1411,6 @@ def do(self, source, card):
card.zone = old_zone


class SwapHealth(TargetedAction):
"""
Swap health between two minions using \a buff.
"""
TARGET = ActionArg()
OTHER = ActionArg()
BUFF = ActionArg()

def do(self, source, target, other, buff):
other = other[0]
buff1 = source.controller.card(buff)
buff1.health = other.health
buff2 = source.controller.card(buff)
buff2.health = target.health
buff1.apply(target)
buff2.apply(other)


class Steal(TargetedAction):
"""
Make the controller take control of targets.
Expand Down Expand Up @@ -1598,34 +1582,17 @@ def do(self, source, target, other, buff):
log.info("swap state %s and %s", target, other)
other = other[0]
buff1 = source.controller.card(buff)
buff1.source = source
buff1._xatk = other.atk
buff1._xhealth = other.health
buff2 = source.controller.card(buff)
buff2.source = source
buff2._xatk = target.atk
buff2._xhealth = target.health
buff1.apply(target)
buff2.apply(other)


class SwapAtk(TargetedAction):
"""
Swap atk between two minions using \a buff.
"""
TARGET = ActionArg()
OTHER = ActionArg()
BUFF = ActionArg()

def do(self, source, target, other, buff):
log.info("swap atk %s and %s", target, other)
other = other[0]
buff1 = source.controller.card(buff)
buff1._xatk = other.atk
buff2 = source.controller.card(buff)
buff2._xatk = target.atk
buff1.apply(target)
buff2.apply(other)


class CopyState(TargetedAction):
"""
Copy target state, buff on self
Expand Down
9 changes: 8 additions & 1 deletion fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@ def shuffle_into_deck(self):
"""
return self.game.cheat_action(self, [actions.Shuffle(self.controller, self)])

def put_on_top(self):
"""
Put the card into the controller's deck top
"""
return self.game.cheat_action(self, [actions.PutOnTop(self.controller, self)])

def battlecry_requires_target(self):
"""
True if the play action of the card requires a target
Expand Down Expand Up @@ -600,7 +606,7 @@ class Character(LiveEntity):
cant_be_targeted_by_op_hero_powers = boolean_property("cant_be_targeted_by_op_hero_powers")

heavily_armored = boolean_property("heavily_armored")
min_health = boolean_property("min_health")
min_health = int_property("min_health")
rush = boolean_property("rush")
taunt = boolean_property("taunt")
poisonous = boolean_property("poisonous")
Expand Down Expand Up @@ -999,6 +1005,7 @@ class Enchantment(BaseCard):
incoming_damage_multiplier = int_property("incoming_damage_multiplier")
max_health = int_property("max_health")
spellpower = int_property("spellpower")
min_health = int_property("min_health")

buffs = []
slots = []
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/classic/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ class EX1_275:

class EX1_277:
"""Arcane Missiles"""
def play(self):
count = self.controller.get_spell_damage(3)
yield Hit(RANDOM_ENEMY_CHARACTER, 1) * count
play = Hit(RANDOM_ENEMY_CHARACTER, 1) * SPELL_DAMAGE(3)


class EX1_279:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/classic/paladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ class EX1_371:

class EX1_384:
"""Avenging Wrath"""
def play(self):
count = self.controller.get_spell_damage(8)
yield Hit(RANDOM_ENEMY_CHARACTER, 1) * count
play = Hit(RANDOM_ENEMY_CHARACTER, 1) * SPELL_DAMAGE(8)


class EX1_619:
Expand Down
23 changes: 6 additions & 17 deletions fireplace/cards/gangs/neutral_legendary.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ class CFM_672:
PlayReq.REQ_MINION_TARGET: 0,
PlayReq.REQ_TARGET_IF_AVAILABLE: 0}

def play(self):
targets = self.controller.deck.filter(type=CardType.MINION)
if targets:
target = random.choice(targets)
target.zone = Zone.SETASIDE
yield Shuffle(CONTROLLER, TARGET)
yield Summon(CONTROLLER, target)
play = Swap(TARGET, RANDOM(FRIENDLY_DECK + MINION))


class CFM_685:
Expand All @@ -65,16 +59,11 @@ class CFM_685:

class CFM_806:
"""Wrathion"""
def play(self):
while True:
current_handsize = len(self.controller.hand)
yield Draw(self.controller)
if len(self.controller.hand) == current_handsize:
# Unable to draw card due to fatigue or max hand size
break
card = self.controller.hand[-1]
if card.type != CardType.MINION or card.race != Race.DRAGON:
break
play = Draw(CONTROLLER).then(
Find(Draw.CARD + DRAGON) | (
Find(LazyValueSelector(Draw.CARD)) & Battlecry(SELF, None)
)
)


class CFM_807:
Expand Down
6 changes: 1 addition & 5 deletions fireplace/cards/gangs/priest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ class CFM_020e:
class CFM_605:
"""Drakonid Operative"""
powered_up = HOLDING_DRAGON

def play(self):
decklist = [i.id for i in self.controller.opponent.deck]
if decklist:
yield HOLDING_DRAGON & DISCOVER(RandomID(*decklist))
play = powered_up & GenericChoice(CONTROLLER, Copy(RANDOM(DeDuplicate(ENEMY_DECK)) * 3))


class CFM_606:
Expand Down
4 changes: 2 additions & 2 deletions fireplace/cards/gvg/priest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class GVG_011:
class GVG_014:
"""Vol'jin"""
requirements = {PlayReq.REQ_MINION_TARGET: 0, PlayReq.REQ_TARGET_IF_AVAILABLE: 0}
play = SwapHealth(SELF, TARGET, "GVG_014a")
play = SwapState(SELF, TARGET, "GVG_014a")


class GVG_014a:
max_health = lambda self, i: self.health
max_health = lambda self, i: self._xhealth


class GVG_072:
Expand Down
11 changes: 3 additions & 8 deletions fireplace/cards/gvg/warrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@ class GVG_086:
class GVG_050:
"""Bouncing Blade"""
requirements = {PlayReq.REQ_MINIMUM_TOTAL_MINIONS: 1}

def play(self):
targets = self.game.board.filter(dead=False)
while True:
live_targets = [t for t in targets if t.health > t.min_health]
if live_targets != targets:
break
yield Hit(random.choice(targets), 1)
play = Hit(RANDOM(ALL_MINIONS - IMMUNE - (CURRENT_HEALTH == MIN_HEALTH)), 1).then(
Dead(Hit.TARGET) | CastSpell("GVG_050")
)


class GVG_052:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/kobolds/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Hand:
class LOOT_104e:
class Hand:
events = OWN_TURN_BEGIN.on(
Morph(SELF, RandomSpell(card_class=CardClass.MAGE)).then(
Morph(OWNER, RandomSpell(card_class=CardClass.MAGE)).then(
Buff(Morph.CARD, "LOOT_104e"))
)
events = REMOVED_IN_PLAY
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/kobolds/priest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LOOT_528:
"""Twilight Acolyte"""
# <b>Battlecry:</b> If you're holding a Dragon, swap this minion's Attack with another
# minion's.
play = HOLDING_DRAGON & SwapAtk(TARGET, SELF, "LOOT_528e")
play = HOLDING_DRAGON & SwapState(TARGET, SELF, "LOOT_528e")


class LOOT_528e:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/kobolds/shaman.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ class LOOT_344e:
class LOOT_373:
"""Healing Rain"""
# Restore #12 Health randomly split among all friendly characters.
def play(self):
count = self.controller.get_spell_heal(12)
yield Heal(RANDOM_FRIENDLY_CHARACTER, 1) * count
play = Heal(RANDOM_FRIENDLY_CHARACTER, 1) * SPELL_HEAL(12)


class LOOT_504:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/league/collectible.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ class LOEA16_3:

class LOEA16_4:
"""Timepiece of Horror"""
def play(self):
count = self.controller.get_spell_damage(10)
yield Hit(RANDOM_ENEMY_CHARACTER, 1) * count
play = Hit(RANDOM_ENEMY_CHARACTER, 1) * SPELL_DAMAGE(10)


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

class UNG_111:
"""Living Mana"""
def play(self):
count = min(
self.controller.max_mana,
self.game.MAX_MINIONS_ON_FIELD - len(self.controller.field)
play = (MANA(CONTROLLER) > 0) & (
FULL_BOARD | (
GainEmptyMana(CONTROLLER, -1),
Summon(CONTROLLER, "UNG_111t1"),
Battlecry(SELF, None)
)
yield GainEmptyMana(CONTROLLER, -count)
yield Summon(CONTROLLER, "UNG_111t1") * count
)


class UNG_111t1:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/ungoro/shaman.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ class UNG_938:

class UNG_025:
"""Volcano"""
def play(self):
count = self.controller.get_spell_damage(15)
yield Hit(RANDOM_MINION, 1) * count
play = Hit(RANDOM_MINION, 1) * SPELL_DAMAGE(15)


class UNG_817:
Expand Down
7 changes: 3 additions & 4 deletions fireplace/cards/wog/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

class OG_051:
"""Forbidden Ancient"""
def play(self):
mana = self.controller.mana
yield SpendMana(CONTROLLER, mana)
yield Buff(SELF, "OG_051e") * mana
play = SpendMana(CONTROLLER, CURRENT_MANA(CONTROLLER)).then(
Buff(SELF, "OG_051e") * SpendMana.AMOUNT
)


OG_051e = buff(+1, +1)
Expand Down
8 changes: 3 additions & 5 deletions fireplace/cards/wog/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class OG_090:
class OG_086:
"""Forbidden Flame"""
requirements = {PlayReq.REQ_MINION_TARGET: 0, PlayReq.REQ_TARGET_TO_PLAY: 0}

def play(self):
mana = self.controller.mana
yield SpendMana(CONTROLLER, mana)
yield Hit(TARGET, mana)
play = SpendMana(CONTROLLER, CURRENT_MANA(CONTROLLER)).then(
Hit(TARGET, SpendMana.AMOUNT)
)
3 changes: 0 additions & 3 deletions fireplace/cards/wog/neutral_epic.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class OG_102e:
atk = lambda self, i: self._xatk
max_health = lambda self, i: self._xhealth

def apply(self, target):
target.damage = 0


class OG_174:
"""Faceless Shambler"""
Expand Down
8 changes: 3 additions & 5 deletions fireplace/cards/wog/paladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class OG_222:
class OG_198:
"""Forbidden Healing"""
requirements = {PlayReq.REQ_TARGET_TO_PLAY: 0}

def play(self):
mana = self.controller.mana
yield SpendMana(CONTROLLER, mana)
yield Heal(TARGET, mana * 2)
play = SpendMana(CONTROLLER, CURRENT_MANA(CONTROLLER)).then(
Heal(TARGET, SpendMana.AMOUNT * 2)
)
7 changes: 3 additions & 4 deletions fireplace/cards/wog/priest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class OG_100:

class OG_101:
"""Forbidden Shaping"""
def play(self):
mana = self.controller.mana
yield SpendMana(CONTROLLER, mana)
yield Summon(CONTROLLER, RandomMinion(cost=mana))
play = SpendMana(CONTROLLER, CURRENT_MANA(CONTROLLER)).then(
Summon(CONTROLLER, RandomMinion(cost=SpendMana.AMOUNT))
)
8 changes: 3 additions & 5 deletions fireplace/cards/wog/warlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class OG_116:
class OG_118:
"""Renounce Darkness"""
def play(self):
import random
classes = [
(CardClass.DRUID, "CS2_017"),
(CardClass.HUNTER, "DS1h_292"),
Expand Down Expand Up @@ -85,7 +84,6 @@ def play(self):

class OG_114:
"""Forbidden Ritual"""
def play(self):
mana = self.controller.mana
yield SpendMana(CONTROLLER, mana)
yield Summon(CONTROLLER, "OG_114a") * mana
play = SpendMana(CONTROLLER, CURRENT_MANA(CONTROLLER)).then(
Summon(CONTROLLER, "OG_114a") * SpendMana.AMOUNT
)
3 changes: 3 additions & 0 deletions fireplace/dsl/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def __init__(self, *selectors):
super().__init__()
self.selectors = selectors

def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.selectors)

def check(self, source):
return all(
bool(len(selector.eval(source.game, source)))
Expand Down
Loading