battleman.py: Fixed a very silly error with command parsing, and factored out some ugly input handling code to a lib function
This commit is contained in:
parent
c48218da92
commit
9c60ed4d9c
49
battleman.py
49
battleman.py
|
@ -17,20 +17,10 @@ class CombatGroup():
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_input(cls):
|
def from_input(cls):
|
||||||
name = raw_input("Name: ")
|
name = raw_input("Name: ")
|
||||||
hp = int(raw_input("hp: "))
|
hp = input_int('hp')
|
||||||
init_mod = int(raw_input("init mod: "))
|
init_mod = input_int('init mod')
|
||||||
|
ap = input_int('action points', 0)
|
||||||
ap = raw_input("action points [0] ")
|
surges = input_int('healing surges', 0)
|
||||||
if ap:
|
|
||||||
ap = int(ap)
|
|
||||||
else:
|
|
||||||
ap = 0
|
|
||||||
|
|
||||||
surges = raw_input("surges [0]: ")
|
|
||||||
if surges:
|
|
||||||
surges = int(surges)
|
|
||||||
else:
|
|
||||||
surges = 0
|
|
||||||
|
|
||||||
recharges = []
|
recharges = []
|
||||||
recharge = '-1'
|
recharge = '-1'
|
||||||
|
@ -41,11 +31,7 @@ class CombatGroup():
|
||||||
else:
|
else:
|
||||||
recharges.append(recharge)
|
recharges.append(recharge)
|
||||||
|
|
||||||
count = raw_input("count [1]: ")
|
count = input_int('count', 1)
|
||||||
if count:
|
|
||||||
count = int(count)
|
|
||||||
else:
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
# Now make the combatants...
|
# Now make the combatants...
|
||||||
members = []
|
members = []
|
||||||
|
@ -150,30 +136,27 @@ def main():
|
||||||
def do_prompt():
|
def do_prompt():
|
||||||
comm = raw_input('> ')
|
comm = raw_input('> ')
|
||||||
|
|
||||||
# debug
|
if comm == '?':
|
||||||
print ('|' + comm + '|')
|
|
||||||
|
|
||||||
if 'comm' == '?':
|
|
||||||
do_help()
|
do_help()
|
||||||
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':
|
||||||
do_list_combatants()
|
do_list_combatants()
|
||||||
elif 'comm' == 'b':
|
elif comm == 'b':
|
||||||
do_begin_battle()
|
do_begin_battle()
|
||||||
elif 'comm' == 'd':
|
elif comm == 'd':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif 'comm' == 'h':
|
elif comm == 'h':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif 'comm' == 's':
|
elif comm == 's':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif 'comm' == 'c':
|
elif comm == 'c':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif 'comm' == 'r':
|
elif comm == 'r':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif 'comm' == 'n':
|
elif comm == 'n':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
elif 'comm' == 'w':
|
elif comm == 'w':
|
||||||
print('Sorry, this is still a stub function.')
|
print('Sorry, this is still a stub function.')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user