battleman.py: more formatting cleanup
This commit is contained in:
parent
5fd07e0ae1
commit
5f5fe29032
59
battleman.py
59
battleman.py
|
@ -109,10 +109,10 @@ class Combatant():
|
||||||
|
|
||||||
self.hp -= amount
|
self.hp -= amount
|
||||||
|
|
||||||
if self.is_bloodied() and not was_bloodied:
|
|
||||||
print('{} ({}) is bloodied! Remaining hp: {}'.format(self.name, self.index, self.hp))
|
|
||||||
if self.is_down():
|
if self.is_down():
|
||||||
print('{} ({}) is down!'.format(self.name, self.index))
|
print('{} ({}) is down!'.format(self.name, self.index))
|
||||||
|
elif self.is_bloodied() and not was_bloodied:
|
||||||
|
print('{} ({}) is bloodied! Remaining hp: {}'.format(self.name, self.index, self.hp))
|
||||||
|
|
||||||
|
|
||||||
def is_bloodied(self):
|
def is_bloodied(self):
|
||||||
|
@ -162,11 +162,11 @@ class Battle():
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret = ''
|
ret = ''
|
||||||
if self.is_started():
|
if self.is_started():
|
||||||
ret = 'Battle underway, currently on round {}\n'.format(self.round)
|
ret = 'Battle underway, currently on round {}\n\n'.format(self.round)
|
||||||
else:
|
else:
|
||||||
ret = 'Battle not yet started\n'
|
ret = 'Battle not yet started\n\n'
|
||||||
|
|
||||||
ret = ret + 'Combatants:\n'
|
ret = ret + 'Combatants\n==========\n'
|
||||||
ret = ret + self.list_combatants()
|
ret = ret + self.list_combatants()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -222,6 +222,21 @@ class Battle():
|
||||||
return ret.rstrip()
|
return ret.rstrip()
|
||||||
|
|
||||||
|
|
||||||
|
# Returns a formatted string with all of the combatants
|
||||||
|
def list_current_group(self):
|
||||||
|
ret = ''
|
||||||
|
|
||||||
|
g = self.groups[current]
|
||||||
|
if g.is_solo_group():
|
||||||
|
ret = ret + '{}: {}\n'.format(g.members[0].index, g.name)
|
||||||
|
else:
|
||||||
|
ret = ret + '{}:\n'.format(g.name)
|
||||||
|
for c in g.members:
|
||||||
|
ret = ret + '\t{}: {} ({})\n'.format(c.index, c.name, c.get_health_summary())
|
||||||
|
|
||||||
|
return ret.rstrip()
|
||||||
|
|
||||||
|
|
||||||
def next_combatant(self):
|
def next_combatant(self):
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
g = self.get_current_group()
|
g = self.get_current_group()
|
||||||
|
@ -250,7 +265,7 @@ def main():
|
||||||
# print("Adding enemy group {}".format(i))
|
# print("Adding enemy group {}".format(i))
|
||||||
# battle.add_group(CombatGroup.from_input())
|
# battle.add_group(CombatGroup.from_input())
|
||||||
|
|
||||||
print "Welcome to 4e Battle Manager.\nCurrent status:"
|
print "Welcome to 4e Battle Manager.\n"
|
||||||
print battle
|
print battle
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -266,7 +281,9 @@ def do_prompt():
|
||||||
elif comm == 'a':
|
elif comm == 'a':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif comm == 'l':
|
elif comm == 'l':
|
||||||
battle.list_combatants()
|
print battle.list_combatants()
|
||||||
|
elif comm == 'l':
|
||||||
|
print battle.list_current_group()
|
||||||
elif comm == 'b':
|
elif comm == 'b':
|
||||||
battle.begin()
|
battle.begin()
|
||||||
elif comm == 'd':
|
elif comm == 'd':
|
||||||
|
@ -292,7 +309,7 @@ def do_damage():
|
||||||
print('Error: you can only run this command after starting the battle')
|
print('Error: you can only run this command after starting the battle')
|
||||||
return
|
return
|
||||||
|
|
||||||
battle.list_combatants()
|
print battle.list_combatants()
|
||||||
index = input_int('choose combatant', battle.get_current_group().members[0].index)
|
index = input_int('choose combatant', battle.get_current_group().members[0].index)
|
||||||
amount = input_int('damage')
|
amount = input_int('damage')
|
||||||
battle.deal_damage(index, amount)
|
battle.deal_damage(index, amount)
|
||||||
|
@ -300,18 +317,20 @@ def do_damage():
|
||||||
|
|
||||||
def do_help():
|
def do_help():
|
||||||
print("""Possible commands:
|
print("""Possible commands:
|
||||||
? - print this help menu (yay, you already figured that one out)
|
? - print this help menu (yay, you already figured that one out)
|
||||||
a - add more combatants (works during battle)
|
a - add more combatants (works during battle) [stub]
|
||||||
l - list current combatants
|
b - begin the battle
|
||||||
b - begin the battle
|
l - list combatants
|
||||||
d - deal damage to someone
|
p - print info for combatant/group with initiative
|
||||||
h - heal someone
|
d - deal damage to someone
|
||||||
s - let someone use a healing surge
|
h - heal someone [stub]
|
||||||
c - apply a condition
|
s - let someone use a healing surge [stub]
|
||||||
r - remove a condition (this can also happen automatically)
|
sw -
|
||||||
n - next (end the current combat group's turn)
|
c - apply a condition [stub]
|
||||||
w - wait (remove a combatant from the initiative order and into a separate pool)
|
r - remove a condition (this can also happen automatically) [stub]
|
||||||
q - quit""")
|
n - next (end the current combat group's turn) [stub]
|
||||||
|
w - wait (remove a combatant from the initiative order and into a separate pool) [stub]
|
||||||
|
q - quit""")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user