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 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
def save(self): with SQLite() as db: db.execute( ''' INSERT INTO locations VALUES (NULL, ?) ''', (self.title, )) return self
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 find_by_email(email): if not email: return None with SQLite() as db: row = db.execute( 'SELECT * FROM user WHERE email = ?', (email,) ).fetchone() if row: return User(*row)
def all(available_from=None, available_to=None): with SQLite() as db: rows = db.execute('SELECT * FROM post').fetchall() if available_from=="undefined": available_from=None if available_to=="undefined": available_to=None if not available_from or not available_to: return [Post(*row) for row in rows] return [Post(*row) for row in rows if ( datetime.datetime.strptime(row[7], "%Y-%m-%d").date() <= datetime.datetime.strptime(available_from, "%Y-%m-%d").date() and datetime.datetime.strptime(row[8], "%Y-%m-%d").date() >= datetime.datetime.strptime(available_to, "%Y-%m-%d").date())]
def save(self): with SQLite() as db: db.execute( ''' INSERT INTO post VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ''', ( self.title, self.image, self.size, self.price, self.bed_count, self.location_id, self.available_from, self.available_to, self.description, self.user_id)) return self
def testInvTaille(ID): """Verifie si l'inventaire est plein """ inv = sql.valueAt(ID, "all", "inventory") tailletot = 0 if inv != 0: for c in objetOutil: for x in inv: if c.nom == str(x[1]): if int(x[0]) > 0: tailletot += c.poids * int(int(x[0])) for c in objetItem: for x in inv: if c.nom == str(x[1]): if int(x[0]) > 0: tailletot += c.poids * int(int(x[0])) if tailletot <= invMax: return True else: return False
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
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 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 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
def create(self): with SQLite() as db: db.execute(''' INSERT INTO user (email, password) VALUES (?, ?)''', (self.email, self.password)) return self
from core import level as lvl from core import manage_seasons as MS import manage_commands as mc from languages import lang # Ouverture du port context = zmq.Context() socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") check = True msg = "" VERSION = open("core/version.txt").read().replace("\n", "") # Initialisation print('\nGet Gems - Server ' + VERSION) print(sql.init()) flag = sql.checkField() if flag == 0: print("SQL >> Aucun champ n'a été ajouté, supprimé ou modifié.") elif "add" in flag: print("SQL >> Un ou plusieurs champs ont été ajoutés à la DB.") elif "sup" in flag: print("SQL >> Un ou plusieurs champs ont été supprimés de la DB.") elif "type" in flag: print("SQL >> Un ou plusieurs type ont été modifié sur la DB.") sql.newPlayer(GF.idGetGems, "gems", "discord", "Get Gems") sql.newPlayer(GF.idBaBot, "gems", "discord", "BaBot") lang.init()
def success(param): lang = param["lang"] PlayerID = param["PlayerID"] msg = [] result = [] dict = {} i = -1 for x in objetSuccess: if x.id > i: i = x.id dict[x.id] = x.sid for i in range(0, i + 1): iS = sql.valueAtNumber(PlayerID, i, "success") for x in objetSuccess: arg = None if x.id == i: type = x.type.split("|") if type[0] == "gems" or type[0] == "daily": myStat = sql.valueAtNumber(PlayerID, "{0}".format(type[1]), "{0}".format(type[0])) if type[0] == "gems": arg = None else: arg = [x.objectif] elif type[0] == "broken": myStat = sql.valueAtNumber( PlayerID, "{0} | broken | {1}".format(type[1], type[2]), "statgems") arg = [ x.objectif, type[2], "{idmoji[gem_" + type[2] + "]}" ] 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") arg = [ x.objectif, type[1], "{idmoji[gem_" + type[1] + "]}" ] elif type[0] == "buy" or type[0] == "sell": 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") arg = [ x.objectif, type[1], "{idmoji[gem_" + type[1] + "]}" ] else: myStat = sql.valueAtNumber( PlayerID, "{0} | {1}".format(type[0], type[1]), "statgems") arg = [x.objectif] elif type[0] == "gamble" or type[0] == "stealing" or type[ 0] == "slots": myStat = sql.valueAtNumber( PlayerID, "{0} | {1}".format(type[0], type[1]), "statgems") arg = [x.objectif] elif type[0] == "pay": myStat = sql.valueAtNumber(PlayerID, "pay | {0}".format(type[1]), "statgems") arg = [x.objectif] elif type[0] == "forge": myStat = sql.valueAtNumber( PlayerID, "forge | item | {0}".format(type[1]), "statgems") arg = [ x.objectif, type[1], "{idmoji[gem_" + type[1] + "]}" ] 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 type[2] in GI.objetEmoji: idmoji = ":{0}:".format(type[2]) else: idmoji = "<:gem_{0}:{1}>".format( type[2], "{idmoji[gem_" + type[2] + "]}") arg = [x.objectif, type[2], idmoji] elif type[0] == "inv": myStat = sql.valueAtNumber(PlayerID, "{0}".format(type[1]), "inventory") if type[1] in GI.objetEmoji: idmoji = ":{0}:".format(type[1]) else: idmoji = "<:gem_{0}:{1}>".format( type[1], "{idmoji[gem_" + type[1] + "]}") arg = [x.objectif, type[1], idmoji] if x.sid == iS + 1: result.append( lang_P.forge_msg(lang, "success titre", [GF.ChiffreRomain(x.sid)], False, x.titre)) desc = "{0} | `{1}`/`{2}`".format( lang_P.forge_msg(lang, "success desc", arg, False, x.desc), myStat, x.objectif) result.append(desc) elif iS == dict[i] and x.sid == iS: desc = "{0} | **_{1}_**".format( lang_P.forge_msg(lang, "success desc", arg, False, x.desc), lang_P.forge_msg(lang, "success", None, False, 2)) result.append( lang_P.forge_msg(lang, "success titre", [GF.ChiffreRomain(x.sid)], False, x.titre)) result.append(desc) msg.append("OK") msg.append(lang) msg.append(result) 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 loadItem(F=False): jour = dt.date.today() # Récupere le multiplicateur m = 1 if jour.day == 5 or jour.day == 13 or jour.day == 20: path = "core/saisons.json" with open(path, encoding='utf-8') as json_file: data = json.load(json_file) m = data["mult"] if m <= 0: m = 1 if F: GI.initBourse() global ObjetEventEnd ObjetEventEnd = [] # ========== Items ========== global objetItem objetItem = [ Item("cobblestone", m * itemBourse("cobblestone", "vente"), m * itemBourse("cobblestone", "achat"), 4, "minerai"), Item("iron", m * itemBourse("iron", "vente"), m * itemBourse("iron", "achat"), 10, "minerai"), Item("gold", m * itemBourse("gold", "vente"), m * itemBourse("gold", "achat"), 20, "minerai"), Item("diamond", m * itemBourse("diamond", "vente"), m * itemBourse("diamond", "achat"), 40, "minerai"), Item("emerald", m * itemBourse("emerald", "vente"), m * itemBourse("emerald", "achat"), 50, "minerai"), Item("ruby", m * itemBourse("ruby", "vente"), m * itemBourse("ruby", "achat"), 70, "minerai"), Item("fish", m * itemBourse("fish", "vente"), m * itemBourse("fish", "achat"), 2, "poisson"), Item("tropicalfish", m * itemBourse("tropicalfish", "vente"), m * itemBourse("tropicalfish", "achat"), 8, "poisson"), Item("blowfish", m * itemBourse("blowfish", "vente"), m * itemBourse("blowfish", "achat"), 8, "poisson"), Item("octopus", m * itemBourse("octopus", "vente"), m * itemBourse("octopus", "achat"), 16, "poisson"), Item("seed", m * itemBourse("seed", "vente"), m * itemBourse("seed", "achat"), 0.5, "plante"), Item("cacao", m * itemBourse("cacao", "vente"), m * itemBourse("cacao", "achat"), 1, "plante"), Item("potato", m * itemBourse("potato", "vente"), m * itemBourse("potato", "achat"), 1, "plante"), Item("oak", m * itemBourse("oak", "vente"), m * itemBourse("oak", "achat"), 50, "plante"), Item("spruce", m * itemBourse("spruce", "vente"), m * itemBourse("spruce", "achat"), 70, "plante"), Item("palm", m * itemBourse("palm", "vente"), m * itemBourse("palm", "achat"), 60, "plante"), Item("wheat", m * itemBourse("wheat", "vente"), m * itemBourse("wheat", "achat"), 3, "plante"), Item("grapes", m * itemBourse("grapes", "vente"), m * itemBourse("grapes", "achat"), 1, "emoji"), Item("wine_glass", m * itemBourse("wine_glass", "vente"), m * itemBourse("wine_glass", "achat"), 2, "emoji"), Item("beer", m * itemBourse("beer", "vente"), m * itemBourse("beer", "achat"), 2, "emoji"), Item("chocolate", m * itemBourse("chocolate", "vente"), m * itemBourse("chocolate", "achat"), 3, "consommable"), Item("fries", m * itemBourse("fries", "vente"), m * itemBourse("fries", "achat"), 30, "consommable"), Item("cookie", m * itemBourse("cookie", "vente"), m * itemBourse("cookie", "achat"), 1, "emoji"), Item("candy", m * itemBourse("candy", "vente"), m * itemBourse("candy", "achat"), 1, "emoji"), Item("lollipop", m * itemBourse("lollipop", "vente"), m * itemBourse("lollipop", "achat"), 2, "emoji"), Item("backpack", m * itemBourse("backpack", "vente"), m * itemBourse("backpack", "achat"), -200, "special"), Item("hyperpack", m * itemBourse("hyperpack", "vente"), m * itemBourse("hyperpack", "achat"), -2000, "special"), Item("fishhook", m * itemBourse("fishhook", "vente"), m * itemBourse("fishhook", "achat"), 1, "special") ] if not (jour.month == 10 and jour.day >= 22) or (jour.month == 11 and jour.day <= 10): for one in GI.ObjetHalloween: ObjetEventEnd.append(one) if not (jour.month == 12 and jour.day >= 20) or (jour.month == 1 and jour.day <= 14): for one in GI.ObjetChristmas: ObjetEventEnd.append(one) objetItem += [ Item("pumpkin", m * itemBourse("pumpkin", "vente"), m * itemBourse("pumpkin", "achat"), 5, "halloween"), Item("pumpkinpie", m * itemBourse("pumpkinpie", "vente"), m * itemBourse("pumpkinpie", "achat"), 30, "halloween") ] objetItem += [ Item("cupcake", m * itemBourse("cupcake", "vente"), m * itemBourse("cupcake", "achat"), 10, "christmas") ] # ========== Outils ========== global objetOutil objetOutil = [ Outil("fishingrod", itemBourse("fishingrod", "vente"), itemBourse("fishingrod", "achat"), 25, 100, ""), Outil("pickaxe", itemBourse("pickaxe", "vente"), itemBourse("pickaxe", "achat"), 15, 75, ""), Outil("iron_pickaxe", itemBourse("iron_pickaxe", "vente"), itemBourse("iron_pickaxe", "achat"), 70, 200, "forge"), Outil("diamond_pickaxe", itemBourse("diamond_pickaxe", "vente"), itemBourse("diamond_pickaxe", "achat"), 150, 450, "forge"), Outil("shovel", itemBourse("shovel", "vente"), itemBourse("shovel", "achat"), 10, 35, ""), Outil("iron_shovel", itemBourse("iron_shovel", "vente"), itemBourse("iron_shovel", "achat"), 60, 100, "forge"), Outil("diamond_shovel", itemBourse("diamond_shovel", "vente"), itemBourse("diamond_shovel", "achat"), 120, 240, "forge"), Outil("planting_plan", itemBourse("planting_plan", "vente"), itemBourse("planting_plan", "achat"), 4, 4, "consommable"), Outil("barrel", itemBourse("barrel", "vente"), itemBourse("barrel", "achat"), 3, 3, "consommable"), Outil("furnace", itemBourse("furnace", "vente"), itemBourse("furnace", "achat"), 2, 2, "consommable"), Outil("bank_upgrade", itemBourse("bank_upgrade", "vente"), itemBourse("bank_upgrade", "achat"), 10000, None, "bank") ] # ========== Loot Box ========== global objetBox objetBox = [ Box("commongems", "Gems Common", 30, 10, 50, "gems", 1), Box("raregems", "Gems Rare", 300, 100, 500, "gems", 2), Box("legendarygems", "Gems Legendary", 3000, 1000, 5000, "gems", 4), Box("gift", "Items en folie", 50000, 100, 100000, "gems", 3), Box("gift_heart", "Cadeau de la Saint Valentin", 0, 10000, 50000, "", 2) ] if sql.spam(PlayerID_GetGems, couldown_8h, "bourse", "gems"): sql.updateComTime(PlayerID_GetGems, "bourse", "gems") for x in objetItem: GS.csv_add(x.nom) for x in objetOutil: GS.csv_add(x.nom) ActuBourse()
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 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 all(): with SQLite() as db: rows = db.execute('SELECT * FROM locations').fetchall() return [Locations(*row) for row in rows]
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 drop(): with SQLite() as db: db.execute("DELETE FROM locations")
def itemBourse(item, type): """Version 3.0 | Attribue les prix de la bourse """ # récupération du fichier de sauvegarde de la bourse with open('gems/bourse.json', 'r') as fp: dict = json.load(fp) temp = dict[item] # Récuperation de la valeur courante if type == "vente": pnow = temp["vente"] elif type == "achat": pnow = temp["achat"] PrixMini = 2 # Verification pour l'actualisation de la bourse if sql.spam(PlayerID_GetGems, couldown_8h, "bourse", "gems"): # Gestion des exceptions if item in GI.exception: return pnow if item in ObjetEventEnd: return pnow # Récuperation prix d'origine | prix mini | prix maxi taux = 0.9 for c in GI.PrixItem: if c.nom == item: if type == "vente": pdef = c.vente pmini = c.vente - (c.vente * taux) pmaxi = c.vente + (c.vente * taux) elif type == "achat": pdef = c.achat pmini = c.achat - (c.achat * taux) pmaxi = c.achat + (c.achat * taux) for c in GI.PrixOutil: if c.nom == item: if type == "vente": pdef = c.vente pmini = c.vente - (c.vente * taux) pmaxi = c.vente + (c.vente * taux) elif type == "achat": pdef = c.achat pmini = c.achat - (c.achat * taux) pmaxi = c.achat + (c.achat * taux) pdef = int(pdef) if pmini <= PrixMini: pmini = PrixMini else: pmini = int(pmini) pmaxi = int(pmaxi) # print("============================================\n=== {0} >>> {1}".format(type, item)) # print("Prix défaut: {0}\nPrix mini: {1}\nPrix maxi: {2}".format(pdef, pmini, pmaxi)) # Fonctionnement de la bourse DcrackB = r.randint(1, 1000) # crack boursier négatif if DcrackB <= 5: taux = 0.85 Prix = int(pnow - (pnow * taux)) # crack boursier positif elif DcrackB >= 985 or (pnow < 4 and DcrackB >= 900): if pnow <= 50: taux = 10 elif pnow <= 7: taux = 50 else: taux = 5 Prix = int(pnow + (pnow * taux)) # évolution de la bourse normale (entre -10% et +10% de la valeur courante) else: if pnow > pmaxi: pourcentage = r.randint(-20, -5) elif pnow <= pmini: pourcentage = r.randint(15, 30) elif (pnow > (pmaxi - pdef * 0.3)) or (pnow < (pmini + pdef * 0.3)): pourcentage = r.randint(-20, 20) else: if pnow > 10: pourcentage = r.randint(-10, 10) else: pourcentage = r.randint(-5, 20) Prix = int(pnow + ((pnow * pourcentage) // 100)) if Prix < PrixMini: Prix = PrixMini # print("\nAncien prix: {1}\nNouveau prix: {0}\n".format(Prix, pnow)) # La valeur de vente ne peux etre supérieur à la valeur d'achat if type == "vente": if Prix > temp["achat"]: Prix = temp["achat"] temp["vente"] = Prix temp["precVente"] = pnow # La valeur d'achat ne peux être inférieur à la valeur de vente elif type == "achat": if Prix < temp["vente"]: Prix = temp["vente"] temp["achat"] = Prix temp["precAchat"] = pnow # actualisation du fichier de sauvegarde de la bourse dict[item] = temp with open('gems/bourse.json', 'w') as fp: json.dump(dict, fp, indent=4) return Prix else: return pnow
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