def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2, magic=0) inventory_component = Inventory(26) equipment_inventory_component = Equipment_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", equippable=equipment_component) player.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 get_game_variables(constants): ''' Initializes game variables ''' # creates player if DEBUG == 1: fighter_component = Fighter(hp=1000, defense=1, power=20) else: 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] # starting weapon equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) cashable_component = Cashable(10) dagger = Entity(0, 0, '/', libtcod.orange, 'Rusty Dagger (+2A)', equippable=equippable_component, cashable=cashable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # initialize game 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 create_fighting_entity(game, entity_defname, x, y, player=False): # we get the entity stats from the defname entity_stats = Compendium.get_monster(entity_defname) # we get the base of the creature if entity_stats: base = entity_stats.get("base") else: entity_stats = {} base = entity_defname base_stats = Compendium.get_base_monster(base) if not base_stats: base_stats = {} if not base_stats and not entity_stats: return False # we create the entity entity = create_entity(game, base_stats, entity_stats) entity.blocks = True entity.render_order = RenderOrder.ACTOR entity.x, entity.y = x, y # we create fighting component fighter_component = create_fighter_component(base_stats, entity_stats) entity.add_component(fighter_component, 'fighter') # we create brain component ai_component = create_ai_component(base_stats, entity_stats) entity.add_component(ai_component, 'ai') # We calculate xp value xp_value = calculate_xp_value(entity.fighter) entity.fighter.xp_value = xp_value if player: equipment_component = Equipment() entity.add_component(equipment_component, 'equipment') inventory_component = Inventory(26) entity.add_component(inventory_component, 'inventory') level_component = Level() entity.add_component(level_component, 'level') entity.fighter.death_function = kill_player return entity
def get_game_variables(constants): fighter_component = Fighter(roll_character_attributes(), current_hp=100, base_armor_class=10, base_armor=10, base_cth_modifier=3, base_speed=100, base_attack_cost=100, base_movement_cost=100, base_natural_hp_regeneration_speed=50, base_damage_dice={ "physical": [[1, 3]], "fire": [], "ice": [], "lightning": [], "holy": [], "chaos": [], "arcane": [], "poison": [], }) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, 0x1004, "white", 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, equipment=equipment_component, level=level_component) entities = [player] message_log = MessageLog(constants["message_x"], constants["message_width"], constants["message_height"]) game_map: GameMap = GameMap(width=constants["map_width"], height=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_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(config): level_component = Level(current_level=0, current_xp=0, level_up_base=2, level_up_factor=3, level_up_exponent=2) player = Entity(0, 0, ' ', libtcod.white, 'Ghost', blocks=True, render_order=RenderOrder.GHOST, level=level_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=2) inventory_component = Inventory(20) level_component = Level() equipment_component = Equipment() player = Entity(int(constants['screen_width'] / 2), int(constants['screen_height'] / 2), '@', tcod.red, 'Player', blocks=True, fighter=fighter_component, render_order=RenderOrder.ACTOR, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', tcod.sky, 'Rusty 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.PLAYER_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): if constants['dev_mode'] == 1: fighter_component = Fighter(hp=999, defense=999, power=999) else: fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player_f_name = get_generic_first_name() player_l_name = get_generic_last_name() player = Entity(0, 0, '@', libtcod.white, player_f_name, player_l_name, blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, is_pc=True) 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
def warlord(point=None, dungeon_level=1): #create a warlord ai_component = WarlordNPC() health_component = Health(50) npc = Character(point, 'W', 'Warlord', COLORS.get('warlord'), ai=ai_component, species=Species.ORC, death=WarlordDeath(), health=health_component) npc.add_component(Offence(base_power=10), 'offence') npc.add_component(Defence(defence=4), 'defence') npc.add_component(Level(xp_value=10), 'level') npc.movement.routing_avoid.extend(npc_avoid) npc_level = (dungeon_level - 1) + randint(-1, 1) if npc_level > 1: npc.level.random_level_up(npc_level - 1) item = equipment.create_weapon('longsword') item.base_name = item.base_name + " of I'll F*****G Have You" item.color = COLORS.get('equipment_epic') item.equippable.power = item.equippable.power * 2 npc.inventory.add_item(item) npc.equipment.toggle_equip(item) shield = equipment.create_armour('steel shield') shield.base_name = shield.base_name + " of Hide and Seek" shield.color = COLORS.get('equipment_epic') shield.equippable.power = item.equippable.defence * 2 npc.inventory.add_item(shield) npc.equipment.toggle_equip(shield) breastplate = equipment.create_armour('breastplate') breastplate.base_name = breastplate.base_name + " of Rebounding" breastplate.color = COLORS.get('equipment_epic') breastplate.equippable.power = item.equippable.defence * 2 npc.inventory.add_item(breastplate) npc.equipment.toggle_equip(breastplate) return npc
def get_game_variables(constants): # Creates the player's components. fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() # Creates the player object. 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) # Creates a list of initial static entities. entities = [player] # Gives the player a starting weapon. 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) # Creates the game map and calls its make_map function. 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) # Creates the message log that will store text messages. message_log = MessageLog(constants["message_x"], constants["message_width"], constants["message_height"]) # Stores the current game state integer value, e.g. PLAYERS_TURN is 1. game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants, race=None): if race: fighter_component = Fighter( hp=race.value.get('stats').get('max_health'), defense=race.value.get('stats').get('str'), power=race.value.get('stats').get('str')) else: 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 = FloorMap(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 necromancer(point=None, dungeon_level=1): #create a necromancer health_component = Health(30) ai_component = NecromancerNPC() npc = Character(point, 'N', 'necromancer', COLORS.get('necromancer'), ai=ai_component, species=Species.NONDESCRIPT, health=health_component) npc.add_component(Offence(base_power=12), 'offence') npc.add_component(Defence(defence=8), 'defence') npc.add_component(Level(xp_value=10), 'level') npc.add_component(Children(6), 'children') npc.movement.routing_avoid.extend(npc_avoid) npc_level = (dungeon_level - 1) + randint(-1, 1) if npc_level > 1: npc.level.random_level_up(npc_level - 1) weapon = equipment.random_magic_weapon(dungeon_level=dungeon_level) weapon.lootable = True npc.inventory.add_item(weapon) npc.equipment.toggle_equip(weapon) num_of_potions = randint(0, 3) for _ in range(num_of_potions): potion = equipment.random_potion(dungeon_level=dungeon_level) potion.lootable = True npc.inventory.add_item(potion) num_of_scrolls = randint(0, 3) for _ in range(num_of_scrolls): scroll = equipment.random_scroll(dungeon_level=dungeon_level) scroll.lootable = True npc.inventory.add_item(scroll) return npc
def get_game_variables(constants: Dict) -> Tuple: # initialize player/fighter and inventory fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(int(constants['screen_width'] / 2), int(constants['screen_height'] / 2), "@", constants['colors'].get('player'), 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] # set up inventory stuff equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', tcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # initialize 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, constants['colors']) # initialize blank message log message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) # set initial game state game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): # Components fighter_component = Fighter(hp=100, defense=2, power=5) inventory_component = Inventory(26) level_component = Level() equipement_component = Equipement() # Entities player = Entity(int(constants['screen_width'] / 2) - 10, int(constants['screen_height'] / 2), "Player", "@", libtcod.white, fighter=fighter_component, ai=None, inventory=inventory_component, level=level_component, equipement=equipement_component, render_order=RenderOrder.ACTOR) entities = [player] # Give player equipement starter pack equippable_component = Equippable(EquipementSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, 'Dagger', '-', libtcod.sky, equippable=equippable_component) player.inventory.add_item(dagger) player.equipement.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['room_min_size'], constants['room_max_size'], constants['max_rooms'], constants['map_width'], constants['map_height'], player, entities) # Message Log init message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) # Game State 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) social_component = Social(bond=0) 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_x'], constants['map_width'], constants['map_height']) #game_map = GameMap(constants['map_x'],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']) #hud = HUD() game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def __init__(self, hp, defense, power, body, fov=5, xp=0, will_power=1, level=None): self.base_max_hp = hp self.hp = hp self.base_defense = defense self.base_power = power self.base_fov = fov self.xp = xp self.will_power = will_power self.body = body self.level = level or Level()
def create_player(): attributes = { 'strength': 20, 'dexterity': 10, 'constitution': 30, 'intelligence': 10, 'wisdom': 10, 'charisma': 10, } fighter_component = Fighter(defense=player_vars.defense, power=player_vars.power) inventory_component = Inventory(player_vars.inventory_size) level_component = Level() equipment_component = Equipment() caster_component = Caster(1) return Entity(0, 0, char=player_vars.char, color=color_vars.player, name=player_vars.name, blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, attributes=attributes, caster=caster_component)
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, '@', libtcod.white, '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']) 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 return constants
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, strength=2, attack=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', tc.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, turn_count=0) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, att_bonus=2, str_bonus=1) dagger = Entity(0, 0, '-', tc.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 = GameState.PLAYER_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): # instantiate entities 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) # Instantiate world map. # Monsters will be added to entities upon map generation. 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_panel_x"], constants["message_panel_width"], constants["message_panel_height"]) # first turn in world should be player's game_state = GameStates.PLAYER_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() gold_component = Gold(100) equipment_component = Equipment() player = Entity(0, 0, '@', (255, 255, 255), 'Player', blocks=True, fighter=fighter_component, render_order=RenderOrder.ACTOR, inventory=inventory_component, level=level_component, gold=gold_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', constants['colors'].get('sky'), 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger, constants['colors']) player.equipment.toggle_equip(dagger) 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 hornets(point=None, dungeon_level=1): health_component = Health(2) creature = Character(point, chr(178), 'hornet', COLORS.get('hornet'), ai=BasicNPC(), species=Species.INSECT, health=health_component, act_energy=3) creature.add_component(Offence(base_power=1), 'offence') creature.add_component(Defence(defence=1), 'defence') creature.add_component(Level(xp_value=10), 'level') creature.add_component( Display([ chr(176), chr(176), chr(176), chr(177), chr(177), chr(177), chr(178), chr(178), chr(178) ]), 'display') creature.add_component( DamageModifier(blunt=0.8, slashing=0.8, fire=1.2, ice=1.2, electric=1.2), 'damagemodifier') teeth = equipment.teeth() teeth.lootable = False creature.inventory.add_item(teeth) creature.equipment.toggle_equip(teeth) return creature
def generate_character(x, y, race, with_AI): """Generates a random character of the chosen race""" race_template = race_templates[race] attribute_values = generate_attribute_values(race_template) character_component = Character(attribute_values["age"], race_template) attacks = generate_attack_set(unarmed_attack_definitions) fighter_component = Fighter(hp=attribute_values["hp"], endurance=attribute_values["endurance"], strength=attribute_values["strength"], intelligence=1, willpower=1, known_attacks=attacks) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() ai_component = None if with_AI: ai_component = NeutralAI() character_name = race_template["race_name"] color = libtcod.gray else: character_name = "Player" color = libtcod.orange character = Entity(x, y, '@', color, character_name, blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, character=character_component, ai=ai_component) return character
def rats_nest(point=None, dungeon_level=1): health_component = Health(20) creature = Character(point, 'N', SPECIES_STRINGS[Species.RATNEST], COLORS.get('rats_nest'), ai=SpawningNPC(rat), species=Species.RATNEST, health=health_component, act_energy=2) creature.add_component(Defence(defence=5), 'defence') creature.add_component(Level(xp_value=50), 'level') creature.add_component(Children(5), 'children') creature.movement.routing_avoid.extend(creature_avoid) equipment.add_random_loot(creature, dungeon_level) return creature
def __init__(self): super().__init__( name="player", player=True, # Let's us work with the player component around the game. char="@", color=(255, 255, 255), ai=None, equipment=Equipment(), fighter=Fighter(max_hp=30, base_ac=10), offense=OffenseComponent(Attack('punch', [2])), attributes=Attributes(base_strength=5), # Original inventory capacity is 267 because we have 26 lowercase letters plus $ inventory=PlayerInventory(capacity=27), level=Level(level_up_base=20, difficulty=0), energy=EnergyComponent(refill=12), regeneration=Regeneration(), light=LightComponent(radius=1), )
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_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): """ Initialize player, entities list, and game map """ fighter_component = Fighter(hp=30, defense=2, power=5) 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) 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): fighter_component = Fighter(hp=100, defense=1, power=4) inventory_component = Inventory(26) level_component = Level() # initialize the player and an npc # place the player right in the middle of the screen player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component) # store the npc and player in a list, which will eventually hold all entities in the map entities = [player] # initialize the 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_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_players(constants, entities): players = [] for i in range(constants['player_count']): # Building the players fighter_component = Fighter(hp=30, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() vision_component = Vision(None, constants['fov_radius']) players.append( Entity(0, 0, '@', libtcod.blue, 'Player{0}'.format(i + 1), blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, vision=vision_component)) # Give the player a dagger to start with equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) players[-1].inventory.add_item(dagger) players[-1].equipment.toggle_equip(dagger) entities.append(players[-1]) return players
def get_game_variables(constants): """ Crée une nouvelle partie Parametres: ---------- constants : dict Renvoi: ------- player : Entity entities : list game_map : GameMap message_log : MessageLog game_state : int """ fighter_component = Fighter(hp=100, defense=1, power=3) inventory_component = Inventory() level_component = Level() equipment_component = Equipment() player = Entity(0, 0, constants.get('graphics').get('player'), 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, constants.get('graphics').get('dagger'), libtcod.sky, 'Dague', 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, constants.get('graphics')) 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 troll(point=None, dungeon_level=1): #create a troll health_component = Health(30) ai_component = BasicNPC() npc = Character(point, 'T', 'troll', COLORS.get('troll'), ai=ai_component, species=Species.TROLL, health=health_component, act_energy=6) npc.add_component(Offence(base_power=12), 'offence') npc.add_component(Defence(defence=8), 'defence') npc.add_component(Level(xp_value=10), 'level') regen = Regeneration() npc.add_component(regen, 'regeneration') npc.add_component(DamageModifier(fire=1.5), 'damagemodifier') regen.start() npc.movement.routing_avoid.extend(npc_avoid) item = None dice = randint(1, 100) if dice > 75: item = equipment.create_weapon('heavy mace') equipment.add_smashing(item) else: item = equipment.create_weapon('longsword') item.lootable = False npc.inventory.add_item(item) npc.equipment.toggle_equip(item) return npc