def stats(param): nom = param["nom"] if nom != "None": nom = sql.nom_ID(nom) ID = sql.get_SuperID(nom, param["name_pl"]) else: ID = sql.get_SuperID(param["ID"], param["name_pl"]) 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") msg = [] desc = sql.valueAt(PlayerID, "all", "statgems") if desc != 0: msg.append("OK") msg.append(lang) for x in desc: msg.append(str(x)) else: msg.append("NOK") msg.append(lang) return msg
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
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
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
import random as r import datetime as dt from datetime import datetime, timedelta from apscheduler.schedulers.background import BackgroundScheduler from DB import TinyDB as DB, SQLite as sql import json from gems import gemsItems as GI, gemsStats as GS from languages import lang as lang_P idBaBot = 604776153458278415 idGetGems = 620558080551157770 try: PlayerID_GetGems = sql.get_PlayerID(sql.get_SuperID(idGetGems, "discord")) PlayerID_Babot = sql.get_PlayerID(sql.get_SuperID(idBaBot, "discord")) except: PlayerID_GetGems = 1 PlayerID_Babot = 2 # Taille max de l'Inventaire invMax = 5000 # Définition des classes class Item: def __init__(self, nom, vente, achat, poids, type): self.nom = nom self.vente = vente self.achat = achat self.poids = poids self.type = type
def exec_commands(c): """ Va se charger d'exécuter toutes les commandes params : dict c => message return : dict => name_c, name_p, name_pl, reponse """ # On récupère tous les modules dans gems list_here = gems.list_GG_module packets_list = list() function_dict = dict() res = dict() for i in list_here: # On exclut les magic func if "gems" in i: packets_list.append(i) for j in packets_list: tmp_list = list() tmp = dir(eval("gems." + j)) for k in tmp: tmp_list.append(k) function_dict[str(j)] = tmp_list commande = c["name_c"] file_c = "" for mod_name in packets_list: if commande in function_dict[mod_name]: # Où a été trouvé la commande file_c = mod_name break else: file_c = None # S'il a trouvé une commande if file_c is not None: commande_forgee = "getattr(eval(file_c), commande)" try: c["param_c"]["name_pl"] = c["name_pl"] if c["name_pl"] != "Admin": ID = sql.get_SuperID(c["name_p"], c["name_pl"]) else: ID = sql.get_SuperID(c["name_p"], "discord") if ID != "Error 404": c["param_c"]["lang"] = sql.valueAtNumber(ID, "LANG", "IDs") c["param_c"]["PlayerID"] = sql.get_PlayerID(ID, "gems") else: c["param_c"]["lang"] = "EN" commande_forgee = commande_forgee + '(' + str(c["param_c"]) + ')' except KeyError: pass # Appelle la fonction print(commande_forgee) if ID != "Error 404" or commande == "connect" or commande == "begin": # try: ret = eval(commande_forgee) res["reponse"] = ret # except: # res["reponse"] = ["WarningMsg", c["param_c"]["lang"], lang_P.forge_msg(c["param_c"]["lang"], "WarningMsg", None, False, 1)] else: res["reponse"] = [ "WarningMsg", c["param_c"]["lang"], lang_P.forge_msg(c["param_c"]["lang"], "WarningMsg", None, False, 0) ] res["name_c"] = commande res["name_p"] = c["name_p"] res["name_pl"] = c["name_pl"] else: res = None print(res) return res