コード例 #1
0
ファイル: pokemaster.py プロジェクト: duongd08/pokemaster_bot
async def pokecenter(ctx, *args):
    """
    Heals your whole party pokemon for ₱150
    """
    author = ctx.message.author
    database.add_pokedollars(author, -150)
    database.heal_party(author)

    embed = Embed(
        color=0xB80800,
        description="**{}** Welcome to the Pokemon Center!".format(author))
    embed.set_author(
        name="Nurse Joy",
        icon_url=
        "https://i.pinimg.com/originals/ed/47/7c/ed477c99f4776886de48d5789f25776d.jpg"
    )
    embed.add_field(name="Your Pokemon are healed!",
                    value="Thanks for coming in. Please Come again ;)",
                    inline=False)
    embed.set_footer(
        text=
        "Nurse Joy charged you ₱150 for her services. She ain't messin with no broke broke."
    )
    embed.set_image(
        url=
        "https://cdn.bulbagarden.net/upload/thumb/9/9f/Nurse_Joy_anime_SM.png/250px-Nurse_Joy_anime_SM.png"
    )
    return await pokemaster_bot.say(embed=embed)
コード例 #2
0
async def deposit(ctx, money:int):
    """
    Puts money in account
    """
    author = ctx.message.author
    if str(author) in settings.BOT_ADMIN:
        database.add_pokedollars(author, money)
        await ctx.send("funds deposited")
    else:
        await ctx.send("You are not the bot admin. Go awai.")
コード例 #3
0
async def battle(ctx):
    message = ctx.message
    author = message.author
    wild_pkmn = database.get_random_pokemon(type="battle")
    wild_pkmn_id = wild_pkmn["national_id"]
    wild_pkmn["health"] = wild_pkmn["hp"]
    wild_pkmn_name = wild_pkmn["name"]
    wild_pkmn_name_stripped = wild_pkmn_name.lower().split("-")[0]

    tier = _get_tier(int(wild_pkmn_id))
    prize_money = _get_money_earned(tier)

    party = database.get_party(author)
    fainted = []
    winner = None
    fought_pkmn = []
    for my_pkmn in party:
        if my_pkmn["health"] <= 0:
            last_pkmn = my_pkmn
            continue
        wild_pkmn["health"] = _fight_wild(author, my_pkmn, wild_pkmn)
        fought_pkmn.append(my_pkmn)
        last_pkmn = my_pkmn
        if wild_pkmn["health"] <= 0:
            winner = my_pkmn
            last_pkmn = my_pkmn
            break
        else:
            fainted.append(my_pkmn["name"])
    if len(fought_pkmn) == 0:
        return await ctx.send("Oak: Are you trying to fight the pokemon with your fist? Add some pokemon to your party first.")

    color = _get_tier_color(wild_pkmn_id)
    embed = Embed(color=color, description="**{}** you encountered **{}**".format(message.author, wild_pkmn_name_stripped))
    embed.set_thumbnail(url="http://marktan.us/pokemon/img/icons/{}.png".format(last_pkmn["national_id"]))
    # embed.add_field(name="Fainted Pokemon", value=", ".join(fainted))
    embed.set_image(
        url="http://www.pkparaiso.com/imagenes/xy/sprites/animados/{}.gif".format(wild_pkmn_name.lower()))

    if winner is None:
        # do losing message here
        embed.add_field(name="Oak", value="Your party pokemon was wiped out. Get rekt m8")
        # deduct money
        database.add_pokedollars(author, prize_money * -1)
    else:
        # do winning embed here
        winner_name = winner["name"]
        health_remaining = int((winner["health"]/winner["hp"]) * 100)
        text1 = "has {}% health remaining after the fight".format(health_remaining)
        embed.add_field(name="{} won the fight!".format(winner_name), value=text1, inline=False)
        embed.add_field(name="Pokedollars Earned", value="₱{}".format(prize_money))
        # add prize money
        database.add_pokedollars(author, prize_money)
    return await ctx.send(embed=embed)
コード例 #4
0
async def release(ctx, pkmn_id: int):
    """
    Release a pokemon from your party for money.
    Pokemon trafficking is a thing.
    """
    res = database.release_from_party(ctx.message.author, pkmn_id)
    if res:
        tier = _get_tier(int(pkmn_id))
        money = int(_get_money_earned(tier)/3)
        message = "Oak: Don't worry I'll take care of {} ;) \nHere's ₱{}, buy yourself something nice."\
            .format(database.get_pokemon_name(pkmn_id), money)
        database.add_pokedollars(ctx.message.author, money)
    else:
        message = "**Oak**: Make sure you actually have that pokemon or if your party is not full ya scrub."
    await ctx.send(message)
コード例 #5
0
async def battle_trainer(ctx, author, enemy, bet=None):
    # check if have enough money for bet
    if bet:
        if database.get_pokedollars(author) < bet:
            return await ctx.send("Oak: You're too broke to bet that amount.")
    # check battles if enemy already challenged you
    if author in battles.keys() and enemy in battles[author].keys():
        pass
    elif enemy not in battles.keys():
        battles[enemy] = {author: bet}
        print(battles)
        return await ctx.send("waiting for %s's response" % enemy)
    elif author not in battles[enemy].keys():
        battles[enemy][author] = bet
        print(battles)
        return await ctx.send("waiting for %s's response" % enemy)
    # remove from your pending battles and start battle
    bet = battles[author][enemy]
    battles[author].pop(enemy)

    party1 = database.get_party(author)
    party2 = database.get_party(enemy)
    fainted1 = []
    fainted2 = []

    pkmn1 = party1.pop()
    pkmn2 = party2.pop()
    while len(fainted1) < 6 and len(fainted2) < 6:
        try:
            # check if pokemon is not already fainted
            while pkmn1["health"] <= 0:
                fainted1.append(pkmn1)
                pkmn1 = party1.pop()
            while pkmn2["health"] <= 0:
                fainted2.append(pkmn2)
                pkmn2 = party2.pop()

            result = _fight_trainer(author, enemy, pkmn1, pkmn2)
            if result:
                fainted2.append(pkmn2)
                pkmn2 = party2.pop()
            else:
                fainted1.append(pkmn1)
                pkmn1 = party1.pop()
        except IndexError:
            break

    if len(fainted1) > len(fainted2):
        winner = enemy
        loser = author
    elif len(fainted2) > len(fainted1):
        winner = author
        loser = enemy
    else:
        winner = None

    color = 0xff0000
    embed = Embed(color=color, description="**{}** VS **{}**".format(author, enemy))
    embed.set_thumbnail(url="https://i0.wp.com/alphadigits.com/wp-content/uploads/2014/01/pokebuilder-icon.png?fit=300%2C300")
    embed.set_image(url="https://archives.bulbagarden.net/media/upload/a/a0/Spr_B2W2_Hilbert.png")

    if winner is None:
        embed.add_field(name="Oak", value="The battle was a tie. How disappointing...")
    else:
        # do winning embed here
        embed.add_field(name="Winner:".format(winner), value=winner, inline=False)
        embed.add_field(name="Pokedollars Earned", value="₱{}".format(bet))
        # add prize money
        database.add_pokedollars(winner, bet)
        database.add_pokedollars(loser, bet * -1)
    return await ctx.send(embed=embed)