def new_game(): """ Starts a new game, with a default player on level 1 of the dungeon. Returns the player object. """ # Must initialize the log before we do anything that might emit a message. log.init() fighter_component = Fighter(hp=100, defense=1, power=2, xp=0, death_function=player_death) player = Object(algebra.Location(0, 0), '@', 'player', libtcod.white, blocks=True, fighter=fighter_component) player.inventory = [] player.level = 1 player.game_state = 'playing' # True if there's a (hostile) fighter in FOV player.endangered = False obj = miscellany.dagger() player.inventory.append(obj) actions.equip(player, obj.equipment, False) obj.always_visible = True cartographer.make_map(player, 1) renderer.clear_console() renderer.update_camera(player) log.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red) log.message('Press ? or F1 for help.') return player
def next_level(player, portal): """ Advance to the next level (changing player.current_map). Heals the player 50%. Returns the Map of the new level. """ actions.heal(player.fighter, player.fighter.max_hp / 2) old_map = player.current_map generator = portal.generator need_stairs = generator(player, player.current_map.dungeon_level + 1) renderer.clear_console() renderer.update_camera(player) if need_stairs: stairs = Object(player.pos, '>', 'stairs up', libtcod.white, always_visible=True) stairs.destination = old_map stairs.dest_position = portal.pos player.current_map.objects.insert(0, stairs) player.current_map.portals.insert(0, stairs) return player.current_map
def revisit_level(player, portal): """ Return to a level the player has previously visited (changing player.current_map). Does *not* heal the player. """ player.current_map = portal.destination player.pos = portal.dest_position # Call to initialize_fov() should be redundant but in practice seems to have # worked around an intermittent bug. player.current_map.initialize_fov() player.current_map.fov_needs_recompute = True renderer.update_camera(player) renderer.clear_console()
def next_level(player, portal): """ Advance to the next level (changing player.current_map). Heals the player 50%. Returns the Map of the new level. """ log.message('You take a moment to rest, and recover your strength.', libtcod.light_violet) actions.heal(player.fighter, player.fighter.max_hp / 2) log.message('After a rare moment of peace, you descend deeper into the heart of the dungeon...', libtcod.red) old_map = player.current_map cartographer.make_map(player, player.current_map.dungeon_level + 1) renderer.clear_console() renderer.update_camera(player) # Create the up stairs at the current position. stairs = Object(player.pos, '>', 'stairs up', libtcod.white, always_visible=True) stairs.destination = old_map stairs.dest_position = portal.pos player.current_map.objects.insert(0, stairs) player.current_map.portals.insert(0, stairs) return player.current_map
def new_game(): """ Starts a new game, with a default player on level 1 of the dungeon. Returns the player object. """ # Must initialize the log before we do anything that might emit a message. log.init() quest.display_welcome() player = Object(None, '@', 'player', libtcod.white, blocks=True, fighter=Fighter( hp=36, death_function=player_death, skills={'bow':70, 'first aid':24, 'grappling':40})) player.inventory = [] player.level = 1 player.game_state = 'playing' player.skill_points = 0 player.turn_count = 0 # True if there's a (hostile) fighter in FOV player.endangered = False _new_equipment(player, Object(None, '(', 'silk undertunic', libtcod.dark_sky, item=Item(description='A thick under-tunic of raw silk; prevents 2 bleeding.'), equipment=Equipment(slot='underclothes', bleeding_defense=2))) _new_equipment(player, Object(None, '(', 'quilt kaftan', libtcod.dark_sky, item=Item(description='A heavy quilted kaftan; keeps you warm and prevents 2 wound.'), equipment=Equipment(slot='robes', defense_bonus=2))) _new_equipment(player, Object(None, '(', 'felt cap', libtcod.dark_sky, item=Item(description='A Phrygian felt cap with a loose veil to keep the sun off.'), equipment=Equipment(slot='head'))) _new_equipment(player, miscellany.horn_bow()) _new_equipment(player, miscellany.arrow(12)) _new_equipment(player, miscellany.dagger()) _new_item(player, miscellany.kumiss(4)) _new_item(player, miscellany.bandage(4)) mountain_cartographer.make_map(player, 1) renderer.update_camera(player) renderer.finish_welcome() log.message('At last you have reached the foot of the mountain. She waits above.', libtcod.red) log.message('Press ? or F1 for help.') # _start_near_quarry(player) # _start_near_grotto(player) # _start_near_peak(player) # _start_near_end(player) # TEST # actions.add_to_map(player.current_map, player.pos, miscellany.sword()) # actions.add_to_map(player.current_map, player.pos, miscellany.roundshield()) libtcod.map_compute_fov( player.current_map.fov_map, player.x, player.y, config.TORCH_RADIUS, config.FOV_LIGHT_WALLS, config.FOV_ALGO) return player
def new_game(): """ Starts a new game, with a default player on level 1 of the dungeon. Returns the player object. """ # Must initialize the log before we do anything that might emit a message. log.init() quest.display_welcome() player = Object(None, '@', 'player', libtcod.white, blocks=True, fighter=Fighter(hp=36, death_function=player_death, skills={ 'bow': 70, 'first aid': 24, 'grappling': 40 })) player.inventory = [] player.level = 1 player.game_state = 'playing' player.skill_points = 0 player.turn_count = 0 # True if there's a (hostile) fighter in FOV player.endangered = False _new_equipment( player, Object( None, '(', 'silk undertunic', libtcod.dark_sky, item=Item(description= 'A thick under-tunic of raw silk; prevents 2 bleeding.'), equipment=Equipment(slot='underclothes', bleeding_defense=2))) _new_equipment( player, Object( None, '(', 'quilt kaftan', libtcod.dark_sky, item=Item( description= 'A heavy quilted kaftan; keeps you warm and prevents 2 wound.' ), equipment=Equipment(slot='robes', defense_bonus=2))) _new_equipment( player, Object( None, '(', 'felt cap', libtcod.dark_sky, item=Item( description= 'A Phrygian felt cap with a loose veil to keep the sun off.'), equipment=Equipment(slot='head'))) _new_equipment(player, miscellany.horn_bow()) _new_equipment(player, miscellany.arrow(12)) _new_equipment(player, miscellany.dagger()) _new_item(player, miscellany.kumiss(4)) _new_item(player, miscellany.bandage(4)) mountain_cartographer.make_map(player, 1) renderer.update_camera(player) renderer.finish_welcome() log.message( 'At last you have reached the foot of the mountain. She waits above.', libtcod.red) log.message('Press ? or F1 for help.') # _start_near_quarry(player) # _start_near_grotto(player) # _start_near_peak(player) # _start_near_end(player) # TEST # actions.add_to_map(player.current_map, player.pos, miscellany.sword()) # actions.add_to_map(player.current_map, player.pos, miscellany.roundshield()) libtcod.map_compute_fov(player.current_map.fov_map, player.x, player.y, config.TORCH_RADIUS, config.FOV_LIGHT_WALLS, config.FOV_ALGO) return player