Skip to content

Commit

Permalink
Replace PowerUpRequirements by a proper powered_up script system
Browse files Browse the repository at this point in the history
Fixes #154
  • Loading branch information
jleclanche committed Sep 9, 2015
1 parent a979aee commit 8739d86
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 47 deletions.
9 changes: 3 additions & 6 deletions fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,10 @@ def deathrattles(self):
def powered_up(self):
"""
Returns True whether the card is "powered up".
Currently, this only applies to some cards which require a minion with a
specific race on the field.
"""
for req in self.data.powerup_requirements:
for minion in self.controller.field:
if minion.race == req:
return True
script = getattr(self.data.scripts, "powered_up", None)
if script:
return script.evaluate(self)
return False

@property
Expand Down
4 changes: 3 additions & 1 deletion fireplace/cards/classic/hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CS2_237:

# Houndmaster
class DS1_070:
powered_up = Find(FRIENDLY_MINIONS + BEAST)
play = Buff(TARGET, "DS1_070o")


Expand Down Expand Up @@ -84,7 +85,8 @@ class EX1_538:

# Kill Command
class EX1_539:
play = Find(FRIENDLY_MINIONS + BEAST) & Hit(TARGET, 5) | Hit(TARGET, 3)
powered_up = Find(FRIENDLY_MINIONS + BEAST)
play = powered_up & Hit(TARGET, 5) | Hit(TARGET, 3)


# Flare
Expand Down
12 changes: 0 additions & 12 deletions fireplace/cards/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import chooseone
import enrage
import missing_cards
import powerups


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


def add_powerup_requirements(card, race):
req = ElementTree.Element("PowerUpRequirement")
req.attrib["reqID"] = "1"
req.attrib["param"] = str(int(race))
card.xml.append(req)
print("%s: Adding POWERED_UP definition of %r" % (card.name, race))


def fix_entourage(card, guids):
for entourage in card.xml.findall("EntourageCard"):
guid = entourage.attrib["cardID"]
Expand Down Expand Up @@ -180,9 +171,6 @@ def main():
if id in hero_powers:
add_hero_power(card, hero_powers[id])

if hasattr(powerups, id):
add_powerup_requirements(card, getattr(powerups, id))

if re.match(r"^PART_\d+$", id):
# Hearthstone uses entourage data to identify Spare Parts
# We're better than that.
Expand Down
20 changes: 0 additions & 20 deletions fireplace/cards/data/powerups.py

This file was deleted.

3 changes: 2 additions & 1 deletion fireplace/cards/gvg/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class GVG_035:

# Druid of the Fang
class GVG_080:
play = Find(FRIENDLY_MINIONS + BEAST) & Morph(SELF, "GVG_080t")
powered_up = Find(FRIENDLY_MINIONS + BEAST)
play = powered_up & Morph(SELF, "GVG_080t")


##
Expand Down
3 changes: 2 additions & 1 deletion fireplace/cards/gvg/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class GVG_002:

# Goblin Blastmage
class GVG_004:
play = Find(FRIENDLY_MINIONS + MECH) & Hit(RANDOM_ENEMY_CHARACTER, 1) * 4
powered_up = Find(FRIENDLY_MINIONS + MECH)
play = powered_up & Hit(RANDOM_ENEMY_CHARACTER, 1) * 4


# Flame Leviathan
Expand Down
5 changes: 2 additions & 3 deletions fireplace/cards/gvg/neutral_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ class GVG_096:

# Tinkertown Technician
class GVG_102:
play = (Find(FRIENDLY_MINIONS + MECH) & (
Buff(SELF, "GVG_102e"), Give(CONTROLLER, RandomSparePart())
))
powered_up = Find(FRIENDLY_MINIONS + MECH)
play = powered_up & (Buff(SELF, "GVG_102e"), Give(CONTROLLER, RandomSparePart()))


# Micro Machine
Expand Down
1 change: 1 addition & 0 deletions fireplace/cards/gvg/warrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GVG_053:

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


Expand Down
3 changes: 0 additions & 3 deletions fireplace/cardxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ def __init__(self, xml):
e = self.xml.findall("Power[PlayRequirement]/PlayRequirement")
self.requirements = self._getRequirements(e)

e = self.xml.findall("PowerUpRequirement")
self.powerup_requirements = [Race(int(tag.attrib["param"])) for tag in e]

e = self.xml.findall("./EnrageDefinition/Tag")
self.enrage_tags = {
GameTag(int(tag.attrib["enumID"])): self._get_tag(tag) for tag in e
Expand Down

0 comments on commit 8739d86

Please sign in to comment.