Added code to represent minions, and to kill multiple minions with one command.

This commit is contained in:
Anna Rose 2012-07-06 22:02:02 -04:00
parent 9b00d08b39
commit 52fde623ef
2 changed files with 29 additions and 6 deletions

View File

@ -205,6 +205,16 @@ class CommandParser(Cmd):
c.damage(amount) c.damage(amount)
def do_minionkill(self, line):
"""damage [index list]
Deals 1 damage to each of the specified combatants. Used to indicate minion death"""
data = parse_data(line)
for index in data:
self.btl.get_combatant(int(index)).damage(1)
def do_heal(self, line): def do_heal(self, line):
"""heal [index] [amount] """heal [index] [amount]
Heal hit points for the specified combatant""" Heal hit points for the specified combatant"""

View File

@ -384,12 +384,13 @@ class CombatGroup():
class Combatant(): class Combatant():
next_index = 0 next_index = 0
def __init__(self, name, hp, pc=False, init_mod=0, surges=0, ap=0, sw=0, recharges=[]): def __init__(self, name, hp, pc=False, init_mod=0, surges=0, ap=0, sw=0, recharges=[], minion=False):
self.name = name self.name = name
self.max_hp = hp self.max_hp = hp
self.hp = self.max_hp self.hp = self.max_hp
self.temp_hp = 0 self.temp_hp = 0
self.pc = pc self.pc = pc
self.minion = minion
self.surges = surges self.surges = surges
self.ap = ap self.ap = ap
self.sw = sw self.sw = sw
@ -517,7 +518,8 @@ class Combatant():
self.hp -= amount self.hp -= amount
print '{} took {} points of damage.'.format(self, amount) if not self.minion:
print '{} took {} points of damage.'.format(self, amount)
if self.is_down(): if self.is_down():
print '{} is down!'.format(self) print '{} is down!'.format(self)
@ -655,7 +657,12 @@ recharge powers:
if self.temp_hp > 0: if self.temp_hp > 0:
temp_info = ', {} temp hp'.format(self.temp_hp) temp_info = ', {} temp hp'.format(self.temp_hp)
return '{} hp{}{}{}'.format(self.hp, temp_info, bloodied, ', '.join([x['name'] for x in self.conditions.values()])) if self.minion:
hp_s = 'minion'
else:
hp_s = '{} hp'.format(self.hp)
return hp_s + temp_info + bloodied + ', '.join([x['name'] for x in self.conditions.values()])
def format_condition_summary(self, initial=''): def format_condition_summary(self, initial=''):
@ -754,9 +761,9 @@ def _build_group_from_file_data(data):
else: else:
gname = data['name'] gname = data['name']
minion = bool(data['minion'])
count = int(data['count']) count = int(data['count'])
members = {} members = {}
for i in range(count): for i in range(count):
if count > 1: if count > 1:
@ -765,13 +772,19 @@ def _build_group_from_file_data(data):
name = data['name'] name = data['name']
c = Combatant(name, int(data['hp']), data['pc'], c = Combatant(name, int(data['hp']), data['pc'],
int(data['init']), int(data['surges']), int(data['init']), int(data['surges']),
int(data['ap']), int(data['sw']), data['recharges']) int(data['ap']), int(data['sw']), data['recharges'], data['minion'])
members[c.index] = c members[c.index] = c
return CombatGroup(gname, members, int(data['init'])) return CombatGroup(gname, members, int(data['init']))
def _validate_group_data(data): def _validate_group_data(data):
if not 'hp' in data:
data['hp'] = 1
if not 'minion' in data:
data['minion'] = False
if not 'pc' in data: if not 'pc' in data:
data['pc'] = False data['pc'] = False
@ -795,4 +808,4 @@ def _validate_group_data(data):
else: else:
data['sw'] = 0 data['sw'] = 0
return 'name' in data and 'hp' in data return 'name' in data