Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions Cogs/Xp.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,9 @@ async def gamble(self, ctx, bet = None):
channel = ctx.message.channel

# bet must be a multiple of 10, member must have enough xpreserve to bet
msg = 'Usage: `{}gamble [xp reserve bet] (must be multiple of 10)`'.format(ctx.prefix)
msg = 'Usage: `{}gamble [xp reserve bet/all] (must be multiple of 10)`'.format(ctx.prefix)


try:
bet = int(float(bet))
except:
return await ctx.send(msg)

isAdmin = Utils.is_admin(ctx)
checkAdmin = self.settings.getServerStat(ctx.guild, "AdminArray")
Expand All @@ -619,14 +616,25 @@ async def gamble(self, ctx, bet = None):
xpblock = self.settings.getServerStat(server, "XpBlockArray")

approve = True
decrement = True

decrement = True
betAll = False
roundDown = False
# Check Bet

if not bet % 10 == 0:
if type(bet) == str:
if bet.upper() == "all":
betAll = True
bet = reserveXP

try:
bet = int(float(bet))
except:
return await ctx.send(msg)
if not bet % 10 == 0 and not betAll:
approve = False
msg = 'Bets must be in multiples of *10!*'

elif not bet % 10 == 0 and betAll:
roundDown = True
bet = (bet // 10) * 10
if bet > int(reserveXP):
approve = False
msg = 'You can\'t bet *{:,}*, you only have *{:,}* xp reserve!'.format(bet, reserveXP)
Expand Down Expand Up @@ -709,11 +717,11 @@ async def gamble(self, ctx, bet = None):
if randnum == 1:
# YOU WON!!
self.settings.incrementStat(author, server, "XP", int(payout))
msg = '*{}* bet *{:,}* and ***WON*** *{:,} xp!*'.format(DisplayName.name(author), bet, int(payout))
msg = '*{}* bet *{:,}* and ***WON*** *{:,} xp!* **{}**'.format(DisplayName.name(author), bet, int(payout), f"Note that you betted all but it was not a multiple of 10, so you were rounded to the nearest 10. You did not lose the spare." if betAll and roundDown else "")
# Now we check for promotions
await CheckRoles.checkroles(author, channel, self.settings, self.bot)
else:
msg = '*{}* bet *{:,}* and.... *didn\'t* win. Better luck next time!'.format(DisplayName.name(author), bet)
msg = '*{}* bet *{:,}* and.... *didn\'t* win. Better luck next time! **{}**'.format(DisplayName.name(author), bet, f"Note that you betted all but it was not a multiple of 10, so you were rounded to the nearest 10. You did not lose the spare." if betAll and roundDown else "")

await ctx.send(msg)

Expand Down