async def qp(self, ctx, number_of_tickets=1): """ Quickpick tickets, enter a number to choose how many you want! """ lottory_id = db.get_current_lottory() user_balance = db.get_user_balance(ctx.author.id) total_cost = ticket_cost * number_of_tickets if user_balance < total_cost: await ctx.send("That would cost {:,}, your balance is {:,}. Broke ass bitch".format(total_cost, user_balance)) return else: async with ctx.typing(): ticket_list = quickpick(number_of_tickets) progressive_add = number_of_tickets * ticket_cost * .1 db.add_ticket_to_user(ticket_list, lottory_id, ctx.author.id) new_balance = db.modify_user_balance(ctx.author.id, -1 * total_cost) db.modify_lottory_jackpot_prog(lottory_id, progressive_add) new_progressive = db.get_lottory_jackpot_prog(lottory_id) ticket_obj_list = list(map(lambda x: Ticket(x), ticket_list)) #Convert list of tickets to Ticket objects if len(ticket_list) <= 5: output_line_list = [] for ticket in ticket_list: output_line_list.append('Quickpick ticket {} purchased by {}, good luck!'.format(Ticket(ticket), ctx.author.name)) await ctx.send("\n".join(output_line_list)) if number_of_tickets > 500: await ctx.author.send("You bought {} tickets. I'm not going to send you all of them.".format(number_of_tickets)) else: for n in range(0, len(ticket_list), 50): await ctx.author.send("Lottory {} Quickpick tickets {}".format(lottory_id, ticket_list[n:n+50])) await ctx.send("{} spent {:,} on {:,} tickets, new balance is {:,}. The jackpot is now {:,}".format(ctx.author.name, total_cost, number_of_tickets, round(new_balance,2), payout_table[True][4]+new_progressive))
async def buy_ticket(self, ctx, first: int, second: int, third: int, fourth: int, mega: int): """ Purchase a lottory ticket, enter all 5 numbers seperated by spaces. Valid tickets must have first 4 numbes between 1-23, and last number between 1-11. Use !bt qp <number> to purchase a number of quickpick tickets. Good luck! """ lottory_id = db.get_current_lottory() user_balance = db.get_user_balance(ctx.author.id) ticket = [first, second, third, fourth, mega] ticket_print = Ticket(ticket) if user_balance < ticket_cost: await ctx.send( "That would cost {:,}, your balance is {:,}. Broke ass bitch". format(ticket_cost, user_balance)) return #Validate ticket entry for number in ticket[:4]: if number not in numbers: await ctx.send( "{} is not a valid ticket, first 4 numbers must be between {}-{}}" .format(ticket, numbers[0], numbers[-1])) return if ticket[4] not in range(1, 12): await ctx.send( "{} is not a valid ticket, megaball must be between 1-11". format(ticket)) return for i in range(3): if ticket[i] in ticket[:i]: await ctx.send( "{} is not a valid ticket, first four numbers must be unique" .format(ticket_print)) return if ticket[i] in ticket[i + 1:4]: await ctx.send( "{} is not a valid ticket, first four numbers must be unique" .format(ticket_print)) return progressive_add = ticket_cost * .1 db.add_ticket_to_user([ticket], lottory_id, ctx.author.id) new_balance = db.modify_user_balance(ctx.author.id, -1 * ticket_cost) db.modify_lottory_jackpot_prog(lottory_id, progressive_add) new_progressive = db.get_lottory_jackpot_prog( lottory_id) + payout_table[True][4] await ctx.send( "{} purchased ticket {}, your balance is now {:,}. The progressive jackpot is now {:,}." .format(ctx.author.name, Ticket(ticket), new_balance, new_progressive))