Esempio n. 1
0
    async def filleul_supp(self, ctx, nom):
        """
        Affiche la liste des filleuls d'un joueur
        """
        if ctx.guild.id == wel.idBASTION:
            ID_p = ctx.author.id
            ID_f = ge.nom_ID(nom)
            if ID_f == -1:
                msg = "Ce joueur n'existe pas !"
                await ctx.channel.send(msg)
                return

            PlayerID_p = requests.get(
                'http://{ip}/users/playerid/{discord_id}'.format(
                    ip=ge.API_IP, discord_id=ID)).json()['ID']
            PlayerID_f = requests.get(
                'http://{ip}/users/playerid/{discord_id}'.format(
                    ip=ge.API_IP, discord_id=ID_f)).json()['ID']
            user_f = requests.get('http://{ip}/users/{player_id}'.format(
                ip=ge.API_IP, player_id=PlayerID_f)).json()
            parrain = user_f['godparent']
            if parrain == 0:
                return await ctx.channel.send("Ce joueur n'a pas de parrain")
            if parrain == PlayerID_p:
                lvl.addxp(PlayerID_f, -15)
                fil_count = requests.get(
                    'http://{ip}/users/godchilds/count/{player_id}'.format(
                        ip=ge.API_IP, player_id=PlayerID_p)).text
                gain_p = -100 * int(fil_count)
                lvl.addxp(PlayerID_p, gain_p)
                requests.put(
                    'http://{ip}/users/{player_id}/godparent/{godparentID}'.
                    format(ip=ge.API_IP, player_id=PlayerID_f, godparentID=0),
                    headers=headers)
                msg = "Votre filleul <@{filleul}> a bien été retiré ! Vous perdez {xp_p} XP et lui 15 XP.".format(
                    filleul=ID_f, xp_p=-gain_p)
            else:
                msg = "Vous n'etes pas son parrain !"
            await ctx.channel.send(msg)
        else:
            await ctx.channel.send(
                "commande utilisable uniquement sur le discord `Bastion`")
Esempio n. 2
0
    async def parrain(self, ctx, nom=None):
        """
        Permet d'ajouter un joueur comme parrain.
        En le faisant vous touchez un bonus et lui aussi
        """
        if ctx.guild.id == wel.idBASTION:
            ID = ctx.author.id
            if nom != None:
                ID_p = ge.nom_ID(nom)
                PlayerID = requests.get(
                    'http://{ip}/users/playerid/{discord_id}'.format(
                        ip=ge.API_IP, discord_id=ID)).json()['ID']
                user = requests.get('http://{ip}/users/{player_id}'.format(
                    ip=ge.API_IP, player_id=PlayerID)).json()
                PlayerID_p = requests.get(
                    'http://{ip}/users/playerid/{discord_id}'.format(
                        ip=ge.API_IP, discord_id=ID_p)).json()['ID']
                if PlayerID_p != 0 and user['godparent'] == 0 and ID_p != ID:
                    requests.put(
                        'http://{ip}/users/{player_id}/godparent/{godparentID}'
                        .format(ip=ge.API_IP,
                                player_id=PlayerID,
                                godparentID=PlayerID_p),
                        headers=headers)
                    # print("Parrain ajouté")
                    lvl.addxp(PlayerID, 15)
                    fil_L = requests.get(
                        'http://{ip}/users/godchilds/count/{player_id}'.format(
                            ip=ge.API_IP, player_id=PlayerID)).text
                    gain_p = 100 * int(fil_L)
                    lvl.addxp(PlayerID_p, gain_p)
                    msg = "Votre parrain a bien été ajouté ! Vous empochez 15 XP et lui {0} XP.".format(
                        gain_p)
                else:
                    msg = "Impossible d'ajouter ce joueur comme parrain"

            await ctx.channel.send(msg)
        else:
            await ctx.channel.send(
                "commande utilisable uniquement sur le discord `Bastion`")
Esempio n. 3
0
async def on_raw_reaction_remove(payload):
    if payload.guild_id == wel.idBASTION:
        ID = payload.user_id
        lvl.addxp(ID, -1)
        lvl.addreaction(ID, -1)
Esempio n. 4
0
def checkSuccess(PlayerID, lang):
    result = []
    i = -1
    for x in objetSuccess:
        if x.id > i:
            i = x.id
    myStat = 0
    for i in range(0, i + 1):
        iS = sql.valueAtNumber(PlayerID, i, "success")
        for x in objetSuccess:
            if x.id == i and x.sid == iS + 1:
                type = x.type.split("|")
                nom = ""

                if type[0] == "gems" or type[0] == "daily":
                    myStat = sql.valueAtNumber(PlayerID, "{0}".format(type[1]),
                                               "{0}".format(type[0]))
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "broken":
                    myStat = sql.valueAtNumber(
                        PlayerID,
                        "{0} | broken | {1}".format(type[1],
                                                    type[2]), "statgems")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "mine" or type[0] == "dig" or type[0] == "fish":
                    myStat = sql.valueAtNumber(
                        PlayerID, "{0} | item | {1}".format(type[0], type[1]),
                        "statgems")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "buy" or type[0] == "sell" or type[
                        0] == "gamble" or type[0] == "stealing":
                    if (type[0] == "buy"
                            or type[0] == "sell") and type[1] != "total":
                        myStat = sql.valueAtNumber(
                            PlayerID,
                            "{0} | item | {1}".format(type[0],
                                                      type[1]), "statgems")
                    else:
                        myStat = sql.valueAtNumber(
                            PlayerID, "{0} | {1}".format(type[0], type[1]),
                            "statgems")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "hothouse" or type[0] == "ferment" or type[
                        0] == "cooking":
                    myStat = sql.valueAtNumber(
                        PlayerID, "{0} | {1} | item | {2}".format(
                            type[0], type[1], type[2]), "statgems")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "forge":
                    myStat = sql.valueAtNumber(
                        PlayerID, "forge | item | {0}".format(type[1]),
                        "statgems")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "pay":
                    myStat = sql.valueAtNumber(PlayerID,
                                               "pay | {0}".format(type[1]),
                                               "statgems")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

                elif type[0] == "inv":
                    myStat = sql.valueAtNumber(PlayerID, "{0}".format(type[1]),
                                               "inventory")
                    if myStat >= x.objectif:
                        nom = lang_P.forge_msg(lang, "success titre",
                                               [GF.ChiffreRomain(x.sid)],
                                               False, x.titre)

#                 elif type[0] == "":
#                     myStat = sql.valueAtNumber(PlayerID, "", "statgems")
#                     if myStat >= x.objectif:
#                         nom = lang_P.forge_msg(lang, "success titre", [GF.ChiffreRomain(x.sid)], False, x.titre)

                if nom != "":
                    sql.add(PlayerID, i, 1, "success")
                    result.append(nom)
                    desc = "{0}".format(
                        lang_P.forge_msg(lang, "success", [nom], False, 0))
                    result.append(desc)
                    if iS == 0:
                        iS = 1
                    gain = r.randint(1, 3) * (6 * (iS))
                    lvl.addxp(PlayerID, gain, "gems")
                    desc = "{0} XP".format(
                        lang_P.forge_msg(lang, "success", [gain], False, 1))
                    if iS > 2:
                        desc += GF.lootbox(PlayerID, lang, True)
                    result.append(desc)
                    return result
    return result