def bal(self, ctx, *args): """Get your current balance and amount of packs.""" try: yield from ctx.message.channel.send( "You currently have $" + str(getBal(ctx.message.author.id)) + " and " + str(getPacks(ctx.message.author.id)) + " pack(s).") except: yield from ctx.message.channel.send( "You aren't registered. Use =register")
async def bal(self, ctx, *args): """Get your current balance and amount of packs.""" if not (await is_invoker_registered(ctx)): return await ctx.message.channel.send("You currently have $" + str(getBal(ctx.message.author.id)) + " and " + str(getPacks(ctx.message.author.id)) + " pack(s).")
async def buy(self, ctx, amt: int = 1): """Buy some packs! =buy <amount>""" # Just make sure they can if amt < 1: await ctx.message.channel.send("Invalid input.") return if getBal(ctx.message.author.id) < amt * config.PACK_PRICE: await ctx.message.channel.send("Not enough money for " + str(amt) + " packs. They are currently $" + str(config.PACK_PRICE) + " each.") return # Data stuff, then printing grantPacks(ctx.message.author.id, amt) grantMoney(ctx.message.author.id, -1 * amt * config.PACK_PRICE) if amt == 1: await ctx.message.channel.send( "Bought a pack! Open it with =openpack.") else: await ctx.message.channel.send( "Bought " + str(amt) + " packs!!!! Open them with =openpack!!!!!!!")
def challenge(ctx, target: discord.Member = None, *args): """Challenge a friend to discordTCG! =challenge <@user> <wager>""" challengerID = ctx.message.author.id #Make sure neither player is in a game currently if challengerID in config.matches or target.id in config.matches: yield from bot.say("A player is already in a match.") return #Dont challenge yourself man if ctx.message.author == target: yield from bot.say("You can't challenge yourself, silly!") return #Have challenged guy accept yield from bot.say( target.name + ", you've been challenged to a discordTCG match! Type 'accept' to accept." ) message = yield from bot.wait_for_message(author=target, content='accept', timeout=config.CHALLENGE_TIMEOUT) if message is None: yield from bot.say(ctx.message.author.name + ", your challenge was not accepted :(") return #check again here for duplicate accepts if challengerID in config.matches or target.id in config.matches: yield from bot.say("A player is already in a match.") return #Get player data challengerDeck = mechanics.getPlyData(ctx.message.author) defenderDeck = mechanics.getPlyData(target) if defenderDeck is None or challengerDeck is None: yield from bot.say("Both players aren't registered! Use =register.") return challengerDeck = challengerDeck['decks'][challengerDeck['selectedDeck']] defenderDeck = defenderDeck['decks'][defenderDeck['selectedDeck']] if len(challengerDeck) < config.DECK_SIZE_MINIMUM or len( defenderDeck) < config.DECK_SIZE_MINIMUM: yield from bot.say("A player doesn't have at least " + str(config.DECK_SIZE_MINIMUM) + " cards in his or her deck.") return #Wager stuff try: wager = int(args[0]) if mechanics.getBal(ctx.message.author.id) < wager or mechanics.getBal( target.id) < wager: yield from bot.say( "A player doesn't have enough money for this wager!") return yield from bot.say("Wager set to $" + args[0] + "!") except: wager = 0 #Initialize game #TODO: [challenger] -> [ctx.message.author.id] config.matches[challengerID] = gamebase.TCGame(challengerID, target.id, wager) config.matches[challengerID].chalObj = playerbase.Player( ctx.message.author.name, challengerDeck, [], bot, ctx) config.matches[challengerID].defObj = playerbase.Player( target.name, defenderDeck, [], bot, ctx) config.matches[challengerID].chalObj.shuffle() config.matches[challengerID].defObj.shuffle() for i in range(config.STARTING_HAND_SIZE): config.matches[challengerID].chalObj.drawCard() config.matches[challengerID].defObj.drawCard() config.matches[challengerID].chalObj.opponent = config.matches[ challengerID].defObj config.matches[challengerID].defObj.opponent = config.matches[ challengerID].chalObj print('A match has started. ' + str(ctx.message.author.name) + ' vs ' + str(target.name) + '!') #Start round if random.randint(0, 1) == 0: config.matches[challengerID].chalObj.active = True config.matches[challengerID].defObj.energy += 1 yield from startRound(config.matches[challengerID], ctx.message.author, config.matches[challengerID].chalObj, target, config.matches[challengerID].defObj, ctx) else: config.matches[challengerID].defObj.active = True config.matches[challengerID].chalObj.energy += 1 yield from startRound(config.matches[challengerID], target, config.matches[challengerID].defObj, ctx.message.author, config.matches[challengerID].chalObj, ctx)