예제 #1
0
    def __drop_items(self):
        r = random.randint(1, 100)
        item = None

        if r <= 33:
            item = Potion.random_potion()
        elif r <= 38:
            item = Item.ItemEmeraldSickle()
        elif r <= 41:
            item = Item.ItemWaterSword()
        elif r <= 46:
            item = Item.ItemGoldArmor()

        if item is None:
            return None
        return DroppedItem(item, self.x_pos, self.y_pos)
예제 #2
0
    def __drop_items(self):
        r = random.randint(1, 100)
        item = None

        if r <= 33:
            item = Potion.random_potion()
        elif r <= 38:
            item = Item.ItemBrokenSword()
        elif r <= 41:
            item = Item.ItemWoodenSword()
        elif r <= 42:
            item = Item.ItemIronSword()
        elif r <= 45:
            item = Item.ItemIronArmor()

        if item is None:
            return None
        return DroppedItem(item, self.x_pos, self.y_pos)
예제 #3
0
    def place_object(self, level):
        up, down = None, None
        for y in range(self.height):
            for x in range(self.width):
                if not TileSolidState[self.__map[x][y]]:
                    up = (x, y)
                    break

        for y in reversed(range(self.height)):
            for x in range(self.width):
                if not TileSolidState[self.__map[x][y]]:
                    down = (x, y)
                    break

        r = random.randint(0, 1)
        staircase, player = [up, down][r], [up, down][1 - r]

        count = 0
        monster_list = []

        while count < 15:
            x = random.randint(0, len(self.map) - 1)
            y = random.randint(0, len(self.map) - 1)
            if not TileSolidState[self.__map[x]
                                  [y]] and self.__character_map[x][y] is None:
                if level == 1:
                    monster_list += [
                        random.choice([Enemy.Slime(x, y),
                                       Enemy.Bird(x, y)])
                    ]
                elif level == 2:
                    monster_list += [
                        random.choice([
                            Enemy.Slime(x, y),
                            Enemy.Goblin(x, y),
                            Enemy.Bird(x, y)
                        ])
                    ]
                elif level == 3:
                    monster_list += [
                        random.choice([Enemy.Goblin(x, y),
                                       Enemy.Mummy(x, y)])
                    ]
                else:
                    monster_list += [
                        random.choice([
                            Enemy.Slime(x, y),
                            Enemy.Goblin(x, y),
                            Enemy.Bird(x, y)
                        ])
                    ]
                self.__character_map[x][y] = monster_list[len(monster_list) -
                                                          1]
                count += 1

        count = 0
        object_list = []
        while count < 5:
            x = random.randint(0, len(self.map) - 1)
            y = random.randint(0, len(self.map) - 1)
            if not TileSolidState[self.__map[x]
                                  [y]] and self.__object_map[x][y] is None:
                object_list += [DroppedItem(Potion.random_potion(), x, y)]
                self.__object_map[x][y] = object_list[len(object_list) - 1]
                count += 1
        return staircase, player, monster_list, object_list