Implemented ability to read combatant definitions from files

This commit is contained in:
2012-05-04 11:27:04 -04:00
parent 0fea33760b
commit d62748fa88
2 changed files with 112 additions and 21 deletions

View File

@ -52,33 +52,37 @@ def main():
sys.exit(1)
else:
for f in settings.files:
for g in battle.combatgroups_from_file(f):
btl.add_group(g)
# hard-coding test cases for now.
# fixme: Eventually, use a state-saving text file that's easy to edit, or at least copy...
adele = Combatant("Adele", hp=26, pc=True, surges=8, sw=1)
adele_dict = {adele.index: adele}
aristaire = Combatant("Aristaire", hp=20, pc=True, surges=6, sw=1)
aristaire_dict = {aristaire.index: aristaire}
# adele = Combatant("Adele", hp=26, pc=True, surges=8, sw=1)
# adele_dict = {adele.index: adele}
# aristaire = Combatant("Aristaire", hp=20, pc=True, surges=6, sw=1)
# aristaire_dict = {aristaire.index: aristaire}
foobolds = {}
for i in range(5):
c = Combatant("Foobold", hp=50)
foobolds[c.index] = c
# foobolds = {}
# for i in range(5):
# c = Combatant("Foobold", hp=50)
# foobolds[c.index] = c
barglins = {}
for i in range(2):
c = Combatant("Barglin", hp=50)
barglins[c.index] = c
# barglins = {}
# for i in range(2):
# c = Combatant("Barglin", hp=50)
# barglins[c.index] = c
orcs = {}
for i in range(2):
c = Combatant("Orc", hp=50)
orcs[c.index] = c
# orcs = {}
# for i in range(2):
# c = Combatant("Orc", hp=50)
# orcs[c.index] = c
btl.add_group(CombatGroup("Adele", adele_dict, 2))
btl.add_group(CombatGroup("Aristaire", aristaire_dict, 0))
btl.add_group(CombatGroup("Foobolds", foobolds, 20))
btl.add_group(CombatGroup("Barglins", barglins, 3))
btl.add_group(CombatGroup("Orcs of Baz", orcs, 1))
# btl.add_group(CombatGroup("Adele", adele_dict, 2))
# btl.add_group(CombatGroup("Aristaire", aristaire_dict, 0))
# btl.add_group(CombatGroup("Foobolds", foobolds, 20))
# btl.add_group(CombatGroup("Barglins", barglins, 3))
# btl.add_group(CombatGroup("Orcs of Baz", orcs, 1))
print btl
@ -433,6 +437,8 @@ def do_stub():
def parse_args():
parser = argparse.ArgumentParser(description='Command-line interface to manage battle data for D&D 4e', formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--resume', '-r', action='store_true', help='Resume the battle from the last run of the program')
parser.add_argument('files', nargs=argparse.REMAINDER, help="A list of files containing combat groups to add to the initial battle. Ignored if --resume is specified.")
return parser.parse_args()