コード例 #1
0
def addxp(ID, nb, nameDB):
    balXP = sql.valueAtNumber(ID, "xp", nameDB)
    if balXP != None:
        ns = balXP + int(nb)
        if ns <= 0:
            ns = 0
        sql.updateField(ID, "xp", ns, nameDB)
        return True
    else:
        return False
コード例 #2
0
ファイル: gemsAdmin.py プロジェクト: bastion-gaming/GG-Server
def admin(param):
    fct = param["fct"]
    arg2 = param["arg2"]
    arg3 = param["arg3"]
    arg4 = param["arg4"]
    msg = []
    if fct == "playerid":
        if arg2 == "None":
            platform = param["name_pl"]
        else:
            platform = arg2
    else:
        platform = param["name_pl"]
    if param["name_pl"] == "Admin" and fct != "playerid":
        PlayerID = int(param["ID"])
        lang = "EN"
    else:
        ID = sql.get_SuperID(int(param["ID"]), platform)
        lang = param["lang"]
        if ID == "Error 404":
            msg = [
                "WarningMsg",
                lang_P.forge_msg(lang, "WarningMsg", None, False, 0)
            ]
            return msg
        PlayerID = sql.get_PlayerID(ID, "gems")

    if fct == "init":
        sql.init()
    elif fct == "update":
        # arg2 = nameDB | arg3 = fieldName | arg4 = fieldValue
        desc = sql.updateField(PlayerID, arg3, arg4, arg2)
    elif fct == "add":
        # arg2 = nameDB | arg3 = nameElem | arg4 = nbElem
        desc = sql.add(PlayerID, arg3, arg4, arg2)
    elif fct == "value":
        # arg2 = nameDB | arg3 = nameElem
        desc = sql.valueAt(PlayerID, arg3, arg2)
    elif fct == "gems":
        # arg2 = nb gems
        desc = sql.addGems(PlayerID, arg2)
    elif fct == "spinelles":
        # arg2 = nb spinelles
        desc = sql.addSpinelles(PlayerID, arg2)
    elif fct == "balance total" or fct == 'balancetotal':
        desc = "Balance total"
        desc += "\n{}:gem:".format(sql.countTotalGems())
        spinelleidmoji = "{idmoji[spinelle]}"
        desc += "\n{0}<:spinelle:{1}>".format(sql.countTotalSpinelles(),
                                              spinelleidmoji)
    elif fct == "playerid":
        desc = "PlayerID: {}".format(PlayerID)
    else:
        desc = ":regional_indicator_s::regional_indicator_q::regional_indicator_l:"

    msg.append("Admin {}".format(fct))
    msg.append(lang)
    msg.append(str(desc))
    return msg
コード例 #3
0
def checklevel(ID):
    lang = sql.valueAtNumber(ID, "LANG", "IDs")
    if lang == None:
        lang = "EN"
    if ID == "Error 404":
        msg = [
            "WarningMsg",
            lang_P.forge_msg(lang, "WarningMsg", None, False, 0)
        ]
        return msg
    PlayerID = sql.get_PlayerID(ID, "gems")
    # print(PlayerID)
    msg = []
    S = success.checkSuccess(PlayerID, lang)
    try:
        lvl = sql.valueAtNumber(PlayerID, "lvl", "gems")
        xp = sql.valueAtNumber(PlayerID, "xp", "gems")
        palier = lvlPalier(lvl)
        desc = ""
        if xp >= palier:
            lvl = lvl + 1
            sql.updateField(PlayerID, "lvl", lvl, "gems")
            desc = lang_P.forge_msg(lang, "level", [lvl], False, 0)
            nbG = 100 * lvl
            sql.addGems(PlayerID, nbG)
            desc += lang_P.forge_msg(lang, "level", [nbG], False, 1)
            msg.append("Level UP")
        else:
            msg.append("Level OK")
        msg.append(desc)
        if S != []:
            msg.append(S)
    except:
        print("Level >> Le joueur n'existe pas.")
        msg.append("Level NOK")
        msg.append("Le joueur n'existe pas")
    return msg
コード例 #4
0
def end_season():
    """
    recupere le nombre de gems et le nombre de gems dans la banque,
    stock ces valeurs dans la base de donnée (table seasons) et met
    ces 2 valeurs a 0 + supprime tous les items a prix fixe dans l'inventaire
    """
    res = load_dates()
    nbs = res["total"]
    nb_invest = 0  # Nombre de joueur considéré comme ayant joué
    bank_tot = 0  # Total de la banque
    for i in range(1, sql.taille("gems") + 1):
        # Récupération des données par Joueur
        IDs = sql.userID(i, "gems")
        IDd = IDs[1]
        IDm = IDs[2]
        if IDd is not None:
            SuperID = sql.get_SuperID(IDd, "discord")
        elif IDm is not None:
            SuperID = sql.get_SuperID(IDd, "messenger")
        else:
            SuperID = 0
        PlayerID = sql.get_PlayerID(SuperID)
        solde = sql.valueAtNumber(PlayerID, "gems", "gems")
        bank = sql.valueAtNumber(PlayerID, "Solde", "bank")

        # Valeurs nécessaires au multiplicateur
        if solde != 100:
            nb_invest = nb_invest + 1
            bank_tot = bank_tot + bank

        # Sauvegarde des valeurs de la saison en  cours par Joueur
        save = sql.add(PlayerID, "idseasons", nbs, "seasons")
        print(save)
        if save != 404 and save != 102:
            sql.updateField(PlayerID, "gem", [solde, nbs], "seasons")
            sql.updateField(PlayerID, "bank", [bank, nbs], "seasons")
            # Reset solde de gems et solde de la banque
            sql.updateField(PlayerID, "gems", 100, "gems")
            sql.updateField(PlayerID, "Solde", 0, "bank")
            # Reset dans l'inventaire des objets à prix fixe du marché
            for x in GI.exception:
                if x != "bank_upgrade":
                    sql.updateField(PlayerID, x, 0, "inventory")
            # reset dans l'inventaire des objets événementiels
            for x in GF.ObjetEventEnd:
                if x != "bank_upgrade":
                    sql.updateField(PlayerID, x, 0, "inventory")
    with open('core/saisons.json', 'r') as fp:
        dict = json.load(fp)
    dict["total"] = nbs + 1
    with open('core/saisons.json', 'w') as fp:
        json.dump(dict, fp, indent=4)
    return True, nb_invest, bank_tot