def allin(self, ctx, multiplier: int):
"""It's all or nothing. Bets everything you have."""
# Declare variables for the game.
user = ctx.message.author
settings = super().check_server_settings(user.server)
chip_name = settings["System Config"]["Chip Name"]
if not super().membership_exists(user):
return await self.bot.say(_("You need to register. Type "
"{}casino join.").format(ctx.prefix))
# Run a logic check to determine if the user can play the game.
check = self.game_checks(settings, ctx.prefix, user, 0, "Allin", 1, [1])
if check:
msg = check
else: # Run the game when the checks return None.
# Setup the game to determine an outcome.
settings["Players"][user.id]["Played"]["Allin"] += 1
amount = int(round(multiplier * settings["Players"][user.id]["Chips"]))
balance = super().chip_balance(user)
outcome = random.randint(0, multiplier + 1)
super().withdraw_chips(user, balance)
await self.bot.say(_("You put all your chips into the machine and pull the lever..."))
await asyncio.sleep(3)
# Begin game logic to determine a win or loss.
if outcome == 0:
super().deposit_chips(user, amount)
msg = _("```Python\nJackpot!! You just won {} {} "
"chips!!```").format(amount, chip_name)
settings["Players"][user.id]["Won"]["Allin"] += 1
else:
msg = (_("Sorry! Your all or nothing gamble failed and you lost "
"all your {} chips.").format(chip_name))
# Save the results of the game
super().save_system()
# Send a message telling the user the outcome of this command
await self.bot.say(msg)
评论列表
文章目录