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 durability(PlayerID, outil): # gestion de la durabilité d'un outil nb = int(sql.valueAtNumber(PlayerID, outil, "inventory")) if nb > 0: sql.add(PlayerID, outil, -1, "durability") if sql.valueAtNumber(PlayerID, outil, "durability") <= 0: for c in objetOutil: if c.nom == outil: sql.add(PlayerID, outil, c.durabilite, "durability") sql.add(PlayerID, outil, -1, "inventory") return True return False
def lootbox(PlayerID, lang, param=False): desc = "" D = r.randint(-40, 40) if D == 0: sql.add(PlayerID, "lootbox_legendarygems", 1, "inventory") sql.add(PlayerID, ["boxes", "lootbox | legendary gems | gain"], 1, "statgems") desc = lang_P.forge_msg(lang, "lootbox", ["{idmoji[gem_lootbox]}"], False, 2) elif (D == 10) or (D == -10): sql.add(PlayerID, "lootbox_raregems", 1, "inventory") sql.add(PlayerID, ["boxes", "lootbox | rare gems | gain"], 1, "statgems") desc = lang_P.forge_msg(lang, "lootbox", ["{idmoji[gem_lootbox]}"], False, 1) elif (D >= 29 and D <= 31) or (D >= -31 and D <= -29): sql.add(PlayerID, "lootbox_commongems", 1, "inventory") sql.add(PlayerID, ["boxes", "lootbox | common gems | gain"], 1, "statgems") desc = lang_P.forge_msg(lang, "lootbox", ["{idmoji[gem_lootbox]}"], False, 0) elif param: desc = gift(PlayerID, lang, True) return desc
def gift(PlayerID, lang, param=False): desc = "" jour = dt.date.today() nbgift = r.randint(-3, 3) if param: nbgift = r.randint(0, 2) if nbgift > 0: sql.add(PlayerID, "lootbox_gift", nbgift, "inventory") sql.add(PlayerID, ["boxes", "lootbox | gift | gain"], nbgift, "statgems") desc = lang_P.forge_msg(lang, "lootbox", [nbgift], False, 6) elif (jour.month == 12 and jour.day >= 22) and (jour.month == 12 and jour.day <= 25): if nbgift > 0: sql.add(PlayerID, "lootbox_gift", nbgift, "inventory") sql.add(PlayerID, ["boxes", "lootbox | gift | gain"], nbgift, "statgems") desc = lang_P.forge_msg(lang, "lootbox", [nbgift], False, 3) elif (jour.month == 12 and jour.day >= 30) or (jour.month == 1 and jour.day <= 2): if nbgift > 0: sql.add(PlayerID, "lootbox_gift", nbgift, "inventory") sql.add(PlayerID, ["boxes", "lootbox | gift | gain"], nbgift, "statgems") desc = lang_P.forge_msg(lang, "lootbox", [nbgift], False, 4) return desc
def startKit(ID): gems = sql.valueAtNumber(ID, "gems", "gems") if gems == 0: sql.addGems(ID, 100) sql.add(ID, "pickaxe", 1, "inventory") sql.add(ID, "fishingrod", 1, "inventory") sql.add(ID, "shovel", 1, "inventory") sql.add(ID, "pickaxe", 20, "durability") sql.add(ID, "fishingrod", 20, "durability") sql.add(ID, "shovel", 20, "durability")
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