battleman.py: did some cleanup, got Battle.begin() to work

This commit is contained in:
Anna Rose 2012-03-21 22:47:14 -04:00
parent 38108a4d7b
commit 60df5f6bd0

View File

@ -6,7 +6,7 @@
# Tuned pretty specifically to D&D 4e for now... need a templatized system # Tuned pretty specifically to D&D 4e for now... need a templatized system
# to do anything fancier... may develop that at some point. # to do anything fancier... may develop that at some point.
import dice from dice import Dice
import sys import sys
@ -19,7 +19,7 @@ class CombatGroup():
def from_input(cls): def from_input(cls):
name = raw_input("Name: ") name = raw_input("Name: ")
hp = input_int('hp') hp = input_int('hp')
init_mod = input_int('init mod') init_mod = input_int('init mod', 0)
ap = input_int('action points', 0) ap = input_int('action points', 0)
surges = input_int('healing surges', 0) surges = input_int('healing surges', 0)
@ -53,7 +53,7 @@ class CombatGroup():
def roll_init(self): def roll_init(self):
d = Dice.from_desc('1d20+' + self.init_mod) d = Dice.from_desc('1d20+{}'.format(self.init_mod))
self.set_init(d.roll()['total']) self.set_init(d.roll()['total'])
@ -141,8 +141,8 @@ class Battle():
return return
for g in self.groups: for g in self.groups:
if g.single() and g.members[0].pc: if g.is_solo_group() and g.members[0].pc:
raw_input('Initiative for {}: '.format(g.name)) g.set_init(input_int('Initiative for {}'.format(g.name)))
else: else:
g.roll_init() g.roll_init()
@ -155,7 +155,7 @@ class Battle():
def list_combatants(self): def list_combatants(self):
for g in battle.groups: for g in self.groups:
if g.is_solo_group(): if g.is_solo_group():
print('{}: {}'.format(g.members[0].index, g.name)) print('{}: {}'.format(g.members[0].index, g.name))
else: else:
@ -180,9 +180,9 @@ def main():
battle.add_group(CombatGroup("Aristaire", [Combatant("Aristaire", hp=20, pc=True, surges=6, sw=1)], 0)) battle.add_group(CombatGroup("Aristaire", [Combatant("Aristaire", hp=20, pc=True, surges=6, sw=1)], 0))
battle.add_group(CombatGroup("Foobolds", [Combatant("Foobold", hp=50)], 20)) battle.add_group(CombatGroup("Foobolds", [Combatant("Foobold", hp=50), Combatant("Foobold", hp=50), Combatant("Foobold", hp=50), Combatant("Foobold", hp=50), Combatant("Foobold", hp=50)], 20))
battle.add_group(CombatGroup("Barglins", [Combatant("Barglin", hp=1)], 3)) battle.add_group(CombatGroup("Barglins", [Combatant("Barglin", hp=1), Combatant("Barglin", hp=1)], 3))
battle.add_group(CombatGroup("Orcs of Baz", [Combatant("Orc", hp=32)], 1)) battle.add_group(CombatGroup("Orcs of Baz", [Combatant("Orc", hp=32), Combatant("Orc", hp=32)], 1))
# ngroups = input_int('Number of enemy groups:') # ngroups = input_int('Number of enemy groups:')
# for i in range(1, ngroups+1): # for i in range(1, ngroups+1):