Exemplo n.º 1
0
def get_hand_armor_chances(game_map):
    wp_en = '-hand_armor'

    chances = {}

    chances.update({
        'Hand Warmers' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Gauntlets of Dexterity' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Gauntlets of Fumbling' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Gauntlets of Power' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Black Silk Gloves' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })

    return chances
def get_easy_monsters(dungeon_level):

	monster_chances = {
			'orc'              : from_dungeon_level([[60,1],[30,3],[10,4],[0,5]], dungeon_level),
			'gnoll'            : from_dungeon_level([[80,1],[50,2],[30,3],[0,4]], dungeon_level),
			'troll'            : from_dungeon_level([[15,3],[30,5],[60,7]], dungeon_level),
			#'orc_battle_master': from_dungeon_level([[0,4], [100,5], [0,6]], dungeon_level)
			}
	return monster_chances
def get_scroll_chances(game_map):
    chances = {
        'lightning_scroll': from_dungeon_level([[25, 4]],
                                               game_map.dungeon_level),
        'fireball_scroll': from_dungeon_level([[25, 6]],
                                              game_map.dungeon_level),
        'confusion_scroll': from_dungeon_level([[10, 2]],
                                               game_map.dungeon_level)
    }

    return chances
Exemplo n.º 4
0
def get_throwing_chances(game_map):
    wp_en = '-weapon'

    chances = {
        'Shuriken' + wp_en: from_dungeon_level([[1, 1]],
                                               game_map.dungeon_level),
        'A boulder' + wp_en: from_dungeon_level([[2, 2]],
                                                game_map.dungeon_level),
    }

    return chances
Exemplo n.º 5
0
def get_arrow_chances(game_map):
    wp_en = '-weapon'

    chances = {
        'Wooden Arrows'+wp_en   : from_dungeon_level([[1, 1]], game_map.dungeon_level),
        'Copper Arrows'+wp_en   : from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Iron Arrows' + wp_en   : from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Steel Arrows' + wp_en  : from_dungeon_level([[2, 2]], game_map.dungeon_level),
        }

    return chances
Exemplo n.º 6
0
def get_eye_chances(game_map):
    wp_en = '-eye'

    chances = {}

    chances.update({'Black spectacles' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Eye mask' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Jeweller’s monocle' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Mummy wrapping' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})

    return chances
def get_item_chances(game_map):
    return {
        'healing_potion': 35,
        'sword': from_dungeon_level([[5, 4]], game_map.dungeon_level),
        'shield': from_dungeon_level([[15, 8]], game_map.dungeon_level),
        'lightning_scroll': from_dungeon_level([[25, 4]],
                                               game_map.dungeon_level),
        'fireball_scroll': from_dungeon_level([[25, 6]],
                                              game_map.dungeon_level),
        'confusion_scroll': from_dungeon_level([[10, 2]],
                                               game_map.dungeon_level)
    }
Exemplo n.º 8
0
    def place_entities(self, room, entities):
        """Place a random number of monsters in each room of the map."""
        max_monsters_per_room = from_dungeon_level(max_monsters_dungeon, self.dungeon_level)
        max_items_per_room = from_dungeon_level(max_items_dungeon, self.dungeon_level)
        # Get a random number of monsters and items
        number_of_monsters = rd.randint(0, max_monsters_per_room)
        number_of_items = rd.randint(0, max_items_per_room)
        # Generate dictionary (elem -> chance ) for the appropriate dungeon level
        monster_chances = {m['id']: from_dungeon_level(m['spawn_chance'], self.dungeon_level) for m in monsters}
        consumables_chances = {c['id']: from_dungeon_level(c['drop_chance'], self.dungeon_level) for c in consumables}
        equipment_chances = {e['id']: from_dungeon_level(e['drop_chance'], self.dungeon_level) for e in equipment}

        # === Monsters ===
        for i in range(number_of_monsters):
            # Choose a random location in the room
            x = rd.randint(room.x1 + 1, room.x2 - 1)
            y = rd.randint(room.y1 + 1, room.y2 - 1)

            tile_occupied = any([entity for entity in entities if entity.x == x and entity.y == y])
            if not tile_occupied and self.tiles[x][y].can_spawn:
                monster_choice = random_choice_from_dict(monster_chances)

                for monster in monsters:
                    if monster_choice == monster['id']:
                        monster_entity = self.create_monster_entity(x, y, monster, monster['equipment'])

                entities.append(monster_entity)

        # === Items ===
        for i in range(number_of_items):
            x = rd.randint(room.x1 + 1, room.x2 - 1)
            y = rd.randint(room.y1 + 1, room.y2 - 1)

            tile_occupied = any([entity for entity in entities if entity.x == x and entity.y == y])
            if not tile_occupied and self.tiles[x][y].can_spawn:
                select_item_pool = rd.randint(0, 100)

                if select_item_pool < 70:
                    item_choice = random_choice_from_dict(consumables_chances)

                    for consumable in consumables:
                        if item_choice == consumable['id']:
                            item = self.create_item_entity(x, y, consumable)

                else:
                    item_choice = random_choice_from_dict(equipment_chances)

                    for equippable in equipment:
                        if item_choice == equippable['id']:
                            item = self.create_item_entity(x, y, equippable, is_equippable=True)

                entities.append(item)
Exemplo n.º 9
0
def get_greatsword_chances(game_map):
    wp_en = '-weapon'

    chances = {
        'Greatsword' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level),
        'Fiery Greatsword' + wp_en:
        from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Vorpal Blade' + wp_en:
        from_dungeon_level([[3, 3]], game_map.dungeon_level),
    }

    return chances
Exemplo n.º 10
0
    def place_entities(self, room, entities):
        max_monsters_per_room = from_dungeon_level([[2, 1], [3, 4], [5, 6]],
                                                   self.dungeon_level)
        max_items_per_room = from_dungeon_level([[1, 1], [2, 4]],
                                                self.dungeon_level)

        # Get a random number of monsters
        number_of_monsters = randint(0, max_monsters_per_room)
        number_of_items = randint(0, max_items_per_room)

        monster_chances, item_chances = get_content(self)

        for i in range(number_of_monsters):
            x = randint(room.x1 + 1, room.x2 - 1)
            y = randint(room.y1 + 1, room.y2 - 1)

            #choose a random location in room
            if self.tiles[x][y].blocked == True:
                skip = True
            else:
                skip = False

            if not any([
                    entity
                    for entity in entities if entity.x == x and entity.y == y
            ]) and not skip:
                monster_choice = random_choice_from_dict(monster_chances)
                monster = create_entity(x, y, monster_choice)
                entities.append(monster)
        for i in range(number_of_items):
            x = randint(room.x1 + 1, room.x2 - 1)
            y = randint(room.y1 + 1, room.y2 - 1)

            #choose a random location in room
            if self.tiles[x][y].blocked == True:
                skip = True
            else:
                skip = False

            if not any([
                    entity
                    for entity in entities if entity.x == x and entity.y == y
            ]) and not skip:
                item_choice = random_choice_from_dict(item_chances)

                item = create_item(x, y, item_choice)

                entities.append(item)
Exemplo n.º 11
0
def get_axe_chances(game_map):
    wp_en = '-weapon'

    chances = {
        'Pickaxe' + wp_en: from_dungeon_level([[1, 1]],
                                              game_map.dungeon_level),
        'Axe' + wp_en: from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Battle axe' + wp_en: from_dungeon_level([[3, 3]],
                                                 game_map.dungeon_level),
        'Massive Axe' + wp_en: from_dungeon_level([[4, 4]],
                                                  game_map.dungeon_level),
        'Cleaver' + wp_en: from_dungeon_level([[5, 5]],
                                              game_map.dungeon_level),
    }

    return chances
Exemplo n.º 12
0
def get_monster_chances(game_map):
    return {
        'orc':
        80,
        'troll':
        from_dungeon_level([[15, 3], [30, 5], [60, 7]], game_map.dungeon_level)
    }
Exemplo n.º 13
0
def get_early_items(dungeon_level):

    item_chances = {
        'healing_potion': from_dungeon_level([[40, 1]], dungeon_level),
        'broken_iron_sword': from_dungeon_level([[15, 2]], dungeon_level),
        'flimsy_wooden_bow': from_dungeon_level([[15, 2]], dungeon_level),
        'cracked_wooden_board': from_dungeon_level([[15, 2]], dungeon_level),
        'dirty_leather_tunic': from_dungeon_level([[15, 1]], dungeon_level),
        'dirty_leather_pants': from_dungeon_level([[15, 1]], dungeon_level),
        'lightning_scroll': from_dungeon_level([[15, 3]], dungeon_level),
        'fireball_scroll': from_dungeon_level([[15, 3]], dungeon_level),
        'confusion_scroll': from_dungeon_level([[10, 2]], dungeon_level)
    }

    return item_chances
Exemplo n.º 14
0
 def make_map(self, max_rooms, room_min_size, room_max_size, map_width, map_height, player, entities):
     # Create two rooms for demonstration purposes
     rooms = []
     num_rooms = 0
     
     last_room_center_x = None
     last_room_center_y = None
     
     add_room_size = from_dungeon_level([[0,1], [2,4], [4,7], [6,10], [8,13]] , self.dungeon_level)
     for r in range(max_rooms):
         # random width and height
         w = randint(room_min_size, room_max_size + add_room_size)
         h = randint(room_min_size, room_max_size + add_room_size)
         # random position without going out of boundaries of the map
         x = randint(0, map_width - w - 1)
         y = randint(0, map_height - h - 1)
         
         new_room = Rect(x, y, w, h)
         
         # run through other rooms and see if they intersect with this one
         for other_room in rooms:
             if new_room.intersect(other_room):
                 break
         else:
             self.create_room(new_room)
             
             (new_x, new_y) = new_room.center()
             
             last_room_center_x  = new_x
             last_room_center_y = new_y
             
             if num_rooms == 0:
                 # if this is the first room, place the player here
                 player.x = new_x
                 player.y = new_y
             else:
                 # all rooms after the first, connect to the previous room with a tunnel
                 (prev_x, prev_y) = rooms[num_rooms-1].center()
                 
                 if randint(0,1)==1:
                     self.create_h_tunnel(prev_x, new_x, prev_y)
                     self.create_v_tunnel(prev_y, new_y, new_x)
                 else:
                     self.create_v_tunnel(prev_y, new_y, prev_x)
                     self.create_h_tunnel(prev_x, new_x, new_y)
             if num_rooms != 0:    
                 self.place_entities(new_room, entities)
             
             rooms.append(new_room)
             num_rooms += 1
     stairs_component = Stairs(self.dungeon_level + 1)
     down_stairs = Entity(last_room_center_x, last_room_center_y, '>', tc.silver, 'Stairs',
                          render_order=RenderOrder.STAIRS, stairs=stairs_component)
     entities.append(down_stairs)
Exemplo n.º 15
0
    def fill_room(self, room, dungeon_level, entities):
        max_items_per_room = from_dungeon_level(max_items_per_room_weights, dungeon_level)
        number_of_items = randint(0, max_items_per_room)
        item_chances = weight_factor(items, dungeon_level)

        for _ in range(number_of_items):
            # Choose a random location in room
            x = randint(room.x1 + 1, room.x2 - 1)
            y = randint(room.y1 + 1, room.y2 - 1)
            if not entities.find_by_point(x, y):
                item_choice = random_choice_from_dict(item_chances)
                item = self.get_item(x, y, item_choice)
                entities.append(item)
Exemplo n.º 16
0
    def populate_room(self, room, dungeon_level, entities):
        max_monsters_per_room = from_dungeon_level(max_monsters_per_room_weights, dungeon_level)
        number_of_monsters = randint(0, max_monsters_per_room)
        monster_chances = weight_factor(monsters, dungeon_level)

        for _ in range(number_of_monsters):
            # Choose a random location in room
            x = randint(room.x1 + 1, room.x2 - 1)
            y = randint(room.y1 + 1, room.y2 - 1)
            if not entities.find_by_point(x, y):
                monster_choice = random_choice_from_dict(monster_chances)
                monster = self.get_monster(x, y, monster_choice)
                entities.append(monster)
Exemplo n.º 17
0
def get_content(self):

    monster_chances = {'bat': from_dungeon_level([[100, 0], [20, 2], [5, 4]],self.dungeon_level),
                       'orc': from_dungeon_level([[80, 0], [0, 7]],self.dungeon_level),
                       'troll': from_dungeon_level([[15, 3], [60, 5], [80, 7]], self.dungeon_level),
                       'goblin': from_dungeon_level([[30, 0], [50, 3], [40,6]],self.dungeon_level),
                       }

    item_chances = {'healing_potion': 35,
                    'sword': from_dungeon_level([[5, 4]], self.dungeon_level),
                    'shield': from_dungeon_level([[15, 8]], self.dungeon_level),
                    'lightning_scroll': from_dungeon_level([[25, 4]], self.dungeon_level),
                    'fireball_scroll': from_dungeon_level([[25, 6]], self.dungeon_level),
                    }
    return monster_chances, item_chances
Exemplo n.º 18
0
def get_foot_armor_chances(game_map):
    wp_en = '-foot_armor'

    chances = {}

    chances.update({'Black Boots' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Elven Boots' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Dwarvish Iron Shoes' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Boots of Jumping' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Boots of Levitation' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Speed Boots' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Silk Shoes' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})
    chances.update({'Low Boots' + wp_en: from_dungeon_level([[1, 1]], game_map.dungeon_level)})

    return chances
Exemplo n.º 19
0
    def __init__(self, width, height, room_min_size, room_max_size, dungeon_level=1):
        self.width = width
        self.height = height
        self.room_min_size = room_min_size
        self.room_max_size = room_max_size

        self.tiles = self.initialize_tiles()

        self.rooms = []

        self.dungeon_level = dungeon_level

        self.number_of_bosses = 0
        self.max_number_of_bosses = from_dungeon_level([[1, 3], [3, 5], [7, 7]], self.dungeon_level)
Exemplo n.º 20
0
def get_knive_chances(game_map):
    wp_en = '-weapon'
    chances = {
        'Sickle'+wp_en          : from_dungeon_level([[1, 1]], game_map.dungeon_level),
        'Orcish Dagger'+wp_en    : from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Dagger' + wp_en        : from_dungeon_level([[3, 3]], game_map.dungeon_level),
        'Elven Dagger' + wp_en   : from_dungeon_level([[4, 4]], game_map.dungeon_level),
        'Athame' + wp_en        : from_dungeon_level([[5, 5]], game_map.dungeon_level),
        'Kris Knife' + wp_en     : from_dungeon_level([[6, 6]], game_map.dungeon_level),
        'Grimtooth' + wp_en     : from_dungeon_level([[7, 7]], game_map.dungeon_level),
        }

    return chances
Exemplo n.º 21
0
 def generate_enchantment(self, dungeon_level):
     "Generates a random enchantment for the given item based on dungeon level. The modifier will potentially apply a bonus and change the name of the item"
     modifierChances = {
         key: from_dungeon_level(value.chance, dungeon_level)
         for key, value in equippable_enchantment.items()
         if self.slot in value.slot_restrictions
     }
     modifier_name = random_choice_from_dict(modifierChances)
     modifier = equippable_enchantment.get(modifier_name)
     if modifier.bonus_dic:
         for key, value in modifier.bonus_dic.items():
             # Bonus type is whatever is written in modifier
             setattr(self, key, getattr(self, key) + value)
             return ' of ' + modifier_name
     return ''
	def place_entities(self, room, entities):
		max_monsters_per_room = from_dungeon_level([[3,1],[5,3],[8,5]], self.dungeon_level)
		max_items_per_room = from_dungeon_level([[1,1],[2,4]], self.dungeon_level)
		# Get a random number of monsters
		number_of_monsters = randint(0, max_monsters_per_room)

		# Get a random number of items
		number_of_items = randint(0, max_items_per_room)

		monster_chances = get_easy_monsters(self.dungeon_level)

		item_chances = get_early_items(self.dungeon_level)

		for i in range(number_of_monsters):
			# Choose a random location in the room
			x = randint(room.x1 + 1, room.x2 - 1)
			y = randint(room.y1 + 1, room.y2 - 1)

			# Check if an entity is already in that location
			if not any([entity for entity in entities if entity.x == x and entity.y == y]):
				monster_choice = random_choice_from_dict(monster_chances)

				monster = choose_easy_monster(monster_choice, self.dungeon_level, x, y)

				entities.append(monster)

		for i in range(number_of_items):
			x = randint(room.x1 + 1, room.x2 - 1)
			y = randint(room.y1 + 1, room.y2 - 1)

			if not any([entity for entity in entities if entity.x == x and entity.y == y]):
				item_choice = random_choice_from_dict(item_chances)

				item = choose_early_item(item_choice, x, y)

				entities.append(item)
Exemplo n.º 23
0
    def populate_cave(self, cave, entities):
        max_monsters = from_dungeon_level(max_monsters_per_level_weights, cave.dungeon_level)
        number_of_monsters = randint(0, max_monsters)
        monster_chances = weight_factor(monsters, cave.dungeon_level)

        if cave.map_creator.twilight_zone:
            zone = cave.map_creator.twilight_zone
        elif cave.map_creator.dark_zone:
            zone = cave.map_creator.dark_zone

        for _ in range(number_of_monsters):
            x, y = choice(tuple(zone))
            if not entities.find_by_point(x, y):
                monster_choice = random_choice_from_dict(monster_chances)
                monster = self.get_monster(x, y, monster_choice)
                entities.append(monster)
Exemplo n.º 24
0
    def next_floor(self, player, message_log, constants):
        self.dungeon_level += 1
        entities = [player]

        self.max_number_of_bosses = from_dungeon_level([[1, 2], [2, 5], [3, 7], [5, 8], [8, 9]], self.dungeon_level)

        self.room_min_size, self.room_max_size = constants['room_min_size'], constants['room_max_size']
        self.width, self.height = constants['map_width'], constants['map_height']

        self.tiles = self.initialize_tiles()
        entities.extend(self.make_map(constants['max_rooms'], player))

        player.fighter.heal(player.fighter.max_hp // 2)

        message_log.add_message(Message('You take a moment to rest, and recover your strength.', tcod.light_violet))

        return entities
Exemplo n.º 25
0
 def generate_material(self, dungeon_level):
     "Generates a random material for the given item based on dungeon level. The modifier will potentially apply a bonus and change the name of the item. Bonus will usually be defensive for armor and offensive for weapons"
     modifierChances = {
         key: from_dungeon_level(value.chance, dungeon_level)
         for key, value in equippable_material.items()
         if self.slot in value.slot_restrictions
     }
     modifier_name = random_choice_from_dict(modifierChances)
     modifier = equippable_material.get(modifier_name)
     if modifier.bonus_dic:
         for _, value in modifier.bonus_dic.items():
             # Set power if weapon, defense if armor
             if self.slot in EquipmentSlotGroups.WEAPONS:
                 setattr(self, 'power_bonus',
                         getattr(self, 'power_bonus') + value)
             else:
                 setattr(self, 'defense_bonus',
                         getattr(self, 'defense_bonus') + value)
             return modifier_name + ' '
     return ''
Exemplo n.º 26
0
def get_head_armor_chances(game_map):
    wp_en = '-head_armor'

    chances = {}

    chances.update({
        'Cornuthaum' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Crested helm' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Crown' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Dwarvish helm' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Engineer’s cap' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Green Headband' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Helm of brilliance' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })
    chances.update({
        'Orcish helm' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level)
    })

    return chances
Exemplo n.º 27
0
    def place_monsters(m, chunks, monster_chances, level):
        entities = []
        chance_any = monster_chances["any"]
        del monster_chances["any"]
        max_monsters_per_room = from_dungeon_level([[2, 1], [3, 4], [5, 6]], level + 1)
        for idx, c in enumerate(chunks):
            c.monsters = []
            rval = random.randint(0, 100)
            if rval > chance_any:
                continue
            if idx == 0:
                num_monsters = 1  # don't overwhelm in the first room
            else:
                num_monsters = random.randint(1, max_monsters_per_room)
            room_center = Pos(c.x + c.width // 2, c.y + c.height // 2)
            skip_room = False

            for _ in range(num_monsters):
                x = random.randint(c.x + 1, c.x + c.width - 1)
                y = random.randint(c.y + 1, c.y + c.height - 1)
                if idx == 0:
                    # first room, don't spawn right next to player
                    attempts = 0
                    while Pos(x, y).distance_to(room_center) < 4:
                        x = random.randint(c.x + 1, c.x + c.width - 2)
                        y = random.randint(c.y + 1, c.y + c.height - 2)
                        attempts += 1
                        if attempts > 100:
                            skip_room = True
                if skip_room:
                    continue

                already_there = [entity for entity in entities if entity.pos.x == x and entity.pos.y == y]
                if not any(already_there) and not m.tiles[x][y].blocked:
                    monster_choice = random_choice_from_dict(monster_chances)
                    monster_data = get_monster(x, y, m, c, monster_choice, entities)
                    entities.extend(monster_data)
                    c.monsters.extend(monster_data)

        m.entities = entities
Exemplo n.º 28
0
def get_club_chances(game_map):
    wp_en = '-weapon'

    chances = {
        'Wooden Club' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level),
        'Mace' + wp_en:
        from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Warhammer' + wp_en:
        from_dungeon_level([[3, 3]], game_map.dungeon_level),
        'Morning Star' + wp_en:
        from_dungeon_level([[4, 4]], game_map.dungeon_level),
        'Spiked Flail' + wp_en:
        from_dungeon_level([[5, 5]], game_map.dungeon_level),
        'Giant Club' + wp_en:
        from_dungeon_level([[6, 6]], game_map.dungeon_level),
        'Auger' + wp_en:
        from_dungeon_level([[7, 7]], game_map.dungeon_level),
        'Mjolnir' + wp_en:
        from_dungeon_level([[8, 8]], game_map.dungeon_level),
    }

    return chances
Exemplo n.º 29
0
def get_polearm_chances(game_map):
    wp_en = '-weapon'

    chances = {
        'Staff' + wp_en:
        from_dungeon_level([[1, 1]], game_map.dungeon_level),
        'Staff of Light' + wp_en:
        from_dungeon_level([[2, 2]], game_map.dungeon_level),
        'Staff of Darkness' + wp_en:
        from_dungeon_level([[3, 3]], game_map.dungeon_level),
        'Spear' + wp_en:
        from_dungeon_level([[4, 4]], game_map.dungeon_level),
        'Staff of Life' + wp_en:
        from_dungeon_level([[5, 5]], game_map.dungeon_level),
        'Staff of Death' + wp_en:
        from_dungeon_level([[6, 6]], game_map.dungeon_level),
        'Red Hot Poker' + wp_en:
        from_dungeon_level([[7, 7]], game_map.dungeon_level),
        'Thyrsus' + wp_en:
        from_dungeon_level([[8, 9]], game_map.dungeon_level),
    }

    return chances
Exemplo n.º 30
0
    def populate_room(self, room, entities):
        max_monsters = from_dungeon_level([[2, 1], [3, 4], [5, 6]],
                                          self.current_level)
        nb_monsters = randint(0, max_monsters)

        if nb_monsters == 0:
            return

        succesful = 0

        # 100 try in total
        for _ in range(1000):
            x = randint(room.x1 + 1, room.x2 - 1)
            y = randint(room.y1 + 1, room.y2 - 1)

            monster_choice = random_choice_from_dict(MONSTER_PROB)
            entity = get_monster(monster_choice, x, y)

            if self.place_entity(x, y, entity, entities):
                succesful += 1

            if succesful == nb_monsters:
                break
Exemplo n.º 31
0
	def place_entities(self, room, entities):
		max_monsters_per_room = from_dungeon_level([[2, 1], [3, 4], [5, 6]], self.dungeon_level)
		max_items_per_room = from_dungeon_level([[1, 1], [2, 4]], self.dungeon_level)

		#get a random number of monsters
		number_of_monsters = randint(0, max_monsters_per_room)
		number_of_items = randint(0, max_items_per_room)

		monster_chances = {
			'orc': 80,
			'troll':from_dungeon_level([[15, 3], [30, 5], [60, 7]], self.dungeon_level)
		}

		item_chances = {
			'healing_potion': 35,
			'lightning_scroll': from_dungeon_level([[25, 4]], self.dungeon_level),
			'fireball_scroll': from_dungeon_level([[25, 6]], self.dungeon_level),
			'confusion_scroll': from_dungeon_level([[10, 2]], self.dungeon_level)
		}

		for i in range(number_of_monsters):
			#choose a random location in the room
			x = randint(room.x1 + 1, room.x2 - 1)
			y = randint(room.y1 + 1, room.y2 - 1)

			if not any([entity for entity in entities if entity.x == x and entity.y == y]):
				monster_choice = random_choice_from_dict(monster_chances)

				if monster_choice == 'orc':
					fighter_component = Fighter(hp=20, defense=0, power=4, xp=35)
					ai_component = BasicMonster()

					monster = Entity(x, y, 'o', libtcod.desaturated_green, 'Orc', blocks=True, render_order=RenderOrder.ACTOR,
									fighter=fighter_component, ai=ai_component)
				else:
					fighter_component = Fighter(hp=30, defense=2, power=8, xp=100)
					ai_component = BasicMonster()

					monster = Entity(x, y, 'T', libtcod.darker_green, 'Troll', blocks=True, 
									fighter=fighter_component, render_order=RenderOrder.ACTOR, ai=ai_component)

				entities.append(monster)


		for i in range(number_of_items):
			x = randint(room.x1 + 1, room.x2 - 1)
			y = randint (room.y1 + 1, room.y2 - 1)

			if not any([entity for entity in entities if entity.x == x and entity.y == y]):
				item_choice = random_choice_from_dict(item_chances)

				if item_choice == 'healing_potion':
					item_component = Item(use_function=heal, amount=40)
					item = Entity(x, y, '!', libtcod.violet, 'Healing Potion', render_order=RenderOrder.ITEM, item=item_component)
				elif item_choice == 'fireball_scroll':
					item_component = Item(use_function=cast_fireball, targeting=True, targeting_message=Message('Left-click a target tile for the fireball, or right click to canc el.', libtcod.light_cyan), damage=25, radius=3)
					item = Entity(x, y, '#', libtcod.red, 'Fireball Scroll', render_order=RenderOrder.ITEM, item=item_component)
				elif item_choice == 'confuction_scroll':
					item_component = Item(use_function=cast_confuse, targeting=True, targeting_message=Message('Left-click an enemy to confuse it, or right-click to cancel.', libtcod.light_cyan))
					item = Entity(x, y, '#', libtcod.light_pink, 'Confusion Scroll', render_order=RenderOrder.ITEM, item=item_component)	
				else:
					item_component = Item(use_function=cast_lightning, damage=40, maximum_range=5)
					item = Entity(x, y, '#', libtcod.yellow, 'Lightning Scroll', render_order=RenderOrder.ITEM, item=item_component)
				entities.append(item)