예제 #1
0
    async def give(self, ctx: commands.Context, user: discord.Member, *,
                   species: str):
        """Give a pokémon."""

        member = await self.db.fetch_member_info(user)

        species = models.GameData.species_by_name(species)

        if species is None:
            return await ctx.send(
                f"Could not find a pokemon matching `{species}`.")

        await self.db.update_member(
            user,
            {
                "$push": {
                    "pokemon": {
                        "species_id": species.id,
                        "level": 1,
                        "xp": 0,
                        "nature": mongo.random_nature(),
                        "iv_hp": mongo.random_iv(),
                        "iv_atk": mongo.random_iv(),
                        "iv_defn": mongo.random_iv(),
                        "iv_satk": mongo.random_iv(),
                        "iv_sdef": mongo.random_iv(),
                        "iv_spd": mongo.random_iv(),
                    }
                },
            },
        )

        await ctx.send(f"Gave {user.mention} a {species}.")
예제 #2
0
파일: admin.py 프로젝트: markman123/poketwo
    async def setup(self,
                    ctx: commands.Context,
                    user: discord.Member,
                    num: int = 100):
        """Test setup pokémon."""

        # This is for development purposes.

        member = await self.db.fetch_member_info(user)

        pokemon = []
        idx = await self.db.fetch_next_idx(user, reserve=num)

        for i in range(num):
            spid = random.randint(1, 809)
            pokemon.append({
                "owner_id": user.id,
                "species_id": spid,
                "level": 80,
                "xp": 0,
                "nature": mongo.random_nature(),
                "iv_hp": mongo.random_iv(),
                "iv_atk": mongo.random_iv(),
                "iv_defn": mongo.random_iv(),
                "iv_satk": mongo.random_iv(),
                "iv_sdef": mongo.random_iv(),
                "iv_spd": mongo.random_iv(),
                "shiny": False,
                "idx": idx + i,
            })

        await self.bot.mongo.db.pokemon.insert_many(pokemon)
        await ctx.send(f"Gave {user.mention} {num} pokémon.")
예제 #3
0
파일: admin.py 프로젝트: markman123/poketwo
    async def give(self, ctx: commands.Context, user: discord.Member, *,
                   species: str):
        """Give a pokémon."""

        member = await self.db.fetch_member_info(user)

        shiny = False

        if species.lower().startswith("shiny"):
            shiny = True
            species = species.lower().replace("shiny", "").strip()

        species = self.bot.data.species_by_name(species)

        if species is None:
            return await ctx.send(
                f"Could not find a pokemon matching `{species}`.")

        await self.bot.mongo.db.pokemon.insert_one({
            "owner_id":
            user.id,
            "species_id":
            species.id,
            "level":
            1,
            "xp":
            0,
            "nature":
            mongo.random_nature(),
            "iv_hp":
            mongo.random_iv(),
            "iv_atk":
            mongo.random_iv(),
            "iv_defn":
            mongo.random_iv(),
            "iv_satk":
            mongo.random_iv(),
            "iv_sdef":
            mongo.random_iv(),
            "iv_spd":
            mongo.random_iv(),
            "shiny":
            shiny,
            "idx":
            await self.db.fetch_next_idx(user),
        })

        await ctx.send(f"Gave {user.mention} a {species}.")
예제 #4
0
    async def setup(self,
                    ctx: commands.Context,
                    user: discord.Member,
                    num: int = 100):
        """Test setup pokémon."""

        # This is for development purposes.

        member = await self.db.fetch_member_info(user)

        pokemon = []
        pokedex = {}

        for i in range(num):
            spid = random.randint(1, 809)
            pokemon.append({
                "species_id": spid,
                "level": 80,
                "xp": 0,
                "nature": mongo.random_nature(),
                "iv_hp": mongo.random_iv(),
                "iv_atk": mongo.random_iv(),
                "iv_defn": mongo.random_iv(),
                "iv_satk": mongo.random_iv(),
                "iv_sdef": mongo.random_iv(),
                "iv_spd": mongo.random_iv(),
                "shiny": random.randint(1, 4096) == 1,
            })
            pokedex["pokedex." +
                    str(spid)] = pokedex.get("pokedex." + str(spid), 0) + 1

        await self.db.update_member(
            user,
            {
                "$push": {
                    "pokemon": {
                        "$each": pokemon
                    }
                },
                "$inc": pokedex
            },
        )

        await ctx.send(f"Gave {user.mention} {num} pokémon.")
예제 #5
0
    async def catch(self, ctx: commands.Context, *, guess: str):
        """Catch a wild pokémon."""

        # Retrieve correct species and level from tracker

        if ctx.channel.id not in self.bot.spawns:
            return

        species, level, hint, shiny, users = self.bot.spawns[ctx.channel.id]

        if (models.deaccent(guess.lower().replace("′", "'"))
                not in species.correct_guesses):
            return await ctx.send("That is the wrong pokémon!")

        # Correct guess, add to database

        if ctx.channel.id == 759559123657293835:
            if ctx.author.id in users:
                return await ctx.send("You have already caught this pokémon!")

            users.append(ctx.author.id)
        else:
            del self.bot.spawns[ctx.channel.id]

        member = await self.db.fetch_member_info(ctx.author)

        if shiny is None:
            shiny = member.determine_shiny(species)

        moves = [x.move.id for x in species.moves if level >= x.method.level]
        random.shuffle(moves)

        await self.bot.mongo.db.pokemon.insert_one({
            "owner_id":
            ctx.author.id,
            "species_id":
            species.id,
            "level":
            level,
            "xp":
            0,
            "nature":
            mongo.random_nature(),
            "iv_hp":
            mongo.random_iv(),
            "iv_atk":
            mongo.random_iv(),
            "iv_defn":
            mongo.random_iv(),
            "iv_satk":
            mongo.random_iv(),
            "iv_sdef":
            mongo.random_iv(),
            "iv_spd":
            mongo.random_iv(),
            "moves":
            moves[:4],
            "shiny":
            shiny,
            "idx":
            await self.db.fetch_next_idx(ctx.author),
        })
        if shiny:
            await self.db.update_member(ctx.author,
                                        {"$inc": {
                                            "shinies_caught": 1
                                        }})

        message = f"Congratulations {ctx.author.mention}! You caught a level {level} {species}!"

        memberp = await self.db.fetch_pokedex(ctx.author, species.dex_number,
                                              species.dex_number + 1)

        if str(species.dex_number) not in memberp.pokedex:
            message += " Added to Pokédex. You received 35 Pokécoins!"

            await self.db.update_member(
                ctx.author,
                {
                    "$set": {
                        f"pokedex.{species.dex_number}": 1
                    },
                    "$inc": {
                        "balance": 35
                    },
                },
            )

        else:
            inc_bal = 0

            if memberp.pokedex[str(species.dex_number)] + 1 == 10:
                message += f" This is your 10th {species}! You received 350 Pokécoins."
                inc_bal = 350

            elif memberp.pokedex[str(species.dex_number)] + 1 == 100:
                message += (
                    f" This is your 100th {species}! You received 3500 Pokécoins."
                )
                inc_bal = 3500

            elif memberp.pokedex[str(species.dex_number)] + 1 == 1000:
                message += (
                    f" This is your 1000th {species}! You received 35000 Pokécoins."
                )
                inc_bal = 35000

            await self.db.update_member(
                ctx.author,
                {
                    "$inc": {
                        "balance": inc_bal,
                        f"pokedex.{species.dex_number}": 1
                    },
                },
            )

        if member.shiny_hunt == species.dex_number:
            if shiny:
                message += f"\n\nShiny streak reset."
                await self.db.update_member(ctx.author,
                                            {"$set": {
                                                "shiny_streak": 0
                                            }})
            else:
                message += f"\n\n+1 Shiny chain! (**{member.shiny_streak + 1}**)"
                await self.db.update_member(ctx.author,
                                            {"$inc": {
                                                "shiny_streak": 1
                                            }})

        if shiny:
            message += "\n\nThese colors seem unusual... ✨"

        await ctx.send(message)
예제 #6
0
    async def catch(self, ctx: commands.Context, *, guess: str):
        """Catch a wild pokémon."""

        # Retrieve correct species and level from tracker

        if ctx.channel.id not in self.bot.spawns:
            return

        species, level, hint, shiny, users = self.bot.spawns[ctx.channel.id]

        if (models.deaccent(guess.lower().replace("′", "'"))
                not in species.correct_guesses):
            return await ctx.send("That is the wrong pokémon!")

        # Correct guess, add to database

        if ctx.channel.id == 720944005856100452:
            if ctx.author.id in users:
                return await ctx.send("You have already caught this pokémon!")

            users.append(ctx.author.id)
        else:
            del self.bot.spawns[ctx.channel.id]

        member = await self.db.fetch_member_info(ctx.author)

        if shiny is None:
            shiny = random.randint(1, 4096) == 1

        await self.db.update_member(
            ctx.author,
            {
                "$inc": {
                    "shinies_caught": 1 if shiny else 0
                },
                "$push": {
                    "pokemon": {
                        "species_id": species.id,
                        "level": level,
                        "xp": 0,
                        "nature": mongo.random_nature(),
                        "iv_hp": mongo.random_iv(),
                        "iv_atk": mongo.random_iv(),
                        "iv_defn": mongo.random_iv(),
                        "iv_satk": mongo.random_iv(),
                        "iv_sdef": mongo.random_iv(),
                        "iv_spd": mongo.random_iv(),
                        "shiny": shiny,
                    }
                },
            },
        )

        message = f"Congratulations {ctx.author.mention}! You caught a level {level} {species}!"

        memberp = await self.db.fetch_pokedex(ctx.author, species.dex_number,
                                              species.dex_number + 1)

        if str(species.dex_number) not in memberp.pokedex:
            message += " Added to Pokédex. You received 35 Pokécoins!"

            await self.db.update_member(
                ctx.author,
                {
                    "$set": {
                        f"pokedex.{species.dex_number}": 1
                    },
                    "$inc": {
                        "balance": 35
                    },
                },
            )

        else:
            inc_bal = 0

            if memberp.pokedex[str(species.dex_number)] + 1 == 10:
                message += f" This is your 10th {species}! You received 350 Pokécoins."
                inc_bal = 350

            elif memberp.pokedex[str(species.dex_number)] + 1 == 100:
                message += (
                    f" This is your 100th {species}! You received 3500 Pokécoins."
                )
                inc_bal = 3500

            elif memberp.pokedex[str(species.dex_number)] + 1 == 1000:
                message += (
                    f" This is your 1000th {species}! You received 35000 Pokécoins."
                )
                inc_bal = 35000

            await self.db.update_member(
                ctx.author,
                {
                    "$inc": {
                        "balance": inc_bal,
                        f"pokedex.{species.dex_number}": 1
                    },
                },
            )

        if shiny:
            message += "\n\nThese colors seem unusual... ✨"

        await ctx.send(message)
예제 #7
0
    async def redeem(self, ctx: commands.Context, *, species: str = None):
        """Use a redeem to receive a pokémon of your choice."""

        member = await self.db.fetch_member_info(ctx.author)

        if species is None:
            embed = self.bot.Embed()
            embed.title = f"Your Redeems: {member.redeems}"
            embed.description = "You can use redeems to receive any pokémon of your choice. You can receive redeems by supporting the bot on Patreon or through voting rewards."

            embed.add_field(
                name=f"{ctx.prefix}redeem <pokémon>",
                value="Use a redeem to receive a pokémon of your choice.",
            )

            embed.add_field(
                name=f"{ctx.prefix}redeemspawn <pokémon>",
                value=
                "Use a redeem to spawn a pokémon of your choice in the current channel (careful, if something else spawns, it'll be overrided).",
            )

            return await ctx.send(embed=embed)

        if member.redeems == 0:
            return await ctx.send("You don't have any redeems!")

        species = self.bot.data.species_by_name(species)
        if species is None:
            return await ctx.send(
                f"Could not find a pokemon matching `{species}`.")

        if not species.catchable or "Alolan" in species.name:
            return await ctx.send("You can't redeem this pokémon!")

        await self.db.update_member(
            ctx.author,
            {
                "$inc": {
                    "redeems": -1
                },
                "$push": {
                    "pokemon": {
                        "species_id": species.id,
                        "level": 1,
                        "xp": 0,
                        "nature": mongo.random_nature(),
                        "iv_hp": mongo.random_iv(),
                        "iv_atk": mongo.random_iv(),
                        "iv_defn": mongo.random_iv(),
                        "iv_satk": mongo.random_iv(),
                        "iv_sdef": mongo.random_iv(),
                        "iv_spd": mongo.random_iv(),
                        "shiny": member.determine_shiny(species),
                    }
                },
            },
        )

        await ctx.send(
            f"You used a redeem and received a {species}! View it with `{ctx.prefix}info latest`."
        )