Permalink
Browse files

Make slots non-dynamic, add to them whenever buffing/enraging

  • Loading branch information...
jleclanche committed Sep 2, 2015
1 parent 34fdc17 commit cfb0ead04e40dc06641e328a99b4aa546f0950ea
Showing with 15 additions and 21 deletions.
  1. +14 −17 fireplace/card.py
  2. +1 −4 fireplace/player.py
@@ -38,6 +38,7 @@ class BaseCard(Entity):
def __init__(self, id, data):
self.data = data
super().__init__()
self.slots = []
self.auras = []
self.requirements = data.requirements.copy()
self.id = id
@@ -171,10 +172,6 @@ def powered_up(self):
def entities(self):
return chain([self], self.buffs)

@property
def slots(self):
return self.buffs

def _set_zone(self, zone):
old_zone = self.zone
super()._set_zone(zone)
@@ -357,6 +354,7 @@ def __init__(self, *args):
self.cant_be_targeted_by_hero_powers = False
self.num_attacks = 0
self.race = Race.INVALID
self._enrage = None
super().__init__(*args)

@property
@@ -431,14 +429,23 @@ def damage(self):
@damage.setter
def damage(self, amount):
amount = max(0, amount)
dmg = self.damage

if self.min_health:
self.log("%r has HEALTH_MINIMUM of %i", self, self.min_health)
amount = min(amount, self.max_health - self.min_health)

self._damage = amount

if self.enraged:
if not self._enrage:
self.log("Enraging %r", self)
self._enrage = Enrage(self.data.enrage_tags)
self.slots.append(self._enrage)
elif self._enrage:
self.log("Enrage fades from %r", self)
self.slots.remove(self._enrage)
self._enrage = None

@property
def enraged(self):
return False
@@ -523,7 +530,6 @@ class Minion(Character):
)

def __init__(self, id, data):
self._enrage = None
self.always_wins_brawls = False
self.divine_shield = False
self.enrage = False
@@ -566,15 +572,6 @@ def exhausted(self):
return True
return super().exhausted

@property
def slots(self):
slots = super().slots[:]
if self.enraged:
if not self._enrage:
self._enrage = Enrage(self.data.enrage_tags)
slots.append(self._enrage)
return slots

@property
def enraged(self):
return self.enrage and self.damage
@@ -676,8 +673,6 @@ def reveal(self):


class Enchantment(BaseCard):
slots = []

def __init__(self, *args):
self.aura_source = None
self.one_turn_effect = False
@@ -695,8 +690,10 @@ def _getattr(self, attr, i):
def _set_zone(self, zone):
if zone == Zone.PLAY:
self.owner.buffs.append(self)
self.owner.slots.append(self)
elif zone == Zone.REMOVEDFROMGAME:
self.owner.buffs.remove(self)
self.owner.slots.remove(self)
super()._set_zone(zone)

def apply(self, target):
@@ -30,6 +30,7 @@ def __init__(self, name):
self.graveyard = CardList()
self.secrets = CardList()
self.buffs = []
self.slots = []
self.choice = None
self.start_hand_size = 4
self.max_hand_size = 10
@@ -63,10 +64,6 @@ def current_player(self):
def controller(self):
return self

@property
def slots(self):
return self.buffs

@property
def mana(self):
mana = max(0, self.max_mana - self.used_mana - self.overload_locked) + self.temp_mana

0 comments on commit cfb0ead

Please sign in to comment.