Skip to content

Instantly share code, notes, and snippets.

@FOCI-DEV
Created December 9, 2017 07:45
Show Gist options
  • Save FOCI-DEV/313b654c9b794366eb39d6a5f1a5f531 to your computer and use it in GitHub Desktop.
Save FOCI-DEV/313b654c9b794366eb39d6a5f1a5f531 to your computer and use it in GitHub Desktop.
import discord
import re
class Gambler:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def SetValue(self, ctx):
sampleSize = 10
BetSize = 1
BetCount = 1
#Set your balance according to the >mekos command output
startingFunds = re.sub("[^0-9]", "", ctx.send(message.channel, '>mekos'))
@commands.command(pass_context=True)
async def BetResult(self, ctx)
#If Miki says you lost
if embed.content.startswith('You\'ve lost'):
return False #Say you lost
elif embed.content.startswith('You\'ve won'):
return True #Say you won
@commands.command(pass_context=True)
async def MakeBet(self, ctx, funds, InitialBet, BetCount, multiple):
#If the embed was for you
if embed.title.contains(nickname):
value = funds
Bet = InitialBet
CurrentBet = 1
previousBet = 'win'
PreviousBetAmount = InitialBet
while CurrentBet <= BetCount:
# If you win the bet, don't change bet amount
if previousBet == 'win':
if BetResult():
value += Bet
else:
value -= Bet
previousBet = 'loss'
PreviousBetAmount = Bet
if value <= 0:
break
# If you lose the bet, use the bet multiplier
elif previousBet == 'loss':
if BetResult():
Bet = PreviousBetAmount * multiple
if (value - Bet) <= 0:
Bet = value
value += Bet
Bet = InitialBet
previousBet = 'win'
else:
Bet = PreviousBetAmount * multiple
if (value - Bet) <= 0:
Bet = value
value -= Bet
previousBet = 'loss'
PreviousBetAmount = Bet
if value <= 0:
break
try ctx.send(message.channel, '>flip '.Bet.'h')
#Continue betting
counter = 1
while counter <= multipleSampSize:
MakeBet(self, ctx, BetSize, BetCount, 1.75)
counter += 1
multipleSampSize = 100
counter = 1
def setup(bot):
bot.add_cog(Gambler(bot))
import discord
import re
class Gambler:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def SetValue(self, ctx):
sampleSize = 10
BetSize = 1
BetCount = 1
#Set your balance according to the >mekos command output
startingFunds = re.sub("[^0-9]", "", ctx.send(message.channel, '>mekos'))
@commands.command(pass_context=True)
async def BetResult(self, ctx)
#If Miki says you lost
if embed.content.startswith('You\'ve lost'):
return False #Say you lost
elif embed.content.startswith('You\'ve won'):
return True #Say you won
@commands.command(pass_context=True)
async def MakeBet(self, ctx, funds, InitialBet, BetCount, multiple):
#If the embed was for you
if embed.title.contains(nickname):
value = funds
Bet = InitialBet
CurrentBet = 1
previousBet = 'win'
PreviousBetAmount = InitialBet
while CurrentBet <= BetCount:
# If you win the bet, don't change bet amount
if previousBet == 'win':
if BetResult():
value += Bet
else:
value -= Bet
previousBet = 'loss'
PreviousBetAmount = Bet
if value <= 0:
break
# If you lose the bet, use the bet multiplier
elif previousBet == 'loss':
if BetResult():
Bet = PreviousBetAmount * multiple
if (value - Bet) <= 0:
Bet = value
value += Bet
Bet = InitialBet
previousBet = 'win'
else:
Bet = PreviousBetAmount * multiple
if (value - Bet) <= 0:
Bet = value
value -= Bet
previousBet = 'loss'
PreviousBetAmount = Bet
if value <= 0:
break
try ctx.send(message.channel, '>flip '.Bet.'h')
#Continue betting
counter = 1
while counter <= multipleSampSize:
MakeBet(self, ctx, BetSize, BetCount, 1.75)
counter += 1
multipleSampSize = 100
counter = 1
def setup(bot):
bot.add_cog(Gambler(bot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment