summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/basic_games.py142
1 files changed, 96 insertions, 46 deletions
diff --git a/commands/basic_games.py b/commands/basic_games.py
index bad02c6..66524cd 100644
--- a/commands/basic_games.py
+++ b/commands/basic_games.py
@@ -1,5 +1,6 @@
from discord.ext.commands import Bot, Cog
from discord_slash import cog_ext, SlashContext
+from discord import Embed
from discord_slash.utils.manage_commands import create_option, create_choice
from base import config
from models.user import User
@@ -44,16 +45,34 @@ class BasicGames(Cog):
await ctx.send(
content=f"{user.username} is betting {num_coins} {config['currency']} on {choice}"
)
- choices = ["Heads", "Tails"]
- result = random.choice(choices)
- await ctx.send(content=f"Coin flip lands on {result}")
- if choice == result:
- await ctx.send(content=f"You win {num_coins * 2} {config['currency']}!")
- user.add_coins(num_coins * 2)
- else:
- await ctx.send(content=f"You lose {num_coins} {config['currency']} :(")
+ result = random.randint(0, 200)
+ if result <= 110:
+ if choice == "Heads":
+ await ctx.send(content="Coin flip lands on Tails")
+ else:
+ await ctx.send(content="Coin flip lands on Heads")
+
+ embed = Embed(description=f"{ctx.author.mention} loses!", colour=0xFF0000)
+ embed.add_field(name="Lost:", value=f"{num_coins} {config['currency']}")
user.remove_coins(num_coins)
+ elif result > 110 and result < 199:
+ if choice == "Heads":
+ await ctx.send(content="Coin flip lands on Heads")
+ else:
+ await ctx.send(content="Coin flip lands on Tails")
+ embed = Embed(description=f"{ctx.author.mention} wins!", colour=0x00FF00)
+ embed.add_field(name="Prize:", value=f"{num_coins} {config['currency']}")
+ user.add_coins(num_coins)
+ elif result >= 199:
+ winnings = num_coins * 2
+ embed = Embed(
+ description=f"The coin lands on it's side!{ctx.author.mention} wins double!",
+ colour=0x00FF00,
+ )
+ embed.add_field(name="Prize:", value=f"{winnings} {config['currency']}")
+ user.add_coins(winnings)
+ await ctx.send(embed=embed)
user.save()
@cog_ext.cog_slash(
@@ -88,27 +107,41 @@ class BasicGames(Cog):
user_total = results[0] + results[1]
bot_total = results[2] + results[3]
if user_total == 12:
- winnings = num_coins * 2
- await ctx.channel.send(content=f"Double 6! You win {winnings} {config['currency']}!")
+ winnings = num_coins * 3
+
+ embed = Embed(
+ description=f"{ctx.author.mention} rolls a double 6!!! You win!", colour=0x00FF00
+ )
+ embed.add_field(name="Prize:", value=f"{winnings} {config['currency']}")
user.add_coins(winnings)
elif results[0] == results[1]:
winnings = num_coins * 2
- await ctx.channel.send(
- content=f"You roll a double! You win {winnings} {config['currency']}!"
+ embed = Embed(
+ description=f"{ctx.author.mention} rolls a double!! You win!", colour=0x00FF00
)
+ embed.add_field(name="Prize:", value=f"{winnings} {config['currency']}")
user.add_coins(winnings)
else:
await ctx.channel.send(
content=f"{user.display_name}, I rolled a {results[2]} and a {results[3]}"
)
if user_total > bot_total:
- await ctx.channel.send(content=f"You win {num_coins} {config['currency']}!")
+ embed = Embed(description=f"{ctx.author.mention} wins!", colour=0x00FF00)
+ embed.add_field(name="Prize:", value=f"{num_coins} {config['currency']}")
user.add_coins(num_coins)
elif user_total == bot_total:
- await ctx.channel.send(content="It's a draw! Have your money back...")
+ embed = Embed(
+ description=f"{ctx.author.mention}, it's a draw. Have your money back...",
+ colour=0xFFFF00,
+ )
else:
- await ctx.channel.send(content=f"You lose {num_coins} {config['currency']} :(")
+ embed = Embed(
+ description=f"{ctx.author.mention} loses the dice roll :(",
+ colour=0xFF0000,
+ )
+ embed.add_field(name="Lost:", value=f"{num_coins} {config['currency']}")
user.remove_coins(num_coins)
+ await ctx.channel.send(embed=embed)
user.save()
@cog_ext.cog_slash(
@@ -118,7 +151,7 @@ class BasicGames(Cog):
)
async def slots(self, ctx: SlashContext):
user = User.get(User.discord_id == ctx.author_id)
- cost = 100
+ cost = 10
if user.currency < cost:
await ctx.send(
content=f"{user.display_name}, you don't have enough {config['currency']}, it costs 100 {config['currency']} to play"
@@ -130,67 +163,84 @@ class BasicGames(Cog):
)
user.remove_coins(cost)
+ slots = config["slots"]
+
+ e = []
+ for slot in slots:
+ for i in range(slot["rarity"]):
+ e.append(slot)
+ total = len(e) - 1
results = [
- random.randint(0, 5),
- random.randint(0, 5),
- random.randint(0, 5),
+ e[random.randint(0, total)],
+ e[random.randint(0, total)],
+ e[random.randint(0, total)],
]
results_top = [
- random.randint(0, 5),
- random.randint(0, 5),
- random.randint(0, 5),
+ e[random.randint(0, total)],
+ e[random.randint(0, total)],
+ e[random.randint(0, total)],
]
results_bottom = [
- random.randint(0, 5),
- random.randint(0, 5),
- random.randint(0, 5),
+ e[random.randint(0, total)],
+ e[random.randint(0, total)],
+ e[random.randint(0, total)],
]
result_text = ""
- e = list(config["slots"].values())
+ # e = list(config["slots"].values())
winnings = 0
for r in results_top:
- result_text += e[r]["dark"]
+ result_text += r["dark"]
result_text += "\n"
for r in results:
- result_text += e[r]["emoji"]
- winnings += e[r]["reward_single"]
+ result_text += r["emoji"]
+ result_text += "\n"
+
+ for r in results_bottom:
+ result_text += r["dark"]
result_text += "\n"
double = False
triple = False
- if results[0] == results[1] or results[0] == results[2]:
+
+ if results[0]["name"] == results[1]["name"] and results[0]["name"] == results[2]["name"]:
+ triple = True
+ winnings += results[0]["reward_triple"]
+ elif results[0]["name"] == results[1]["name"] or results[0]["name"] == results[2]["name"]:
double = True
- winnings += e[results[0]]["reward_double"]
- elif results[1] == results[2]:
+ winnings += results[0]["reward_double"]
+ elif results[1]["name"] == results[2]["name"]:
double = True
- winnings += e[results[1]]["reward_double"]
- elif results[0] == results[1] and results[0] == results[2]:
- triple = True
- winnings += e[results[0]]["reward_triple"]
-
- for r in results_bottom:
- result_text += e[r]["dark"]
- result_text += "\n"
+ winnings += results[1]["reward_double"]
+ else:
+ for r in results:
+ winnings += r["reward_single"]
await ctx.channel.send(content=result_text)
if winnings == 0:
- await ctx.channel.send(content=f"No match :( You lose {cost} {config['currency']}")
- user.remove_coins(cost)
+ embed = Embed(description=f"No match :( {ctx.author.mention} loses...", colour=0xFF0000)
+ embed.add_field(name="Lost:", value=f"{cost} {config['currency']}")
else:
if triple:
- await ctx.channel.send(content=f"JACKPOT! You win {winnings} {config['currency']}")
+ embed = Embed(
+ description=f"JACKPOT! {ctx.author.mention} wins with a triple!!!",
+ colour=0x00FF00,
+ )
elif double:
- await ctx.channel.send(
- content=f"Ding ding! You win {winnings} {config['currency']}"
+ embed = Embed(
+ description=f"Ding ding! {ctx.author.mention} wins with a double!!",
+ colour=0x00FF00,
)
else:
- await ctx.channel.send(content=f"You win {winnings} {config['currency']}")
+ embed = Embed(description=f"{ctx.author.mention} wins!", colour=0x00FF00)
+
+ embed.add_field(name="Prize:", value=f"{winnings} {config['currency']}")
user.add_coins(winnings)
+ await ctx.channel.send(embed=embed)
user.save()