battleman.py: Lots of output formatting and cleanup.
This commit is contained in:
parent
617c635206
commit
ac7396e6a3
33
battleman.py
33
battleman.py
|
@ -135,11 +135,10 @@ class Combatant():
|
||||||
|
|
||||||
self.hp -= amount
|
self.hp -= amount
|
||||||
|
|
||||||
# fixme - should we change this output?
|
|
||||||
if self.is_down():
|
if self.is_down():
|
||||||
print('{} ({}) is down!'.format(self.name, self.index))
|
print('{} is down!'.format(self))
|
||||||
elif self.is_bloodied() and not was_bloodied:
|
elif self.is_bloodied() and not was_bloodied:
|
||||||
print('{} ({}) is bloodied! Remaining hp: {}'.format(self.name, self.index, self.hp))
|
print('{} is bloodied!'.format(self))
|
||||||
|
|
||||||
|
|
||||||
def heal(self, amount):
|
def heal(self, amount):
|
||||||
|
@ -149,25 +148,35 @@ class Combatant():
|
||||||
if self.hp < 0:
|
if self.hp < 0:
|
||||||
self.hp = 0
|
self.hp = 0
|
||||||
|
|
||||||
self.hp = min(self.hp + amount, self.max_hp + self.temp_hp)
|
amount_healed = amount
|
||||||
|
if self.hp + amount_healed > self.max_hp:
|
||||||
|
amount_healed = self.max_hp - self.hp
|
||||||
|
|
||||||
|
self.hp += amount_healed
|
||||||
|
|
||||||
# fixme - should we change this output?
|
|
||||||
if was_down:
|
if was_down:
|
||||||
print('{} ({}) is conscious.'.format(self.name, self.index))
|
print('{} regains consciousness.'.format(self))
|
||||||
|
|
||||||
|
print('{} regained {} hit points.'.format(self, amount_healed))
|
||||||
|
|
||||||
if was_bloodied and not self.is_bloodied():
|
if was_bloodied and not self.is_bloodied():
|
||||||
print('{} ({}) is no longer bloodied.'.format(self.name, self.index))
|
print('{} is no longer bloodied.'.format(self))
|
||||||
elif was_bloodied and self.is_bloodied():
|
elif was_bloodied and self.is_bloodied():
|
||||||
print('{} ({}) is still bloodied.'.format(self.name, self.index))
|
print('{} is still bloodied.'.format(self))
|
||||||
|
|
||||||
|
|
||||||
def use_surge(self, heal=True):
|
def use_surge(self, heal=True):
|
||||||
if self.surges <= 0:
|
if self.surges <= 0:
|
||||||
print 'Error: {} has no healing surges'.format(self.name)
|
print 'Error: {} has no healing surges.'.format(self.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.surges -= 1
|
self.surges -= 1
|
||||||
print '{} spent a healing surge'.format(self)
|
noheal = ''
|
||||||
if (heal):
|
if not heal:
|
||||||
|
noheal = " (but didn't regain hit points)"
|
||||||
|
print '{} spent a healing surge{}.'.format(self, noheal)
|
||||||
|
|
||||||
|
if heal:
|
||||||
self.heal(self.max_hp / 4)
|
self.heal(self.max_hp / 4)
|
||||||
|
|
||||||
|
|
||||||
|
@ -281,7 +290,7 @@ class Battle():
|
||||||
|
|
||||||
print '\nInitiative Roster:\n'
|
print '\nInitiative Roster:\n'
|
||||||
for g in self.groups:
|
for g in self.groups:
|
||||||
print '{} ({})'.format(g.name, g.init) # fixme - should we change this output?
|
print '{} ({})'.format(g.name, g.init)
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
self.next_round()
|
self.next_round()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user