Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sync def cmd_comprar(self, author, user_mentions, channel, deck, x):
- if x != "0":
- if os.path.exists("data/DCK/" + deck + "/price.txt"):
- if os.path.exists("data/dp/" + author.name + ".txt"):
- data = open("data/dp/" + author.name + ".txt", "r")
- dpr = data.read()
- data.close()
- data = open("data/DCK/" + deck + "/price.txt", "r")
- dkprecoraw = data.read()
- data.close()
- dkpreco = int(dkprecoraw)
- xi = int(x)
- type(xi)
- dp = int(dpr)
- type(dp)
- a = 0
- preco = 0
- while a < xi:
- preco = preco + dkpreco
- a = a + 1
- if(dp >= preco):
- dp = dp - preco
- dpr = str(dp)
- type(dpr)
- data = open("data/dp/" + author.name + ".txt", "w")
- data.write(dpr)
- data.close()
- data = open("data/dck/" + deck + "/cards.txt")
- cartas = data.readlines()
- data2 = open("data/dck/" + deck + "/limit.txt")
- rawlimit = data2.read()
- limit = int(rawlimit)
- limit2 = limit - 1
- data2.close()
- await self.send_message(author, "Foram comprados " + x + " decks " +
- deck + " com sucesso!\n" +
- "você recebeu as seguintes cartas: ")
- xi2 = int(x)
- for i in range(0, xi2):
- if i == 0:
- await self.send_message(author, "--------------------------------------------")
- if i > 0:
- await self.send_message(author, "---")
- i = i + 1
- for i2 in range(0, 5):
- ran = randint(0, limit2)
- await self.send_message(author, cartas[ran])
- await self.send_message(author, "-------------------------------------------------")
- await self.send_message(author, "Obrigado pela compra " + author.name + "! Volte sempre ^^")
- await self.send_message(author, "-------------------------------------------------")
- data.close()
- return Response("As cartas de " + author.name + " foram enviadas! :mailbox_with_mail:")
- else:
- await self.send_message(author, "Você não tem DP para comprar" + x + " decks de " + deck + "!")
- return Response("Não foi possivel enviar as cartas de " + author.name)
- else:
- return Response("Você não tem um profile. De /cp para criar seu profile")
- else:
- return Response("Esse deck não existe!")
- else:
- return Response("Não é possivel comprar menos de 1 deck, " + author.name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement