From 4c6f96832b7571a4998b6c0fbf83d3981cd26bd8 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Fri, 6 Apr 2012 02:04:04 -0400 Subject: [PATCH] battleman: fixed 'print' command on a group, cleaned up and added some output --- battleman.py | 4 ++-- lib/battle.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/battleman.py b/battleman.py index 002aa89..aba7774 100755 --- a/battleman.py +++ b/battleman.py @@ -122,9 +122,9 @@ class CommandParser(Cmd): if num_cmds == 1: return getattr(self, 'do_'+cmds[0])(data) elif num_cmds > 1: - sys.stdout.write('Error: Ambiguous command: {}'.format(comm)) + print 'Error: Ambiguous command: {}'.format(comm) else: - print 'Error: Unrecognized command {}'.format(comm) + print 'Error: Unrecognized command: {}'.format(comm) # We are overriding do_help to avoid printing info about diff --git a/lib/battle.py b/lib/battle.py index 9473dd0..9b8de1f 100644 --- a/lib/battle.py +++ b/lib/battle.py @@ -135,7 +135,6 @@ class Battle(): # Returns a formatted string with just the current group - # fixme: non-solo groups only print indexes... def format_current_group(self): if self.validate_started(): return self.validate_started() @@ -145,7 +144,7 @@ class Battle(): return '{}'.format(g.members[0].format_full_info()) else: ret = '{}\n'.format(g.name) - for c in g.members: + for c in g.members.values(): ret = ret + ' {}\n'.format(c) return ret.rstrip() @@ -181,12 +180,12 @@ class Battle(): for c in self.combatant_hash.values(): c.tick_conditions() - print 'Beginning round {}'.format(self.round) + print 'Beginning round {}.'.format(self.round) def validate_started(self): if not self.is_started(): - return 'Error: you can only run this command after starting the battle' + return 'Error: you can only run this command after starting the battle.' return None @@ -211,9 +210,10 @@ class Battle(): if c: self.wait_list[index] = c + print '{} is now in the wait list.'.format(c) self.next_combatant(same_index = True) else: - print 'Error: Failed to find combatant {}'.format(index) + print 'Error: Failed to find combatant {}.'.format(index) def unwait(self, index): @@ -226,6 +226,7 @@ class Battle(): c = self.wait_list[index] del self.wait_list[index] self.groups.insert(self.current, CombatGroup(c.name, {c.index: c}, 0)) + print '{} is no longer waiting.'.format(c) self.next_combatant(same_index = True) else: if index in self.combatant_hash: