def cmd_take_test(): # Test 'take' command ## Setup # create scene a_map = map_.Map('story') a_map.add_player() sc = map_gen.new_scene(a_map, 'random', (0,0)) # empty player inventory player = sc.characters['player'] player.inventory = [] # create item w = items.get_weapon("Hunting Knife") # add items to scene sc.items.append(w) ## Testing the 'take' command # no item ID msg = sc.cmd_take(None) ok_(msg == "Please indicate item ID.") # invalid item ID msg = sc.cmd_take('9') ok_(msg == "No such item.") # invalid item ID msg = sc.cmd_take('nop') ok_(msg == "No such item.") # valid scenario msg = sc.cmd_take('0') ok_(msg == "Took Hunting Knife.") ok_(w not in sc.items)
def cmd_search_test(): # Test 'search' command # create scene a_map = map_.Map('story') sc = map_gen.new_scene(a_map, 'random', (0,0)) # create items wps = [items.get_weapon("Hunting Knife")] # add items to item stash stash = map_.ItemStash(wps) # add item stash to scene sc.features.append(stash) # search scene and check results msg = sc.cmd_search() ok_("Hunting Knife" in msg)
# Color palette: COLOR_DARKEST = (26, 14, 5) COLOR_DARK = (50, 31, 19) COLOR_LIGHT = (130, 102, 84) COLOR_LIGHTEST = (203, 163, 136) # Tile TILE_W = TILE_H = 32 DEFAULT_MONSTER_LIST = [get_monster("rattlesnake"), get_monster("small_scorpion"), get_monster("big_scorpion"), get_monster("road_runner"), get_monster("coyote"), get_monster("camel"), get_monster("skink")] DEFAULT_FOOD_LIST = [get_foodstuff("cactus_piece")] DEFAULT_HYDRATION_LIST = [get_water("water_bottle")] DEFAULT_MEDICINE_LIST = [get_medicine("antidote")] DEFAULT_WEAPON_LIST = [get_weapon("stick"), get_weapon("sharp_rock"), get_weapon("pointy_stick")] OASIS_MONSTER_LIST = DEFAULT_MONSTER_LIST + [get_monster("crocodile")] CAMP_FOOD_LIST = [get_foodstuff("cactus_piece"), get_foodstuff("granola_bar")] CAMP_WEAPON_LIST = [get_weapon("plusone_mace")] PYRAMID_WEAPON_LIST = [get_weapon("warped_blade")] # Character: CHANCE_DEC = 20 WATER_DEC = 10 HUNGER_DEC = 10 POISON_DAMAGE = 5
def get_weapon_test(): # Tests if weapon can be created by indicating weapon name weapon = items.get_weapon('Hunting Knife') ok_(weapon.desc['name'] == 'Hunting Knife')
def roll_items(self): """ Generate default equipment.""" self.pick_up(items.get_weapon("Hunting Knife"))