def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2, magic=0, magic_defense=1, talismanhp=0, gold=0) inventory_component = Inventory(26) equipment_inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, equipment_inventory=equipment_inventory_component) entities = [player] equipment_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=1) dagger = Entity(0, 0, '-', libtcod.darker_orange, "Dagger (+1 atk)", equippable=equipment_component) player.equipment_inventory.add_item(dagger) player.equipment.toggle_equip(dagger) item_component = Item(use_function=cast_magic, damage=2, maximum_range=3) magic_wand = Entity(0, 0, '|', libtcod.darker_sepia, "Magic Wand", item=item_component) player.inventory.add_item(magic_wand) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def from_json(json_data: Dict) -> "Entity": name = json_data["name"] entity_type = EntityType(json_data["entity_type"]) x = json_data["x"] y = json_data["y"] glyph = json_data["glyph"] fg = json_data["fg"] bg = json_data["bg"] blocks = json_data["blocks"] fighter = Fighter.from_json(json_data["fighter"]) ai = get_ai(json_data["ai"]) item = Item.from_json(json_data["item"]) # This seems to be necessary to avoid circular imports, since inventories are full of Entities: inv_data = json_data["inventory"] if inv_data is not None: inv_capacity_data = inv_data["capacity"] inv_items_data = inv_data["items"] inventory = Inventory(capacity=inv_capacity_data) inventory.items = [ Entity.from_json(item_data) for item_data in inv_items_data ] else: inventory = None stairs = Stairs.from_json(json_data["stairs"]) level = Level.from_json(json_data["level"]) # This is also necessary to avoid circular imports: equipment_data = json_data["equipment"] if equipment_data is not None: main_hand_data = equipment_data["main_hand"] off_hand_data = equipment_data["off_hand"] main_hand = Entity.from_json( main_hand_data) if main_hand_data is not None else None off_hand = Entity.from_json( off_hand_data) if off_hand_data is not None else None equipment = Equipment(main_hand, off_hand) else: equipment = None equippable = Equippable.from_json(json_data["equippable"]) buffs = [Buff.from_json(buff_data) for buff_data in json_data["buffs"]] entity = Entity(name, entity_type, x, y, glyph, fg, bg, blocks, fighter, ai, item, inventory, stairs, level, equipment, equippable) for buff in buffs: buff.owner = entity entity.buffs = buffs return entity
def take_turn(self, target, fov_map, game_map, entities): results = [] monster = self.owner if libtcod.map_is_in_fov(fov_map, monster.x, monster.y): if randint(1, 100) < 5: message_log.add_message( Message( 'The shaman barks something, and a goblin materializes beside you!', libtcod.light_violet)) monster = Entity((randint(-3, 3) + target.x), (randint(-3, 3) + target.y), 'g', libtcod.green, 'Clanfear Goblin', blocks=True, render_order=RenderOrder.ACTOR, fighter=Fighter(hp=15, defense=1, power=2, xp=45), ai=BasicMonster(), inventory=Inventory(5)) entities.add_new_entity(monster) elif monster.distance_to(target) >= 2: monster.move_astar(target, entities, game_map) elif target.fighter.hp > 0: attack_results = monster.fighter.attack(target) results.extend(attack_results) return results
def get_dummy_player(role): fighter_component = Fighter(hp=100, defense=12, power=12, hitdie=[1, 8], con=11, dmg=[1, 6]) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() animator_component = Animator() role_component = role player = Entity(0, 0, 1, libtcod.white, 'Player', 'Handsome fellow', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, role=role_component, animator=animator_component) return player
def create_monster_entity(self, x, y, entity_data, equipment=None): """ Create a monster entity at specific coordinates on the game map. Monster can have equipment (none by default). """ fighter_component = Fighter(**entity_data['kwargs']) ai_component = BasicMonster() inventory_component = None equipment_component = None if equipment: inventory_component = Inventory((len(equipment))) equipment_component = Equipment() char, color, name = entity_data['entity_args'] monster_entity = Entity(x, y, char, color, name, blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, ai=ai_component, inventory=inventory_component, equipment=equipment_component, description=entity_data['description']) if equipment: for item in equipment: equipment = self.create_item_entity(x, y, item, is_equippable=True) monster_entity.inventory.add_item(equipment) monster_entity.equipment.toggle_equip(equipment) return monster_entity
def get_game_variables(constants): fighter_component = Fighter("player") inventory_component = Inventory(26) level_component = Level() player = Entity(0, 0, "@", tcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component) game_state = GameStates.PLAYER_TURN entities = [player] game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, float(player.fighter.cr), constants['max_items_per_room']) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) return player, entities, game_map, message_log, game_state
def get_arena_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=3, speed=100) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity( [], 3, 3, "@", libtcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, ) entities = [player] constants["fov_radius"] = 100 # We can see the whole map in the arena game_map = GameMap(constants["map_width"], constants["map_height"]) game_map.make_arena(entities) message_log = MessageLog( constants["message_x"], constants["message_width"], constants["message_height"] ) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def initialize_player(self): player_components = { "Fighter": Fighter(hp=300, defense=2, power=5, factions=[Factions.PLAYER]), "Inventory": Inventory(26), "Devotee": Devotee(100), "StatusContainer": StatusContainer() } player = Entity(int(game_constants.screen_width / 2), int(game_constants.screen_height / 2), '@', libtcod.white, "Ascetic", True, RenderOrder.ACTOR, message_log=self.message_log, state=AIStates.INANIMATE, components=player_components) player.get_component("Inventory").equip_item( generate_starting_pistol(self.message_log)) return player
def get_game_variables(constants): fighter_comp = Fighter(20, 5, 5) inventory_comp = Inventory(10) level_comp = Level() equipment_component = Equipment() player = Entity('Player', int(constants['screen_width'] / 2), int(constants['screen_height'] / 2), '@', libtcod.white, is_player=True, fighter=fighter_comp, inventory=inventory_comp, level=level_comp, equipment=equipment_component) entities = [player] weapon = get_item('Hammer', 0, 0) player.inventory.add_item(weapon) player.equipment.toggle_equip(weapon) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) game_map.populate_dungeon(entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYER_TURN return player, entities, game_map, message_log, game_state
def spawn_actor(self, x, y, name, faction, path_map): if self.check_collision(x, y, path_map): return {'spawned': False} else: # If short you can walk through ;) walkable = self.entity_data['actors'][name]['walkable'] char = self.entity_gfx['actors'][name]['char'] colour = tuple( self.palette[self.entity_gfx['actors'][name]['colour']]) hp_max = self.entity_data['actors'][name]['hp_max'] attack = self.entity_data['actors'][name]['attack'] shield = self.entity_data['actors'][name]['shield'] inventory_capacity = self.entity_data['actors'][name].get( 'inventory_capacity') inventory_component = None if ( inventory_capacity == None) else Inventory(inventory_capacity) ai_component = get_ai(self.entity_data['actors'][name].get('ai')) entity = Entity( x, y, name, faction, char, colour, hp_max, attack, shield, (RenderOrder.ACTOR_SHORT if walkable else RenderOrder.ACTOR), walkable, inventory_component, ai_component) self.entities.append(entity) self.block_map[y, x] = (not walkable) return {'spawned': True}
def from_json(json_data): x = json_data.get('x') y = json_data.get('y') char = json_data.get('char') colour = lc.Color( json_data.get('colour')[0], json_data.get('colour')[1], json_data.get('colour')[2]) name = json_data.get('name') blocks = json_data.get('blocks') render_order = RenderOrder(json_data.get('render_order')) fighter = Fighter.from_json( json_data.get('fighter')) if json_data.get('fighter') else None ai = ai_from_json(json_data.get('ai')) if json_data.get('ai') else None item = Item.from_json( json_data.get('item')) if json_data.get('item') else None inventory = Inventory.from_json( json_data.get('inventory')) if json_data.get('inventory') else None stairs = Stairs.from_json( json_data.get('stairs')) if json_data.get('stairs') else None equipment = Equipment.from_json( json_data.get('equipment')) if json_data.get('equipment') else None level = Level.from_json( json_data.get('level')) if json_data.get('level') else None equip = Equip.from_json( json_data.get('equip')) if json_data.get('equip') else None return Entity(x, y, char, colour, name, blocks, render_order, fighter, ai, item, inventory, stairs, level, equipment, equip)
def get_game_variables(constants): fighter_component = Fighter(hp=100, str=3, dex=3) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() death_component = Death(kill_player) player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, death=death_component) entities = [player] dagger = generate_weapon('dagger', 0, 0) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) potion = generate_item('healing_potion', 0, 0) player.inventory.add_item(potion) game_map = GameMap(constants['map_width'], constants['map_height'], constants['version']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=3) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() caster_component = Caster(mana=5, focus=2) body_component = Body('anthropod') player = Entity(0,0, '@', (255,255,255), 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, caster=caster_component, inventory=inventory_component, level=level_component, equipment=equipment_component, body=body_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=1) dagger = Entity(0, 0, '-', constants['colors'].get('sky'), 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger, constants['colors']) player.equipment.toggle_equip(dagger) lexicon = get_lexicon() game_map = GameMap(constants['map_width'], constants['map_height']) make_map(game_map, constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, constants['colors'], lexicon) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state, lexicon
def create(self, name, class_uid, race_uid, stats, body_uid): """ Creates a new character based on arguments :return: """ uid = "player" new_instance = Character( uid=uid, name=name, character_class=self.get_class_template_by_uid(class_uid).copy(), character_race=self.get_race_template_by_uid(race_uid).copy(), stats=stats, display=Display((255, 255, 255), (0, 0, 0), "@"), body=self.factory_service.build_body_instance_by_uid(body_uid), inventory=Inventory()) health_base = new_instance.character_class.hit_die constitution_bonus = new_instance.get_stat_modifier( StatsEnum.Constitution) total_health = health_base + constitution_bonus new_instance.stats.set_core_current_value(StatsEnum.Health, total_health) new_instance.stats.set_core_maximum_value(StatsEnum.Health, total_health) return new_instance
def get_game_variables(): screen: pygame.display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) constants = get_constants() pygame.display.set_caption(constants['title']) manager = UIManager(width=constants['screen_width'], height=constants['screen_height'], main_menu_rect=constants['main_menu_rect'], message_log_rect=constants['message_log_rect'], theme=constants['theme1']) fighter_component = Fighter(hp=constants['start_hp'], defense=constants['start_def'], power=constants['start_power']) inventory_component = Inventory(constants['start_inventory']) player = Entity(x=constants['map_width'] // 2, y=constants['map_height'] // 2, name='player', sprite_type='player', dead_sprite_type='bones', render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component) entities = [player] screen_health_bar = HealthBar(name=player.name, hp=player.fighter.hp, max_hp=player.fighter.max_hp, bg_color=constants['health_bar_bg_color'], fg_color=constants['health_bar_fg_color'], rect=constants['health_bar_rect']) entity_info = EntityInfo(constants['entity_info_rect']) map_surf = MapSurface(constants['map_rect'], constants['sprites']) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(player, entities, constants['max_monsters_per_room'], constants['max_items_per_room']) camera = Camera(game_map, player, constants['camera_width'], constants['camera_height']) return screen, manager, screen_health_bar, entity_info, player, entities, game_map, map_surf, camera
def __init__(self, point, char, name, color, always_visible=False, blocks=True, ai=None, item=None, gear=None, species=Species.NONDESCRIPT, death=None, health=None, act_energy=4, interaction=Interactions.FOE, render_order=RenderOrder.ACTOR, animate=True): super(Character, self).__init__(point, char, name, color, blocks, always_visible, ai, item, gear, death=death, health=health, act_energy=act_energy, interaction=interaction, render_order=render_order, animate=animate) self.add_component(Equipment(), "equipment") self.add_component(Inventory(26), "inventory") self.species = species
def create_player(): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add(dagger) player.equipment.toggle_equip(dagger) return player
def create_monster(name): _base = Base(name='player', char='@', color=libtcod.white, render_order=RenderOrder.ACTOR) _body = Body() _health = Health() _inv = Inventory() _job = Job.BARBARIAN _pos = Position() _race = Race.HUMAN _soul = Soul(eccentricity=5, rank=10) _status = Status() monster = Entity(base=_base, body=_body, health=_health, inv=_inv, job=_job, pos=_pos, race=_race, soul=_soul, status=_status) monster.health.points = monster.health.max return monster
def get_game_variables(constants): """Initialize game variables.""" # === Entities === fighter_component = Fighter(hp=100, defense=1, power=3) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.lightest_grey, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, description='You.') entities = [player] equippable_component = Equippable(**dagger['kwargs']) char, color, name = dagger['entity_args'] starting_weapon = Entity(0, 0, char, color, name, render_order=RenderOrder.ITEM, equippable=equippable_component, description=dagger['description']) player.inventory.add_item(starting_weapon) player.equipment.toggle_equip(starting_weapon) # === Game map === game_map = GameMap(constants['map_width'], constants['map_height'], constants['room_min_size'], constants['room_max_size']) dungeon_type = Tunnel game_map.make_map(dungeon_type, player, entities) # === Message log === message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) # === Game state === game_state = GameStates.PLAYER_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(consts): # Player fighter_component = Fighter(hp=30, defense=2, power=5) inventory_comp = Inventory(26) level_comp = Level() player = Entity(0, 0, '@', tcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_comp, level=level_comp) entities = [player] # Game Map game_map = GameMap(consts['map_width'], consts['map_height']) game_map.make_map(consts['max_rooms'], consts['room_min'], consts['room_max'], consts['map_width'], consts['map_height'], player, entities, consts['max_monsts_room'], consts['max_items_room']) # Game State game_state = GameStates.PLAYER_TURN # Message Log message_log = MessageLog(consts['msg_x'], consts['msg_width'], consts['msg_height']) return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() #Create a player entity for the player player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] #Give a starting weapon - a dagger - to the player equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(config): fighter_component = Fighter(hp=100, defense=2, power=4) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] game_map = GameMap(config) game_map.make_map(player, entities) message_log = MessageLog(config) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=4) inventory_component = Inventory(26) level_component = Level() player = Entity(0, 0, '@', (255, 255, 255), 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component) entities = [player] game_map = GameMap(constants['map_width'], constants['map_height']) make_map(game_map, constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, constants['colors']) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=30, defence=2, power=5) inventory_component = Inventory(26) player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component) entities = [player] game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, constants['max_monsters_per_room'], constants['max_items_per_room']) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): # Entities fighter_component = Fighter(hp=10000, defense=1, strength=200, dexterity=0, intelligence=0, charisma=0) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcodpy.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] for itm in range(0, 25): item_component = Item(use_function=heal, amount=40) item = Entity(0, 0, '!', libtcodpy.violet, 'Healing Potion', render_order=RenderOrder.ITEM, item=item_component) player.inventory.add_item(item) equippable_component = Equippable(EquipmentSlots.MAIN_HAND, strength_bonus=2) dagger = Entity(0, 0, '-', libtcodpy.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # Game Map game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) # Message message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, "Dagger", equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants["map_width"], constants["map_height"]) game_map.make_map(constants["max_room"], constants["room_min_size"], constants["room_max_size"], constants["map_width"], constants["map_height"], player, entities) message_log = MessageLog(constants["message_x"], constants["message_width"], constants["message_height"]) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(name="Player", entity_type=EntityType.PLAYER, x=const.SCREEN_WIDTH // 2, y=const.SCREEN_HEIGHT // 2, glyph=ord('@'), fg=(255, 255, 255), blocks=True, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity("Dagger", EntityType.ITEM, 0, 0, ord('-'), fg=tcod.sky, equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) dungeon = {} game_map = GameMap(const.MAP_WIDTH, const.MAP_HEIGHT) game_map.make_map(const.MAX_ROOMS, const.ROOM_MIN_SIZE, const.ROOM_MAX_SIZE, const.MAP_WIDTH, const.MAP_HEIGHT, player) game_map.entities.append(player) dungeon.update({game_map.dungeon_level: game_map}) message_log = MessageLog(0, const.LOG_WIDTH, const.LOG_HEIGHT) game_state = GameState.PLAYER_TURN camera = Camera(0, 0, const.VIEWPORT_WIDTH - 1, const.VIEWPORT_HEIGHT - 1) current_level = 1 return player, dungeon, message_log, game_state, current_level, camera
def get_game_variables(constants): inventory_component = Inventory(26) body_component = get_human_body() player = Entity(int(constants['screen_width'] / 2), int(constants['screen_height'] / 2), '@', tcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, ai=Player, inventory=inventory_component, body=body_component) entities = [player] animator = Animator([]) turn_count = 0 game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(player, entities, constants) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYER_TURN return player, entities, animator, turn_count, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() skill_list_component = SkillList() learnable_skills_component = ['Shoulder Charge', 'Cloak of Quills', 'Throw Rock'] player = Entity(0, 0, CustomTile.PLAYER0, libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, skill_list=skill_list_component, learnable_skills=learnable_skills_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) sharp_rock = Entity(0, 0, CustomTile.SHARP_ROCK, libtcod.sky, 'Sharp Rock', equippable=equippable_component) player.inventory.add_item(sharp_rock) player.equipment.toggle_equip(sharp_rock) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): status_component = Status_Effects() job_component = Jobs() fighter_component = Fighter(hp=100, mana=50, defense=1, power=2, attack_dice_minimum=1, attack_dice_maximum=4, constitution=10, willpower=10, status_effects=status_component, job=job_component, nutrition=500, ac=1, accuracy=1) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() skill_component = Skills(50) player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, player=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, skills=skill_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state