Fixed some formatting bugs and erroneous error messages. Fixed a bug that made it impossible to print combatant info
This commit is contained in:
parent
387bc8f793
commit
5a08d943bb
|
@ -141,7 +141,7 @@ class Battle():
|
|||
|
||||
g = self.groups[self.current]
|
||||
if g.is_solo_group():
|
||||
return '{}'.format(g.members[0].format_full_info())
|
||||
return '{}'.format(g.get_member_by_pos(0).format_full_info())
|
||||
else:
|
||||
ret = '{}\n'.format(g.name)
|
||||
for c in g.members.values():
|
||||
|
@ -670,20 +670,18 @@ def combatgroups_from_file(filename):
|
|||
|
||||
with open(filename, 'r') as f:
|
||||
group_data = {}
|
||||
group_data['recharges'] = []
|
||||
|
||||
for line in f.read().split('\n'):
|
||||
line = line.strip()
|
||||
|
||||
if line == '':
|
||||
if group_data == {}:
|
||||
continue
|
||||
|
||||
g = _build_group_from_file_data(group_data)
|
||||
if g is not None:
|
||||
ret.append(g)
|
||||
else:
|
||||
print 'Error: Failed to read a group definition from file: {}'.format(filename)
|
||||
|
||||
group_data = {}
|
||||
group_data['recharges'] = []
|
||||
|
||||
else:
|
||||
try:
|
||||
|
@ -692,7 +690,21 @@ def combatgroups_from_file(filename):
|
|||
print 'Error: Bad value in data file. No data from file parsed.'
|
||||
return []
|
||||
|
||||
group_data[var] = value
|
||||
if var == 'recharge':
|
||||
recharge = {}
|
||||
recharge['used'] = False
|
||||
info = var.split('|')
|
||||
try:
|
||||
recharge['name'] = info[0].strip()
|
||||
recharge['value'] = int(info[1])
|
||||
except ValueError:
|
||||
print 'Error: Bad syntax in recharge power. Ignoring'
|
||||
continue
|
||||
|
||||
group_data['recharges'].append(recharge)
|
||||
|
||||
else:
|
||||
group_data[var] = value
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -701,25 +713,29 @@ def _build_group_from_file_data(data):
|
|||
if not _validate_group_data(data):
|
||||
return None
|
||||
|
||||
if 'count' in data:
|
||||
if data['count'] > 1:
|
||||
if 'groupname' in data:
|
||||
gname = data['groupname']
|
||||
else:
|
||||
gname = data['name'] + 's'
|
||||
|
||||
count = int(data['count'])
|
||||
else:
|
||||
count = 1
|
||||
gname = data['name']
|
||||
|
||||
count = int(data['count'])
|
||||
|
||||
|
||||
members = {}
|
||||
for i in range(count):
|
||||
c = Combatant(data['name'], int(data['hp']), data['pc'],
|
||||
if count > 1:
|
||||
name = data['name'] + ' ' + str(i + 1)
|
||||
else:
|
||||
name = data['name']
|
||||
c = Combatant(name, int(data['hp']), data['pc'],
|
||||
int(data['init']), int(data['surges']),
|
||||
int(data['ap']), data['sw'], data['recharges'])
|
||||
int(data['ap']), int(data['sw']), data['recharges'])
|
||||
members[c.index] = c
|
||||
|
||||
return CombatGroup(gname, members, data['init'])
|
||||
return CombatGroup(gname, members, int(data['init']))
|
||||
|
||||
|
||||
def _validate_group_data(data):
|
||||
|
|
Loading…
Reference in New Issue
Block a user