battleman.py: did some cleanup, got Battle.begin() to work
This commit is contained in:
parent
38108a4d7b
commit
60df5f6bd0
18
battleman.py
18
battleman.py
|
@ -6,7 +6,7 @@
|
|||
# Tuned pretty specifically to D&D 4e for now... need a templatized system
|
||||
# to do anything fancier... may develop that at some point.
|
||||
|
||||
import dice
|
||||
from dice import Dice
|
||||
import sys
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ class CombatGroup():
|
|||
def from_input(cls):
|
||||
name = raw_input("Name: ")
|
||||
hp = input_int('hp')
|
||||
init_mod = input_int('init mod')
|
||||
init_mod = input_int('init mod', 0)
|
||||
ap = input_int('action points', 0)
|
||||
surges = input_int('healing surges', 0)
|
||||
|
||||
|
@ -53,7 +53,7 @@ class CombatGroup():
|
|||
|
||||
|
||||
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'])
|
||||
|
||||
|
||||
|
@ -141,8 +141,8 @@ class Battle():
|
|||
return
|
||||
|
||||
for g in self.groups:
|
||||
if g.single() and g.members[0].pc:
|
||||
raw_input('Initiative for {}: '.format(g.name))
|
||||
if g.is_solo_group() and g.members[0].pc:
|
||||
g.set_init(input_int('Initiative for {}'.format(g.name)))
|
||||
else:
|
||||
g.roll_init()
|
||||
|
||||
|
@ -155,7 +155,7 @@ class Battle():
|
|||
|
||||
|
||||
def list_combatants(self):
|
||||
for g in battle.groups:
|
||||
for g in self.groups:
|
||||
if g.is_solo_group():
|
||||
print('{}: {}'.format(g.members[0].index, g.name))
|
||||
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("Foobolds", [Combatant("Foobold", hp=50)], 20))
|
||||
battle.add_group(CombatGroup("Barglins", [Combatant("Barglin", hp=1)], 3))
|
||||
battle.add_group(CombatGroup("Orcs of Baz", [Combatant("Orc", hp=32)], 1))
|
||||
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), Combatant("Barglin", hp=1)], 3))
|
||||
battle.add_group(CombatGroup("Orcs of Baz", [Combatant("Orc", hp=32), Combatant("Orc", hp=32)], 1))
|
||||
|
||||
# ngroups = input_int('Number of enemy groups:')
|
||||
# for i in range(1, ngroups+1):
|
||||
|
|
Loading…
Reference in New Issue
Block a user