Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make slots non-dynamic, add to them whenever buffing/enraging
  • Loading branch information
jleclanche committed Sep 2, 2015
1 parent 34fdc17 commit cfb0ead
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
31 changes: 14 additions & 17 deletions fireplace/card.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -676,8 +673,6 @@ def reveal(self):


class Enchantment(BaseCard):
slots = []

def __init__(self, *args):
self.aura_source = None
self.one_turn_effect = False
Expand All @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions fireplace/player.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cfb0ead

Please sign in to comment.