From 1da238be5a06098b85c28337b3f1c6af9743a419 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 01:08:56 -0400 Subject: [PATCH 01/11] battleman.py: Added a feature to conditions that allows them to end at the start of a turn or the end of a turn --- battleman.py | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/battleman.py b/battleman.py index 34bcace..a0c5156 100755 --- a/battleman.py +++ b/battleman.py @@ -18,7 +18,6 @@ import sys class CombatGroup(): - # What we're mostly getting here is a definition of the *members* # of the group... then we build them all and stick them in # the group @@ -77,13 +76,10 @@ class CombatGroup(): def begin_turn(self): - msg = None - if self.is_solo_group(): - msg = '{} has initiative.'.format(self.name) - else: - msg = '{} have initiative.'.format(self.name) + print '{} {} initiative.'.format(self.name, ['has', 'have'][len(self.members) != 1]) - print msg + for c in self.members: + c.begin_turn() def end_turn(self): @@ -117,11 +113,12 @@ class Combatant(): # cond_type can be 's' or 't', for 'save' or 'timed'. If it is 't', condition expires at the end of the players turn # 'duration' rounds from now - def add_condition(self, name, cond_type, duration=None): + def add_condition(self, name, cond_type, duration=None, end_type='e'): condition = {} condition['name'] = name condition['cond_type'] = cond_type condition['duration'] = duration + condition['end_type'] = end_type condition['index'] = self.next_condition_index if cond_type == 'timed' and duration == None: print('Error: specified a timed condition with no duration.') @@ -159,8 +156,17 @@ class Combatant(): c['duration'] -= 1 + def begin_turn(self): + for c in self.conditions.values(): + if c['cond_type'] == 't' and c['end_type'] == 's': + if c['duration'] <= 0: + self.remove_condition(c['index']) + else: + print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) + + def end_turn(self): - for (index, c) in self.conditions.items(): + for c in self.conditions.values(): if c['cond_type'] == 's': r = None if self.pc: @@ -171,16 +177,16 @@ class Combatant(): r = save_die.roll()['total'] if r >= 10: - self.remove_condition(index) + self.remove_condition(c['index']) + print('{} successfully saved against {}.'.format(self, c['name'])) else: print('{} failed a save against {}.'.format(self, c['name'])) - elif c['cond_type'] == 't': - c['duration'] -= 1 - if c['duration'] < 0: - self.remove_condition(index) + elif c['cond_type'] == 't' and c['end_type'] == 'e': + if c['duration'] <= 0: + self.remove_condition(c['index']) else: - print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration']+1, 's'[c['duration']==0:])) + print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) # fixme: still need to add recharges @@ -490,9 +496,8 @@ def do_prompt(): (comm, rdata) = input_str('', default='?', show_default=False, prompt_str='>').partition(' ')[::2] data = rdata.split(' ') - # To simplify our checks later if data == ['']: - data = None + data = [] if comm == '?': do_help() @@ -528,7 +533,6 @@ def do_prompt(): do_wait(data) elif comm == 'W': do_unwait(data) - print('Sorry, this is still a stub function.') elif comm == 'q': sys.exit(0) @@ -642,6 +646,7 @@ def do_second_wind(data): def do_add_condition(data): duration = None + end_type = 'e' if len(data) >= 1: c = battle.get_combatant(int(data[0])) @@ -664,7 +669,12 @@ def do_add_condition(data): else: duration = input_int('duration') - c.add_condition(name, ctype, duration) + if len(data) >= 5: + end_type = data[4] + else: + end_type = input_str('(s)tart|(e)nd', default='e', show_default=True) + + c.add_condition(name, ctype, duration, end_type) def do_remove_condition(data): From fddb2bf8bb553a90047fe8da317950c61d55d547 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 01:18:53 -0400 Subject: [PATCH 02/11] battleman.py: Added recharge power rerolling, improved recharge inputting. --- battleman.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/battleman.py b/battleman.py index a0c5156..2a46336 100755 --- a/battleman.py +++ b/battleman.py @@ -30,13 +30,17 @@ class CombatGroup(): surges = input_int('healing surges', 0) recharges = [] - recharge = [''] while True: - recharge = input_str("recharge", default='').split(',') - if recharge == ['']: - break - else: + data = [] + data = input_str("recharge", default='').split(',') + if len(data) == 2: + recharge = {} + recharge['name'] = data[0] + recharge['value'] = int(data[1]) + recharge['used'] = False recharges.append(recharge) + else: + break count = input_int('count', 1) @@ -188,7 +192,13 @@ class Combatant(): else: print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) - # fixme: still need to add recharges + for r in self.recharges: + if r['used']: + # Roll to recharge + d = Dice.from_str('1d6') + n = d.roll()['total'] + if n >= r['value']: + r['used'] = False def damage(self, amount): From 0afd59aa885758680f6010023f3b382b1547d60e Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 01:53:32 -0400 Subject: [PATCH 03/11] battleman.py: Implemented UI side of recharge powers. --- battleman.py | 107 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 21 deletions(-) diff --git a/battleman.py b/battleman.py index 2a46336..39e722b 100755 --- a/battleman.py +++ b/battleman.py @@ -104,12 +104,18 @@ class Combatant(): self.surges = surges self.ap = ap self.sw = sw - self.recharges = [] self.conditions = {} self.index = Combatant.next_index self.next_condition_index = 0 Combatant.next_index += 1 + self.recharges = {} + recharge_index = 0 + for r in recharges: + r['index'] = recharge_index + self.recharges[recharge_index] = r + recharge_index += 1 + def __str__(self): return "{}: {} ({})".format(self.index, self.name, self.format_health_summary()) @@ -192,8 +198,9 @@ class Combatant(): else: print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) + # fixme: print message when this succeeds for r in self.recharges: - if r['used']: + if r['used']: # fixme: this line breaks # Roll to recharge d = Dice.from_str('1d6') n = d.roll()['total'] @@ -279,6 +286,25 @@ class Combatant(): self.add_condition('Second Wind (+2 all def)', 't', 1) + def use_recharge_power(self, index): + if index not in self.recharges: + print "Error: Invalid recharge index" + return + + self.recharges[index]['used'] = True + + + def choose_recharge_power(self): + print self.format_recharge_summary() + index = input_int('choice') + + if index not in self.recharges: + print 'Error: {} is not a valid index'.format(index) + return self.choose_recharge_power() + + return self.recharges[index] + + def is_bloodied(self): return self.hp <= self.max_hp / 2 @@ -287,6 +313,21 @@ class Combatant(): return self.hp <= 0 + def format_full_info(self): + return """{name} +{separator} +index: {index} +hp: {hp}/{max_hp} +temp hp: {temp_hp} +surges: {surge} +ap: {ap} +sw: {sw} +conditions: +{conditions} +recharge powers: +{recharge}""".format(index=self.index, name=self.name, hp=self.hp, max_hp=self.max_hp, temp_hp=self.temp_hp, surge=self.surges, ap=self.ap, sw=self.sw, conditions=self.format_condition_summary(), recharge=self.format_recharge_summary(), separator='='*len(self.name)) + + def format_health_summary(self): bloodied = '' temp_info = '' @@ -313,6 +354,11 @@ class Combatant(): return summary.rstrip() + def format_recharge_summary(self): + summary = '' + for (index, r) in self.recharges.items(): + summary = summary + '{}: {} (Recharge: {}, Available: {})\n'.format(index, r['name'], r['value'], ['Yes', 'No'][ r['used'] ]) + return summary.rstrip() # data about the battle - includes combatant list, etc @@ -435,9 +481,9 @@ class Battle(): g = self.groups[self.current] if g.is_solo_group(): - ret = ret + '{}\n'.format(g.members[0]) + ret = '{}\n'.format(g.members[0].format_full_info()) else: - ret = ret + '{}:\n'.format(g.name) + ret = ret + '{}'.format(g.name) for c in g.members: ret = ret + ' {}\n'.format(c) @@ -539,6 +585,8 @@ def do_prompt(): do_remove_condition(data) elif comm == 'n': battle.next_combatant() + elif comm == 'r': + do_use_recharge_power(data) elif comm == 'w': do_wait(data) elif comm == 'W': @@ -549,23 +597,23 @@ def do_prompt(): def do_help(): print("""Possible commands: -? - print this help menu (yay, you already figured that one out) -a - add more combatants (works during battle) -b - begin the battle -l - list combatants -p - print info for combatant/group with initiative -d - deal damage to someone -h - heal someone -t - add temporary hit points -T - remove temporary hit points [stub] -s - use a healing surge -so - use a healing surge, but don't regain hit points -sw - use a second wind -c - apply a condition -C - remove a condition -n - next (end the current combat group's turn) -wW - wait / unwait (remove a combatant from the initiative order and into a separate pool, then put them back) [stub] -q - quit""") +? - print this help menu (yay, you already figured that one out) +a - add more combatants (works during battle) +b - begin the battle +l - list combatants +p - print info for combatant/group with initiative +d - deal damage to someone +h - heal someone +t - add temporary hit points +T - remove temporary hit points [stub] +s - use a healing surge +so - use a healing surge, but don't regain hit points +sw - use a second wind +c/C - apply / remove a condition +r - use a rechargable power +n - next (end the current combat group's turn) +w/W - wait / unwait (remove a combatant from the initiative order and into a separate pool, then put them back) [stub] +q - quit""") def do_add_combatants(data): @@ -704,6 +752,23 @@ def do_remove_condition(data): c.remove_condition(index) +def do_use_recharge_power(data): + if len(data) >= 1: + c = battle.get_combatant(int(data[0])) + if not c: + print ('Error: Invalid combatant index.') + return + else: + c = battle.choose_combatant() + + if len(data) >= 2: + index = int(data[1]) + else: + index = c.choose_recharge_power()['index'] + + c.use_recharge_power(index) + + def do_wait(data): do_stub() From 14e5033c2d19c150cbaedd81cbc402a559449686 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 13:56:55 -0400 Subject: [PATCH 04/11] battleman.py: Fixed recharge rolling, added message when roll succeeds --- battleman.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/battleman.py b/battleman.py index 39e722b..c8a09e9 100755 --- a/battleman.py +++ b/battleman.py @@ -198,14 +198,15 @@ class Combatant(): else: print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) - # fixme: print message when this succeeds - for r in self.recharges: - if r['used']: # fixme: this line breaks + # fixme - this rolls on the same turn the power is used. Need a way to avoid that. + for r in self.recharges.values(): + if r['used']: # Roll to recharge d = Dice.from_str('1d6') n = d.roll()['total'] if n >= r['value']: r['used'] = False + print('{} can use {} again!'.format(self, r['name'])) def damage(self, amount): @@ -735,6 +736,7 @@ def do_add_condition(data): c.add_condition(name, ctype, duration, end_type) +# fixme: if you pick someone with no conditions, you get stuck in a loop def do_remove_condition(data): if len(data) >= 1: c = battle.get_combatant(int(data[0])) @@ -752,6 +754,7 @@ def do_remove_condition(data): c.remove_condition(index) +# fixme: if you pick someone with no recharges, you get stuck in a loop def do_use_recharge_power(data): if len(data) >= 1: c = battle.get_combatant(int(data[0])) From 656e46d28e2a1ed6323eebc7c04f5fb36c993265 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:08:15 -0400 Subject: [PATCH 05/11] battleman.py: Avoid getting stuck in input loop when adding conditions or using recharge powers --- battleman.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/battleman.py b/battleman.py index c8a09e9..bde0878 100755 --- a/battleman.py +++ b/battleman.py @@ -150,6 +150,10 @@ class Combatant(): def choose_condition(self): + if not len(self.conditions): + print '{} has no conditions.'.format(self) + return None + print self.format_condition_summary() index = input_int('choice') @@ -296,6 +300,10 @@ class Combatant(): def choose_recharge_power(self): + if not len(self.recharges): + print '{} has no rechargable powers.'.format(self) + return None + print self.format_recharge_summary() index = input_int('choice') @@ -749,9 +757,13 @@ def do_remove_condition(data): if len(data) >= 2: index = int(data[1]) else: - index = c.choose_condition()['index'] + cond = c.choose_condition() + index = None + if cond: + index = cond['index'] - c.remove_condition(index) + if index != None: + c.remove_condition(index) # fixme: if you pick someone with no recharges, you get stuck in a loop @@ -767,9 +779,13 @@ def do_use_recharge_power(data): if len(data) >= 2: index = int(data[1]) else: - index = c.choose_recharge_power()['index'] + r = c.choose_recharge_power() + index = None + if r: + index = r['index'] - c.use_recharge_power(index) + if index != None: + c.use_recharge_power(index) def do_wait(data): From f5d16bfbaa880692c25917e989e35cab7251f99d Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:16:09 -0400 Subject: [PATCH 06/11] battleman.py: Fixed recharges getting a roll the round they are used. --- battleman.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/battleman.py b/battleman.py index bde0878..e44663b 100755 --- a/battleman.py +++ b/battleman.py @@ -113,6 +113,7 @@ class Combatant(): recharge_index = 0 for r in recharges: r['index'] = recharge_index + r['just_used'] = False self.recharges[recharge_index] = r recharge_index += 1 @@ -205,6 +206,10 @@ class Combatant(): # fixme - this rolls on the same turn the power is used. Need a way to avoid that. for r in self.recharges.values(): if r['used']: + if r['just_used']: + r['just_used'] = False + continue + # Roll to recharge d = Dice.from_str('1d6') n = d.roll()['total'] @@ -297,6 +302,7 @@ class Combatant(): return self.recharges[index]['used'] = True + self.recharges[index]['just_used'] = True def choose_recharge_power(self): @@ -556,6 +562,7 @@ def main(): do_prompt() +# fixme - change input behavior. If an action has a sensible default, do that when no args are passed - require args to change default behavior def do_prompt(): print('') (comm, rdata) = input_str('', default='?', show_default=False, prompt_str='>').partition(' ')[::2] @@ -744,7 +751,6 @@ def do_add_condition(data): c.add_condition(name, ctype, duration, end_type) -# fixme: if you pick someone with no conditions, you get stuck in a loop def do_remove_condition(data): if len(data) >= 1: c = battle.get_combatant(int(data[0])) @@ -766,7 +772,6 @@ def do_remove_condition(data): c.remove_condition(index) -# fixme: if you pick someone with no recharges, you get stuck in a loop def do_use_recharge_power(data): if len(data) >= 1: c = battle.get_combatant(int(data[0])) From 029907edf28cab6aa8063eeef9a674a343867035 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:16:37 -0400 Subject: [PATCH 07/11] battleman.py: removed spurious fixme comment --- battleman.py | 1 - 1 file changed, 1 deletion(-) diff --git a/battleman.py b/battleman.py index e44663b..858cabc 100755 --- a/battleman.py +++ b/battleman.py @@ -203,7 +203,6 @@ class Combatant(): else: print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) - # fixme - this rolls on the same turn the power is used. Need a way to avoid that. for r in self.recharges.values(): if r['used']: if r['just_used']: From a89acda1ac334b1e24579d22fe2392e15afad0dd Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:20:09 -0400 Subject: [PATCH 08/11] battleman.py: Code cleanup --- battleman.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/battleman.py b/battleman.py index 858cabc..650aa6b 100755 --- a/battleman.py +++ b/battleman.py @@ -132,7 +132,7 @@ class Combatant(): condition['end_type'] = end_type condition['index'] = self.next_condition_index if cond_type == 'timed' and duration == None: - print('Error: specified a timed condition with no duration.') + print 'Error: specified a timed condition with no duration.' return self.conditions[self.next_condition_index] = condition self.next_condition_index += 1 @@ -145,7 +145,7 @@ class Combatant(): return None c = self.conditions.pop(index) - print('{} is no longer affected by {}.'.format(self, c['name'])) + print '{} is no longer affected by {}.'.format(self, c['name']) return c @@ -177,7 +177,7 @@ class Combatant(): if c['duration'] <= 0: self.remove_condition(c['index']) else: - print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) + print '{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:]) def end_turn(self): @@ -185,7 +185,7 @@ class Combatant(): if c['cond_type'] == 's': r = None if self.pc: - print('{}: save against {}.'.format(self, c['name'])) + print '{}: save against {}.'.format(self, c['name']) r = input_int('saving throw') else: save_die = Dice.from_str('1d20') @@ -193,15 +193,15 @@ class Combatant(): if r >= 10: self.remove_condition(c['index']) - print('{} successfully saved against {}.'.format(self, c['name'])) + print '{} successfully saved against {}.'.format(self, c['name']) else: - print('{} failed a save against {}.'.format(self, c['name'])) + print '{} failed a save against {}.'.format(self, c['name']) elif c['cond_type'] == 't' and c['end_type'] == 'e': if c['duration'] <= 0: self.remove_condition(c['index']) else: - print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) + print '{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:]) for r in self.recharges.values(): if r['used']: @@ -214,7 +214,7 @@ class Combatant(): n = d.roll()['total'] if n >= r['value']: r['used'] = False - print('{} can use {} again!'.format(self, r['name'])) + print '{} can use {} again!'.format(self, r['name']) def damage(self, amount): @@ -231,9 +231,9 @@ class Combatant(): print '{} took {} points of damage.'.format(self, amount) if self.is_down(): - print('{} is down!'.format(self)) + print '{} is down!'.format(self) elif self.is_bloodied() and not was_bloodied: - print('{} is bloodied!'.format(self)) + print '{} is bloodied!'.format(self) def heal(self, amount): @@ -250,14 +250,14 @@ class Combatant(): self.hp += amount_healed if was_down: - print('{} regains consciousness.'.format(self)) + print '{} regains consciousness.'.format(self) - print('{} regained {} hit points.'.format(self, amount_healed)) + print '{} regained {} hit points.'.format(self, amount_healed) if was_bloodied and not self.is_bloodied(): - print('{} is no longer bloodied.'.format(self)) + print '{} is no longer bloodied.'.format(self) elif was_bloodied and self.is_bloodied(): - print('{} is still bloodied.'.format(self)) + print '{} is still bloodied.'.format(self) def add_temp_hp(self, amount): @@ -451,7 +451,7 @@ class Battle(): def begin(self): if self.is_started(): - print("Error: battle is already running") + print "Error: battle is already running" for g in self.groups: if g.is_solo_group() and g.members[0].pc: @@ -532,7 +532,7 @@ 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): @@ -563,7 +563,7 @@ def main(): # fixme - change input behavior. If an action has a sensible default, do that when no args are passed - require args to change default behavior def do_prompt(): - print('') + print '' (comm, rdata) = input_str('', default='?', show_default=False, prompt_str='>').partition(' ')[::2] data = rdata.split(' ') @@ -634,7 +634,7 @@ q - quit""") def do_add_combatants(data): ngroups = input_int('number of groups') for i in range(1, ngroups+1): - print("Adding group {}".format(i)) + print "Adding group {}".format(i) battle.add_group(CombatGroup.from_input()) @@ -801,7 +801,7 @@ def do_unwait(data): def do_stub(): - print("Sorry, this is a stub function") + print "Sorry, this is a stub function" def input_str(prompt, default=None, show_default=False, prompt_str=':'): From 2cd5120ec0f890bac4d7ee291032ffffc4615331 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:26:24 -0400 Subject: [PATCH 09/11] battleman.py: Code cleanup and output format cleanup for combatant info printing. --- battleman.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/battleman.py b/battleman.py index 650aa6b..b4149a0 100755 --- a/battleman.py +++ b/battleman.py @@ -339,7 +339,7 @@ sw: {sw} conditions: {conditions} recharge powers: -{recharge}""".format(index=self.index, name=self.name, hp=self.hp, max_hp=self.max_hp, temp_hp=self.temp_hp, surge=self.surges, ap=self.ap, sw=self.sw, conditions=self.format_condition_summary(), recharge=self.format_recharge_summary(), separator='='*len(self.name)) +{recharge}""".format(index=self.index, name=self.name, hp=self.hp, max_hp=self.max_hp, temp_hp=self.temp_hp, surge=self.surges, ap=self.ap, sw=self.sw, conditions=self.format_condition_summary(' '), recharge=self.format_recharge_summary(' '), separator='='*len(self.name)) def format_health_summary(self): @@ -356,7 +356,7 @@ recharge powers: return '{} hp{}{}{}'.format(self.hp, temp_info, bloodied, ', '.join([x['name'] for x in self.conditions.values()])) - def format_condition_summary(self): + def format_condition_summary(self, initial=''): summary = '' for (index, c) in self.conditions.items(): type_string = '' @@ -364,14 +364,14 @@ recharge powers: type_string = 'Save Ends' elif c['cond_type'] == 't': type_string = '{} Round{}'.format(c['duration'], 's'[ c['duration']==1: ] ) - summary = summary + '{}: {} ({})\n'.format(index, c['name'], type_string) + summary = summary + '{}{}: {} ({})\n'.format(initial, index, c['name'], type_string) return summary.rstrip() - def format_recharge_summary(self): + def format_recharge_summary(self, initial): summary = '' for (index, r) in self.recharges.items(): - summary = summary + '{}: {} (Recharge: {}, Available: {})\n'.format(index, r['name'], r['value'], ['Yes', 'No'][ r['used'] ]) + summary = summary + '{}{}: {} (Recharge: {}, Available: {})\n'.format(initial, index, r['name'], r['value'], ['Yes', 'No'][ r['used'] ]) return summary.rstrip() @@ -491,17 +491,14 @@ class Battle(): if self.validate_started(): return self.validate_started() - ret = '' - g = self.groups[self.current] if g.is_solo_group(): - ret = '{}\n'.format(g.members[0].format_full_info()) + return '{}'.format(g.members[0].format_full_info()) else: - ret = ret + '{}'.format(g.name) + ret = '{}\n'.format(g.name) for c in g.members: ret = ret + ' {}\n'.format(c) - - return ret.rstrip() + return ret.rstrip() def next_combatant(self): From a2151557b140c6e7129399d7dcd70744b4d0763c Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:35:20 -0400 Subject: [PATCH 10/11] Add code for printing full info for arbitrary combatants. --- battleman.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/battleman.py b/battleman.py index b4149a0..935e28c 100755 --- a/battleman.py +++ b/battleman.py @@ -572,7 +572,7 @@ def do_prompt(): elif comm == 'a': do_add_combatants(data) elif comm == 'p': - print battle.format_current_group() + do_print_combatant_info(data) elif comm == 'l': print battle.format_combatants() elif comm == 'b': @@ -635,6 +635,17 @@ def do_add_combatants(data): battle.add_group(CombatGroup.from_input()) +def do_print_combatant_info(data): + if len(data) >= 1: + c = battle.get_combatant(int(data[0])) + if not c: + print('Error: Invalid combatant index.') + else: + print c.format_full_info() + else: + print battle.format_current_group() + + def do_damage(data): if len(data) >= 1: c = battle.get_combatant(int(data[0])) From 331da9c0b76ac1bcd3386f4c8393e5472040a8b9 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Mar 2012 14:45:18 -0400 Subject: [PATCH 11/11] battleman.py: Updated help function to reflect future features --- battleman.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/battleman.py b/battleman.py index 935e28c..c980a80 100755 --- a/battleman.py +++ b/battleman.py @@ -603,6 +603,8 @@ def do_prompt(): do_wait(data) elif comm == 'W': do_unwait(data) + elif comm == 'x': + do_stub() elif comm == 'q': sys.exit(0) @@ -625,6 +627,7 @@ c/C - apply / remove a condition r - use a rechargable power n - next (end the current combat group's turn) w/W - wait / unwait (remove a combatant from the initiative order and into a separate pool, then put them back) [stub] +x - force save the progress to the current battle cache (for use with --resume) [stub] q - quit""")