def playGame(bot, trigger): global gameMode global fartList global shartList global chosen_scenario chosen_scenario = random.choice(scenarios) chosen_outcome = chosen_scenario.chooseOutcome() sayScenario = str(chosen_scenario.giveScenario()) bot.say(sayScenario) bot.say('Press 1 for Fart. Press 2 for Shart.') time.sleep(10) fartlist = str(', '.join(fartList)) shartlist = str(', '.join(shartList)) bot.say(chosen_outcome) if chosen_scenario.outcome == chosen_scenario.fart: bot.say('Winners: %s ' %(fartlist)) for winner in fartList: gravecoin.credit_user(winner,chosen_scenario.amount) for loser in shartList: gravecoin.debit_user(loser,chosen_scenario.amount) if chosen_scenario.outcome == chosen_scenario.shart: bot.say('Winners: %s ' %(shartlist)) for winner in shartList: gravecoin.credit_user(winner,chosen_scenario.amount) for loser in fartList: gravecoin.debit_user(loser,chosen_scenario.amount) time.sleep(1) gameMode = 0 fartList = [] shartList = []
def gamble(bot, trigger): name = trigger.nick if not trigger.group(3): bot.say('Specify how much you\'d like to wager') return # bot.say(trigger.group(2))#EVERYTHING # bot.say(trigger.group(3))#FIRST WORD (NAME) # bot.say(trigger.group(4))#SECOND WORD (MONEY) amount = int(trigger.group(3)) balance = int(gravecoin.check_balance(name)) if amount > balance: bot.say("You only have %s to spend." %(balance)) return gravecoin.debit_user(name,amount) first_item = random.choice(items) second_item = random.choice(items) third_item = random.choice(items) chosen_items = [first_item,second_item,third_item] bot.say('| %s | %s | %s |' % (first_item, second_item, third_item)) if sorted(trifecta) == sorted(chosen_items): winnings = (amount * 2) bot.say('You got the Trifecta! You win %s!' % (winnings)) winnings = winnings + amount gravecoin.credit_user(name,winnings) elif sorted(cockandballs) == sorted(chosen_items): winnings = (amount * 3) bot.say('You got the C**k And Balls! You win %s!' % (winnings)) winnings = winnings + amount gravecoin.credit_user(name,winnings) elif sorted(santorum) == sorted(chosen_items): winnings = (amount * 2) bot.say('You got a Santorum! You win %s!' % (winnings)) winnings = winnings + amount gravecoin.credit_user(name,winnings) elif sorted(snakeEyes) == sorted(chosen_items): winnings = (amount * 3) bot.say('You got Snake Eyes! You win %s!' % (winnings)) winnings = winnings + amount gravecoin.credit_user(name,winnings) elif first_item == second_item == third_item: winnings = (amount * 4) bot.say('You got three matches! You win %s!' % (winnings)) winnings = winnings + amount gravecoin.credit_user(name,winnings) elif first_item == second_item or second_item == third_item or first_item == third_item: winnings = amount * 2 bot.say('You got two matches! You win %s!' % (winnings)) gravecoin.credit_user(name,winnings) else: bot.say('You lose.')
def buy(bot, trigger): name = trigger.nick try: shares = int(trigger.group(3)) ticker = str(trigger.group(4).upper()) except: try: shares = int(trigger.group(4)) ticker = str(trigger.group(3).upper()) except: bot.say('Enter which stock you\'d like to buy, and how many shares.') return if shares < 0: bot.say('Enter a valid amount of stocks') return if ticker not in stocks: bot.say('%s is not a valid stock.' % (ticker)) return market = StockMarket() market.open_db(file_Name) price = market.get_balance(ticker) if price < 1: bot.say('Stock has crashed. Please wait until it is restored') return price_total = market.get_balance(ticker) * shares their_balance = gravecoin.check_balance(name) if int(price_total) > int(their_balance): max_shares = (int(their_balance) / int(price)) bot.say('The price for %s shares of %s is ɷ %s. You only have ɷ %s. At most you can buy %s shares' % (shares,ticker,price_total,their_balance,max_shares)) return bot.say('Buying %s shares of %s for ɷ %s ' %(shares,ticker,price_total)) trade = StockTrade() try: trade.open_db(saved_stocks) trade.buy_stocks(name,ticker,shares,price) gravecoin.debit_user(name,price_total) except: bot.say('Something broken, you have probably not been charged. Probably')