def test_05_battle_multiple(self): traits = character.CharacterCollection(ref_folder) c1 = traits.generate_random_character() c2 = traits.generate_random_character() rules = battle.BattleRules(rules_file) sim = battle.BattleSimulator(c1, c2, traits, rules, 1000) if sim.winner == c2.name or sim.winner == c1.name: self.assertEqual(True, True) else: self.assertEqual(True, False) #print(sim) self.assertEqual(str(sim)[0:17], 'After 1000 fights')
def run_simulation(c1, c2): """ using character and planet, run the simulation """ print('running simulation...') traits = character.CharacterCollection(character.fldr) c1 = traits.generate_random_character() c2 = traits.generate_random_character() print(c1) print(c2) rules = battle.BattleRules(battle.rules_file) b = battle.Battle(c1, c2, traits, rules, print_console='Yes') print(b.status)
def test_04_battle_one_char(self): traits = character.CharacterCollection(ref_folder) c1 = traits.generate_random_character() c2 = traits.generate_random_character() rules = battle.BattleRules(rules_file) b = battle.Battle(c1, c2, traits, rules, print_console='No') self.assertEqual(len(str(b)) > 5, True) if c2.name in str(b) or c1.name in str(b): self.assertEqual(True, True) else: self.assertEqual(True, False) b2 = battle.Battle(c1, c2, traits, rules, print_console='Yes') self.assertEqual(len(str(b2)) > 5, True) if c2.name in str(b2) or c1.name in str(b2): self.assertEqual(True, True) else: self.assertEqual(True, False)
}, ['cast'], 'Example char', ['Apple', 'knife']) print(c1) """ CHARACTER = Jim Race = Orc Class = Mage STATS = STA:5 AGI:5 INT:8 Health:20 max_health:20 STR:2 Story = Example char SKILLS = cast INVENTORY = Apple, knife """ # load rules and traits data rules_file = fldr + os.sep + 'data' + os.sep + 'battle.rules' traits = character.CharacterCollection(os.path.join(fldr, 'data')) rules = battle.BattleRules(rules_file) # create a random character c2 = traits.generate_random_character() c2.save_to_file(os.path.join(op_fldr, 'random_char.txt')) print(c2) """ CHARACTER = Rekkaj Race = Orc Class = Ranger STATS = STA:9 AGI:7 INT:2 CON:8 Health:22 max_health:22 STR:6 Story = A young scholar with a burning desire to learn SKILLS = Slow Monster, Teleport Other, Detect Monsters INVENTORY = 27 gold, food, stick, stick """
def test_03_battle_rules(self): rules = battle.BattleRules(rules_file) self.assertEqual(len(str(rules)) > 500, True) #print(rules) self.assertEqual(rules.all_rules['dmg_min'], '2')