Example #1
0
 def test_save_and_load_player_with_items(self):
     first_item = parse_item_file('short_sword')
     second_item = parse_item_file('life_potion')
     inventory = [first_item, second_item]
     player = random_player_entity(name="raimund",
                                   classes=['warrior'],
                                   race='human',
                                   items=inventory)
     player_saved = player.save('player')
     loaded_player = load_player(player_saved, True)
     self.assertFalse(loaded_player.turn_is_finished())
     self.assertTrue(first_item in loaded_player.items)
     self.assertTrue(second_item in loaded_player.items)
Example #2
0
 def test_save_and_load_used_weapon(self):
     weapon = parse_item_file('short_sword')
     weapon.used()
     weapon_saved = weapon.save('item')
     loaded_weapon = load_item(weapon_saved)
     self.assertEqual(weapon.durability_max, loaded_weapon.durability_max)
     self.assertEqual(weapon.durability, loaded_weapon.durability)
 def test_save_and_load_item(self):
     potion = parse_item_file('life_potion')
     potion_saved = potion.save('item')
     loaded_potion = load_item(potion_saved)
     self.assertEqual(potion.desc, loaded_potion.desc)
     self.assertEqual(potion.price, loaded_potion.price)
     self.assertEqual(potion.resell_price, loaded_potion.resell_price)
Example #4
0
 def test_save_and_load_player_with_equipment(self):
     helmet = parse_item_file('helmet')
     equipment = [helmet]
     player = random_player_entity(name="raimund",
                                   classes=['warrior'],
                                   race='human',
                                   equipments=equipment)
     player_saved = player.save('player')
     loaded_player = load_player(player_saved, True)
     self.assertFalse(loaded_player.turn_is_finished())
     self.assertTrue(helmet in loaded_player.equipments)
Example #5
0
 def test_save_and_load_foe(self):
     foe = random_foe_entity(name="skeleton_cobra",
                             reach=[2],
                             keywords=[Keyword.CAVALRY],
                             loot=[(parse_item_file('monster_meat'),
                                    rd.random()),
                                   (random_gold(), rd.random())])
     foe_saved = foe.save('foe')
     loaded_foe = load_foe(foe_saved, True, 0, 0)
     self.assertEqual(foe.name, loaded_foe.name)
     self.assertEqual(foe.pos, loaded_foe.pos)
     self.assertEqual(foe.hp, loaded_foe.hp)
     self.assertEqual(foe.defense, loaded_foe.defense)
     self.assertEqual(foe.res, loaded_foe.res)
     self.assertEqual(foe.strength, loaded_foe.strength)
     self.assertEqual(foe.strategy, loaded_foe.strategy)
     self.assertEqual(foe.lvl, loaded_foe.lvl)
     self.assertEqual(foe.skills, loaded_foe.skills)
     self.assertEqual(foe.reach, loaded_foe.reach)
     self.assertEqual(foe.keywords, loaded_foe.keywords)
     self.assertEqual(foe.alterations, loaded_foe.alterations)
     self.assertEqual(foe.potential_loot, loaded_foe.potential_loot)