Added code to represent minions, and to kill multiple minions with one command.
This commit is contained in:
@ -384,12 +384,13 @@ class CombatGroup():
|
||||
class Combatant():
|
||||
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.max_hp = hp
|
||||
self.hp = self.max_hp
|
||||
self.temp_hp = 0
|
||||
self.pc = pc
|
||||
self.minion = minion
|
||||
self.surges = surges
|
||||
self.ap = ap
|
||||
self.sw = sw
|
||||
@ -517,7 +518,8 @@ class Combatant():
|
||||
|
||||
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():
|
||||
print '{} is down!'.format(self)
|
||||
@ -655,7 +657,12 @@ recharge powers:
|
||||
if self.temp_hp > 0:
|
||||
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=''):
|
||||
@ -754,9 +761,9 @@ def _build_group_from_file_data(data):
|
||||
else:
|
||||
gname = data['name']
|
||||
|
||||
minion = bool(data['minion'])
|
||||
count = int(data['count'])
|
||||
|
||||
|
||||
members = {}
|
||||
for i in range(count):
|
||||
if count > 1:
|
||||
@ -765,13 +772,19 @@ def _build_group_from_file_data(data):
|
||||
name = data['name']
|
||||
c = Combatant(name, int(data['hp']), data['pc'],
|
||||
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
|
||||
|
||||
return CombatGroup(gname, members, int(data['init']))
|
||||
|
||||
|
||||
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:
|
||||
data['pc'] = False
|
||||
|
||||
@ -795,4 +808,4 @@ def _validate_group_data(data):
|
||||
else:
|
||||
data['sw'] = 0
|
||||
|
||||
return 'name' in data and 'hp' in data
|
||||
return 'name' in data
|
||||
|
Reference in New Issue
Block a user