Skip to content

Commit 8739d86

Browse files
committed
Replace PowerUpRequirements by a proper powered_up script system
Fixes #154
1 parent a979aee commit 8739d86

File tree

9 files changed

+13
-47
lines changed

9 files changed

+13
-47
lines changed

fireplace/card.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,10 @@ def deathrattles(self):
151151
def powered_up(self):
152152
"""
153153
Returns True whether the card is "powered up".
154-
Currently, this only applies to some cards which require a minion with a
155-
specific race on the field.
156154
"""
157-
for req in self.data.powerup_requirements:
158-
for minion in self.controller.field:
159-
if minion.race == req:
160-
return True
155+
script = getattr(self.data.scripts, "powered_up", None)
156+
if script:
157+
return script.evaluate(self)
161158
return False
162159

163160
@property

fireplace/cards/classic/hunter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CS2_237:
2323

2424
# Houndmaster
2525
class DS1_070:
26+
powered_up = Find(FRIENDLY_MINIONS + BEAST)
2627
play = Buff(TARGET, "DS1_070o")
2728

2829

@@ -84,7 +85,8 @@ class EX1_538:
8485

8586
# Kill Command
8687
class EX1_539:
87-
play = Find(FRIENDLY_MINIONS + BEAST) & Hit(TARGET, 5) | Hit(TARGET, 3)
88+
powered_up = Find(FRIENDLY_MINIONS + BEAST)
89+
play = powered_up & Hit(TARGET, 5) | Hit(TARGET, 3)
8890

8991

9092
# Flare

fireplace/cards/data/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import chooseone
1111
import enrage
1212
import missing_cards
13-
import powerups
1413

1514

1615
italicize = [
@@ -45,14 +44,6 @@ def add_hero_power(card, id):
4544
print("%s: Adding hero power %r" % (card, id))
4645

4746

48-
def add_powerup_requirements(card, race):
49-
req = ElementTree.Element("PowerUpRequirement")
50-
req.attrib["reqID"] = "1"
51-
req.attrib["param"] = str(int(race))
52-
card.xml.append(req)
53-
print("%s: Adding POWERED_UP definition of %r" % (card.name, race))
54-
55-
5647
def fix_entourage(card, guids):
5748
for entourage in card.xml.findall("EntourageCard"):
5849
guid = entourage.attrib["cardID"]
@@ -180,9 +171,6 @@ def main():
180171
if id in hero_powers:
181172
add_hero_power(card, hero_powers[id])
182173

183-
if hasattr(powerups, id):
184-
add_powerup_requirements(card, getattr(powerups, id))
185-
186174
if re.match(r"^PART_\d+$", id):
187175
# Hearthstone uses entourage data to identify Spare Parts
188176
# We're better than that.

fireplace/cards/data/powerups.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

fireplace/cards/gvg/druid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class GVG_035:
3434

3535
# Druid of the Fang
3636
class GVG_080:
37-
play = Find(FRIENDLY_MINIONS + BEAST) & Morph(SELF, "GVG_080t")
37+
powered_up = Find(FRIENDLY_MINIONS + BEAST)
38+
play = powered_up & Morph(SELF, "GVG_080t")
3839

3940

4041
##

fireplace/cards/gvg/mage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class GVG_002:
1313

1414
# Goblin Blastmage
1515
class GVG_004:
16-
play = Find(FRIENDLY_MINIONS + MECH) & Hit(RANDOM_ENEMY_CHARACTER, 1) * 4
16+
powered_up = Find(FRIENDLY_MINIONS + MECH)
17+
play = powered_up & Hit(RANDOM_ENEMY_CHARACTER, 1) * 4
1718

1819

1920
# Flame Leviathan

fireplace/cards/gvg/neutral_common.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ class GVG_096:
6161

6262
# Tinkertown Technician
6363
class GVG_102:
64-
play = (Find(FRIENDLY_MINIONS + MECH) & (
65-
Buff(SELF, "GVG_102e"), Give(CONTROLLER, RandomSparePart())
66-
))
64+
powered_up = Find(FRIENDLY_MINIONS + MECH)
65+
play = powered_up & (Buff(SELF, "GVG_102e"), Give(CONTROLLER, RandomSparePart()))
6766

6867

6968
# Micro Machine

fireplace/cards/gvg/warrior.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class GVG_053:
1111

1212
# Screwjank Clunker
1313
class GVG_055:
14+
powered_up = Find(FRIENDLY_MINIONS + MECH)
1415
play = Buff(TARGET, "GVG_055e")
1516

1617

fireplace/cardxml.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ def __init__(self, xml):
1616
e = self.xml.findall("Power[PlayRequirement]/PlayRequirement")
1717
self.requirements = self._getRequirements(e)
1818

19-
e = self.xml.findall("PowerUpRequirement")
20-
self.powerup_requirements = [Race(int(tag.attrib["param"])) for tag in e]
21-
2219
e = self.xml.findall("./EnrageDefinition/Tag")
2320
self.enrage_tags = {
2421
GameTag(int(tag.attrib["enumID"])): self._get_tag(tag) for tag in e

0 commit comments

Comments
 (0)