def test_bastards_sting(self): """...""" weapon_test = {} for _class in ["paladin", "antipaladin"]: try: player = PCreature(scene=self.scene, pos=(0, 0), _class=_class) except ValueError as e: player.combat._class = _class weapon = ItemEntity(name="bastard's sting", pos=(0, 0), scene=self.scene) weapon.item.pick_up(player) weapon.item.use(player) weapon_test[_class] = { "magic": int(weapon.equipment.magic), "on_hit_actions": list(weapon.equipment.on_hit_actions), "on_turn_actions": list(weapon.equipment.on_turn_actions), } weapon.item.drop(player) self.assertEqual(weapon_test['paladin']['magic'], 2) self.assertEqual(weapon_test['paladin']['on_hit_actions'], []) self.assertEqual(weapon_test['paladin']['on_turn_actions'], []) self.assertEqual(weapon_test['antipaladin']['magic'], 5) self.assertEqual(weapon_test['antipaladin']['on_hit_actions'], ['unholy']) self.assertEqual(weapon_test['antipaladin']['on_turn_actions'], ['unholy aurea'])
def setUp(self): """...""" def dummy(*args, **kwargs): pass class Dummy: pass class Scene(): add_obj = dummy rem_obj = dummy gfx = Dummy() gfx.msg_log = Dummy() gfx.msg_log.add = print gfx.hp_bar = Dummy() gfx.hp_bar.set_value = dummy print("\n", "#" * 30, "\n%s" % __file__) self.scene = Scene() self.player = PCreature(scene=self.scene, pos=(0, 0), _class="fighter", race="human")
def __init__(self, *args, **kwargs): """...""" super().__init__(*args, **kwargs) self.tile = TileEntity(name="floor", scene=self, pos=(0, 0)) self.feature = FeatureEntity(name="stair_up", scene=self, pos=(0, 0)) self.item = ItemEntity(name='healing potion', scene=self, pos=(0, 0)) self.player = PCreature(scene=self, pos=(0, 0)) self.beast = NPCreature(name="orc", scene=self, pos=(0, 0))
def test_bastards_sting(self): """...""" scene = self.scene player = PCreature(scene=scene, pos=(0, 0)) scene.player = player weapon = ItemEntity(name="bastard's sting", pos=(0, 0), scene=scene) weapon.item.pick_up(player) weapon.item.use(player) if __name__ == '__main__': tree_view(weapon, expand=[WeaponComponent])
def test_dwarf_rogue(self): """...""" player = PCreature(scene=self.scene, pos=(0, 0), _class="rogue", race="dwarf") self.assertEqual(player.combat.skills.skills['appraise'].trained, True) self.assertEqual(player.combat.skills.skills['appraise'].ranks, 2) self.assertEqual(player.combat.skills.skills['appraise'].value, 5) before_armor = int(player.combat.skills.skills['swim'].value) armor = ItemEntity(name="studded leather", pos=(0, 0), scene=self.scene) armor.item.pick_up(player) armor.item.use(player) # armor. """ import tree_view skills = player.combat.skills combat = player.combat inventory = player.inventory player_dict = tree_view.Tree(player) player_dict["combat"] = tree_view.Tree(combat) player_dict["inventory"] = [ tree_view.Tree(item, expand=[obj_components.Armor]) for item in inventory] player_dict["combat"]["skills"] = tree_view.Tree(skills) from mylib.data_tree import tk_tree_view tk_tree_view(player_dict) """ self.assertEqual(player.combat.skills.skills['swim'].value, before_armor + armor.equipment.armor_check_penalty)
def test_all(self): """...""" d = {} for _class in combat.char_roll.classes: for race in combat.char_roll.races: d["_".join((_class, race))] = PCreature( scene=self.scene, pos=(0, 0), _class=_class, race=race).combat if __name__ == '__main__': for character in d.keys(): feats = d[character].__dict__.pop('feats') skills = d[character].__dict__.pop('skills') d[character] = tree_view(d[character]) d[character]['feats'] = tree_view( feats, expand=[combat.feats.FeatNode]) d[character]['skills'] = tree_view( skills, expand=[combat.skills.SkillNode]) tree_view(d)
def test_all(self): return import tree_view d = {} for _class in ["rogue"]: # combat.char_roll.classes: for race in ["dwarf"]: # combat.char_roll.races: d["_".join((_class, race))] = PCreature(scene=self.scene, x=0, y=0, _class=_class, race=race).combat for character in d.keys(): skills = d[character].__dict__.pop('skills') d[character] = tree_view.Tree(d[character]) d[character] = tree_view.Tree(skills, expand=[combat.skills.SkillNode]) from mylib.data_tree import tk_tree_view tk_tree_view(d)
def new_level(self, header, character): """Create a new map level for the session.""" scene = self.parent scene.state = 'loading' # TODO use try/except to handle first level (no record of player) if scene.current_level: try: scene.rem_obj(scene.player, "creatures", scene.player.pos) except AttributeError: pass # going back to a level that already exists if header in scene.maps: # set the level number so that dynamic @properties will use it scene.maps.set_current(header) else: # going to a new level - or the first one # set the level number so that dynamic @properties will use it scene.maps.add(rnd_gen.create_map(header=header)) scene.maps.set_current(header) current_level = scene.current_level populate_level.populate(scene=scene, _map=current_level) current_level.set_tile_variation() current_level.set_tiling_index() for tile in current_level.tiles: tile.scene = scene scene.player = PCreature(scene=scene, pos=(0, 0), combat=character) scene.player.set_starting_position(pos=scene.current_level._start, header=scene.current_level.header) scene.player.active = True scene.state = 'playing'