Machine à sous

This commit is contained in:
attilavs2 2025-05-06 22:48:21 +02:00
parent 32d0433b5c
commit dd861daddd

View file

@ -157,6 +157,44 @@ async def collect(message):
else: else:
await message.channel.send(init_perso_str) await message.channel.send(init_perso_str)
async def slot(message):
amnt = message.content.split(' ')[1]
try:
amnt = int(amnt)
except:
await message.channel.send("Quantité invalide")
return
gid = int(message.guild.id)
uid = int(message.author.id)
ret = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={uid}").fetchone()
if ret == None:
await message.channel.send(init_perso_str)
return
cash = ret[0]
if amnt > cash:
await message.channel.send("Vous n'avez pas assez d'argent")
return
roll = random.random()
gain = 0
print("Roll :",roll)
if roll < 1/6:
await message.channel.send(f"<@{uid}> a perdu toute sa mise")
if roll >= 1/6 and roll < 3/6:
gain = int(amnt*0.35*random.random())
await message.channel.send(f"<@{uid}> n'a remporté que {gain}$")
if roll >= 3/6 and roll < 5/6:
gain = int(amnt*1.1*random.random())
await message.channel.send(f"<@{uid}> a réussi à remporter {gain}$")
if roll >= 5/6 and roll < 19/20:
gain = int(amnt*0.4 + amnt*1.2*random.random())
await message.channel.send(f"<@{uid}> a extrait {gain}$ des griffes de la machine")
if roll >= 19/20:
gain = int(amnt*4 + amnt*16*random.random())
await message.channel.send(f"## <@{uid}> JACKPOT ! Vous avez gagné {gain}$ !")
cash -= amnt-gain
cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={uid}")
database.commit()
async def leaderboard(message): async def leaderboard(message):
uid = int(message.author.id) uid = int(message.author.id)
gid = int(message.guild.id) gid = int(message.guild.id)
@ -176,8 +214,9 @@ async def ecoaide(message):
await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\ await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\
"?pinguncon : Ping le con local\n"\ "?pinguncon : Ping le con local\n"\
"?pingunjuif : Ping le juif local\n"\ "?pingunjuif : Ping le juif local\n"\
"?pingrand : Ping un membre aléatoire du serveur\n" "?pingrand : Ping un membre aléatoire du serveur\n"\
"?roulette : Prennez une chance sur six de vous faire timeout") "?roulette : Jouez à la roulette russe\n"\
"?reload : Réinitialisez la roulette russe\n")
async def ecohelp(message): async def ecohelp(message):
await message.channel.send("Eco+ help page \n"\ await message.channel.send("Eco+ help page \n"\
@ -267,6 +306,7 @@ cmd_dict = {\
"?collect":collect,\ "?collect":collect,\
"?lb":leaderboard,\ "?lb":leaderboard,\
"?reload":reload,\ "?reload":reload,\
"?slot":slot,\
} }
@client.event @client.event
@ -274,7 +314,7 @@ async def on_message(message):
if message.author == client.user: if message.author == client.user:
return return
content = message.content content = message.content.split(" ")[0]
if not content: if not content:
return return