#!/usr/bin/python # # battleman.py - RPG Battle Manager # # A table-top RPG battle flow manager # Tuned pretty specifically to D&D 4e for now... need a templatized system # to do anything fancier... may develop that at some point. class Combatant(): def __init__(self, name, hp, pc=False, surges=0, ap=0, sw=0, recharges=[], count=1): self.name = name self.hp = hp self.pc = pc self.surges = surges self.ap = ap self.sw = sw self.recharges = [] self.init = 0 self.conditions = [] self.count = count def set_init(self, init): self.init = init def add_condition(self, cond_type, duration): condition.type = cond_type condition.duration = duration self.conditions.append(condition) def turn_begin(self): add_msg("Initiative: " + self) def __str__(self): return "{} ({hp} hp)".format(self.name, hp=self.hp) def combatant_from_input(): name = raw_input("Name: ") hp = int(raw_input("hp: ")) surges = raw_input("surges [0]: ") if surges: surges = int(surges) else: surges = 0 recharges = [] recharge = '-1' while True: recharge = raw_input("recharge: ").split(',') if recharge == ['']: break else: recharges.append(recharge) count = raw_input("count[1]: ") if count: count = int(count) else: count = 1 return Combatant(name, hp, pc=0, surges=surges, recharges=recharges, count=count) def main(): combatants = [] # hard-coding test cases for now. # Eventually, use a state-saving text file that's easy to edit combatants.append(Combatant("Adele", hp=26, pc=True, surges=8, sw=1)) combatants.append(Combatant("Aristaire", hp=20, pc=True, surges=6, sw=1)) ngroups = int(raw_input("Num enemy groups: ")) for i in range(1, ngroups+1): print("Adding enemy group {}".format(i)) combatants.append(combatant_from_input()) for c in combatants: print(c) # while True: # do_prompt() if __name__ == '__main__': main()