Added code to handle groups of NPCs who are 'down'

This commit is contained in:
Anna Rose 2012-07-06 21:45:45 -04:00
parent 261304d78b
commit 0db48c544d

View File

@ -177,6 +177,11 @@ class Battle():
# there's a sentinel value in CombatGroup
g.begin_turn()
# Handle groups of dead/down NPCs
if not g.has_pcs() and g.group_down() and not from_unwait and not same_index:
print '{} {} down.'.format(g.name, ['is', 'are'][len(g.members) != 1])
self.next_combatant()
def next_round(self):
if self.round == None:
@ -360,6 +365,20 @@ class CombatGroup():
self.turn_began = False
def has_pcs(self):
for c in self.members.values():
if c.pc:
return True
return False
def group_down(self):
for c in self.members.values():
if c.hp > 0:
return False
return True
class Combatant():
@ -566,6 +585,16 @@ class Combatant():
self.add_condition('Second Wind (+2 all def)', 't', 1, 's')
def use_action_point(self):
if self.ap <= 0:
print "{} doesn't have any action points.".format(self)
return
self.ap -= 1
print '{} used an action point!'.format(self)
def use_recharge_power(self, index):
if index not in self.recharges:
print "Error: Invalid recharge index"