Ejemplo n.º 1
0
    def generate_level_params(self):

        level_params = []
        biomes = level_biomes()
        biome_params = meditate_params()
        for i in range(5):
            level = {}
            biome = random.choice(biomes)
            biome_desc, biome_mod = random.choice(list(biome_params.items()))
            level["biome"] = biome
            level["modifier"] = biome_mod
            level["freq_monster"] = None
            # Generate level title
            if random.random() > 0.7:
                monsters = []
                if self.world_tendency < 0:
                    for x, y in tilemap()["monsters_chaos"].items():
                        monsters.append((x, y))
                elif self.world_tendency > 0:
                    for x, y in tilemap()["monsters_light"].items():
                        monsters.append((x, y))
                else:
                    for x, y in tilemap()["monsters"].items():
                        monsters.append((x, y))
                monsters.sort()
                spawn_rates = self.get_spawn_rates(monsters)
                monster_prefix = random.choice(
                    random.choices(monsters, spawn_rates, k=5))[0]
                level["title"] = "The " + monster_prefix.capitalize(
                ) + " " + biome.capitalize() + " of " + biome_desc
                level["freq_monster"] = monster_prefix
            else:
                level["title"] = "The " + biome.capitalize(
                ) + " of " + biome_desc
            level_params.append(level)

        return level_params
Ejemplo n.º 2
0
    def kill(self):
        if self.player:
            self.char = tilemap()["player_remains"]
            death_message = Message(msg="You died!", style="death")

        else:
            death_message = Message("The {0} is dead!".format(self.name),
                                    style="death")

            if self.boss:
                self.char = tilemap()["boss_remains"]
                self.color = "darkest red"
            else:
                self.char = tilemap()["monster_remains"]
                self.color = "dark gray"
                self.light_source = None
            self.blocks = False
            self.fighter = None
            self.ai = None
            self.name = "remains of " + get_article(
                self.name) + " " + self.name
            self.layer = 1

        return death_message
Ejemplo n.º 3
0
 def draw_indicator(self,
                    entity_x,
                    entity_y,
                    color=None,
                    occupied_tiles=None):
     # Draw player indicator
     blt.layer(4)
     x, y = self.owner.game_camera.get_coordinates(entity_x, entity_y)
     blt.color(color)
     if occupied_tiles is not None:
         return
     else:
         blt.put(x * self.owner.options.tile_offset_x,
                 y * self.owner.options.tile_offset_y,
                 tilemap()["indicator"])
Ejemplo n.º 4
0
 def refresh(self):
     self.items = []
     self.items_icons = []
     self.sub_items = {}
     animals = tilemap()["monsters"]
     animals = {x: animals[x] for x in ("crow", "rat", "snake")}
     for (k, v) in animals.items():
         animal = json_data.data.fighters[k]
         stats = "hp: {0}, ac: {1}, ev: {2}, power: {3}".format(
             animal["hp"], animal["ac"], animal["ev"], animal["power"])
         skills = "skills: {0}".format(", ".join(
             animal["player_abilities"]))
         self.items.append(k)
         self.items_icons.append(v)
         self.sub_items[k] = [stats, skills]
Ejemplo n.º 5
0
 def __init__(self, spirit_power):
     self.owner = None
     self.spirit_power = spirit_power
     self.char = {"player": tilemap()["player"]}
     self.char_exp = {"player": 0}
     self.char_level = 1
     self.skill_points = 0
     self.exp_lvl_interval = 100
     self.insights = 0
     self.avatar = {"player": None}
     self.lightmap = None
     self.sel_weapon = None
     self.sel_attack = None
     self.sel_utility = None
     self.sel_weapon_idx = 0
     self.sel_attack_idx = 0
     self.sel_utility_idx = 0
Ejemplo n.º 6
0
 def __init__(self, blocked, block_sight, x, y):
     self.blocking_entity = None
     self.blocked = blocked
     self.block_sight = block_sight
     self.x = x
     self.y = y
     self.explored = False
     self.visited = False
     self.seed = randint(1, 100)
     self.char = tilemap()["floor"]
     self.layers = []
     self.color = "darkest amber"
     self.name = None
     self.spawnable = False
     self.occupied = False
     self.is_door = False
     self.door = None
     self.entities_on_tile = []
     self.items_on_tile = []
     self.stairs = None
     self.natural_light_level = 1.5
     self.targeting_zone = False
Ejemplo n.º 7
0
    def handle_player_exp(self, killed_fighter):
        self.spirit_power += killed_fighter.max_hp
        self.char_exp["player"] += killed_fighter.max_hp
        self.owner.fighter.hp += killed_fighter.power
        levels_gained = int(self.char_exp["player"] / (self.exp_lvl_interval * self.char_level))
        entity_name = killed_fighter.owner.name

        if entity_name in tilemap()["monsters"].keys():
            self.char[entity_name] = tilemap()["monsters"][entity_name]
        elif entity_name in tilemap()["monsters_light"].keys():
            self.char[entity_name] = tilemap()["monsters_light"][entity_name]
        elif entity_name in tilemap()["monsters_chaos"].keys():
            self.char[entity_name] = tilemap()["monsters_chaos"][entity_name]

        if entity_name in self.char_exp.keys():
            self.char_exp[entity_name] += 1
        else:
            self.char_exp[entity_name] = 1

        if levels_gained >= 1:
            self.level_up(levels_gained)
            return Message("You have gained a level!", style="level_up")

        return None
Ejemplo n.º 8
0
    def init_new_game(self, params):
        choice = params
        self.player = None
        self.levels = None
        self.time_counter = None
        # Create player
        inventory_component = Inventory(26)
        f_data = self.data.fighters["player"]
        fighter_component = Fighter(hp=f_data["hp"],
                                    ac=f_data["ac"],
                                    ev=f_data["ev"],
                                    power=f_data["power"],
                                    mv_spd=f_data["mv_spd"],
                                    atk_spd=f_data["atk_spd"],
                                    size=f_data["size"],
                                    fov=f_data["fov"])

        light_component = LightSource(radius=fighter_component.fov)
        player_component = Player(50)
        abilities_component = Abilities("player")
        status_effects_component = StatusEffects("player")
        summoner_component = Summoner()
        player = Entity(1,
                        1,
                        3,
                        player_component.char["player"],
                        "default",
                        "player",
                        blocks=True,
                        player=player_component,
                        fighter=fighter_component,
                        inventory=inventory_component,
                        light_source=light_component,
                        summoner=summoner_component,
                        indicator_color="gray",
                        abilities=abilities_component,
                        status_effects=status_effects_component,
                        stand_on_messages=False)
        player.player.avatar["player"] = fighter_component
        avatar_f_data = self.data.fighters[choice]
        a_fighter_component = Fighter(hp=avatar_f_data["hp"],
                                      ac=avatar_f_data["ac"],
                                      ev=avatar_f_data["ev"],
                                      power=avatar_f_data["power"],
                                      mv_spd=avatar_f_data["mv_spd"],
                                      atk_spd=avatar_f_data["atk_spd"],
                                      size=avatar_f_data["size"],
                                      fov=avatar_f_data["fov"])
        player.player.avatar[choice] = a_fighter_component
        player.player.avatar[choice].owner = player
        player.abilities.initialize_abilities(choice)
        player.player.char[choice] = tilemap()["monsters"][choice]
        player.player.char_exp[choice] = 20

        player.player.avatar[choice].max_hp += 20
        player.player.avatar[choice].hp += 20
        player.player.avatar[choice].power += 1
        player.player.insights = 200

        self.player = player

        character_menu = MenuData(name="avatar_info", params=self.player)
        self.menus.create_or_show_menu(character_menu)

        message_log = MessageLog(4)
        self.message_log = message_log
        self.message_log.owner = self

        # Initialize game camera
        game_camera = Camera(1, 1, self.ui.viewport.w, self.ui.viewport.h,
                             self.options)
        self.game_camera = game_camera
        self.game_camera.owner = self

        levels = Levels(tileset=self.options.gfx)
        self.levels = levels
        self.levels.owner = self

        blt.clear_area(2, self.ui.viewport.offset_h + self.ui.offset_y + 1,
                       self.ui.viewport.x, 1)

        # if settings.gfx == "ascii":
        #     player.char = tilemap()["player"]
        #     player.color = "lightest green"

        self.levels.change("hub")
        self.fov_recompute = True
        self.game_state = GameStates.PLAYER_TURN
        self.time_counter = self.TimeCounter(owner=self)
Ejemplo n.º 9
0
    def process(self, game_map):
        msgs = []
        if not self.summoning and self.summoned_entities:
            summons = []
            for entity in self.summoned_entities:
                summons.append(entity.name)
                game_map.entities["allies"].remove(entity)
                game_map.tiles[entity.x][entity.y].remove_entity(entity)
                del entity
            self.summoned_entities = []
            self.owner.fighter.summoning = False
            self.summoning = [""]
            if len(summons) > 1:
                msg = Message(
                    "Your trusty companions {0} return back to the spirit plane!"
                    .format(", ".join(summons)))
            else:
                msg = Message(
                    "Your trusty companion {0} returns back to the spirit plane!"
                    .format(summons[0]))
            msgs.append(msg)
            return msgs

        elif self.summoning and not self.summoned_entities:
            if len(self.summoning) <= self.rank:
                name = self.summoning[-1]
            else:
                name = self.summoning[self.rank]
            char = tilemap()["monsters"][name]
            color = get_monster_color(name)
            f_data = json_data.data.fighters[name]
            remarks = f_data["remarks"]
            fighter_component = Fighter(hp=f_data["hp"],
                                        ac=f_data["ac"],
                                        ev=f_data["ev"],
                                        power=f_data["power"],
                                        mv_spd=f_data["mv_spd"],
                                        atk_spd=f_data["atk_spd"],
                                        size=f_data["size"],
                                        fov=f_data["fov"])
            ai_component = BasicMonster(ally=True)
            light_component = LightSource(radius=fighter_component.fov)
            abilities_component = Abilities(name)
            status_effects_component = StatusEffects(name)
            neighbours = get_neighbours(self.owner,
                                        game_map=game_map.tiles,
                                        radius=3,
                                        algorithm="square",
                                        empty_tiles=True)
            summon_tile = choice(neighbours)
            entity_name = name
            monster = Entity(summon_tile.x,
                             summon_tile.y,
                             3,
                             char,
                             color,
                             entity_name,
                             blocks=True,
                             fighter=fighter_component,
                             ai=ai_component,
                             light_source=light_component,
                             abilities=abilities_component,
                             status_effects=status_effects_component,
                             remarks=remarks,
                             indicator_color="light green")
            monster.light_source.initialize_fov(game_map)
            game_map.tiles[summon_tile.x][summon_tile.y].add_entity(monster)
            game_map.entities["allies"].append(monster)
            self.summoned_entities.append(monster)
            msg = Message("A friendly {0} appears!".format(entity_name))
            msgs.append(msg)
            remark_str = "{0}: {1}".format(monster.colored_name,
                                           choice(monster.remarks))
            remark_msg = Message(msg=remark_str, style="dialog")
            msgs.append(remark_msg)
            return msgs

        return msgs