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]
|
g = self.groups[self.current]
|
||||||
if g.is_solo_group():
|
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:
|
else:
|
||||||
ret = '{}\n'.format(g.name)
|
ret = '{}\n'.format(g.name)
|
||||||
for c in g.members.values():
|
for c in g.members.values():
|
||||||
|
@ -670,20 +670,18 @@ def combatgroups_from_file(filename):
|
||||||
|
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
group_data = {}
|
group_data = {}
|
||||||
|
group_data['recharges'] = []
|
||||||
|
|
||||||
for line in f.read().split('\n'):
|
for line in f.read().split('\n'):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
||||||
if line == '':
|
if line == '':
|
||||||
if group_data == {}:
|
|
||||||
continue
|
|
||||||
|
|
||||||
g = _build_group_from_file_data(group_data)
|
g = _build_group_from_file_data(group_data)
|
||||||
if g is not None:
|
if g is not None:
|
||||||
ret.append(g)
|
ret.append(g)
|
||||||
else:
|
|
||||||
print 'Error: Failed to read a group definition from file: {}'.format(filename)
|
|
||||||
group_data = {}
|
group_data = {}
|
||||||
|
group_data['recharges'] = []
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -692,6 +690,20 @@ def combatgroups_from_file(filename):
|
||||||
print 'Error: Bad value in data file. No data from file parsed.'
|
print 'Error: Bad value in data file. No data from file parsed.'
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
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
|
group_data[var] = value
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -701,25 +713,29 @@ def _build_group_from_file_data(data):
|
||||||
if not _validate_group_data(data):
|
if not _validate_group_data(data):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if 'count' in data:
|
if data['count'] > 1:
|
||||||
if 'groupname' in data:
|
if 'groupname' in data:
|
||||||
gname = data['groupname']
|
gname = data['groupname']
|
||||||
else:
|
else:
|
||||||
gname = data['name'] + 's'
|
gname = data['name'] + 's'
|
||||||
|
else:
|
||||||
|
gname = data['name']
|
||||||
|
|
||||||
count = int(data['count'])
|
count = int(data['count'])
|
||||||
else:
|
|
||||||
count = 1
|
|
||||||
gname = data['name']
|
|
||||||
|
|
||||||
members = {}
|
members = {}
|
||||||
for i in range(count):
|
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['init']), int(data['surges']),
|
||||||
int(data['ap']), data['sw'], data['recharges'])
|
int(data['ap']), int(data['sw']), data['recharges'])
|
||||||
members[c.index] = c
|
members[c.index] = c
|
||||||
|
|
||||||
return CombatGroup(gname, members, data['init'])
|
return CombatGroup(gname, members, int(data['init']))
|
||||||
|
|
||||||
|
|
||||||
def _validate_group_data(data):
|
def _validate_group_data(data):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user