Advertisement
DoutorWhite

Sistema de compras Vector 10/10

Sep 29th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.41 KB | None | 0 0
  1. sync def cmd_comprar(self, author, user_mentions, channel, deck, x):
  2.       if x != "0":
  3.          if os.path.exists("data/DCK/" + deck + "/price.txt"):
  4.             if os.path.exists("data/dp/" + author.name + ".txt"):
  5.                    data = open("data/dp/" + author.name + ".txt", "r")
  6.                    dpr = data.read()
  7.                    data.close()
  8.                    data = open("data/DCK/" + deck + "/price.txt", "r")
  9.                    dkprecoraw = data.read()
  10.                    data.close()
  11.                    dkpreco = int(dkprecoraw)
  12.                    xi = int(x)
  13.                    type(xi)
  14.                    dp = int(dpr)
  15.                    type(dp)
  16.                    a = 0
  17.                    preco = 0
  18.                    while a < xi:
  19.                        preco = preco + dkpreco
  20.                        a = a + 1
  21.                    if(dp >= preco):
  22.                       dp = dp - preco
  23.                       dpr = str(dp)
  24.                       type(dpr)
  25.                       data = open("data/dp/" + author.name + ".txt", "w")
  26.                       data.write(dpr)
  27.                       data.close()
  28.                       data = open("data/dck/" + deck + "/cards.txt")
  29.                       cartas = data.readlines()
  30.                       data2 = open("data/dck/" + deck + "/limit.txt")
  31.                       rawlimit = data2.read()
  32.                       limit = int(rawlimit)
  33.                       limit2 = limit - 1
  34.                       data2.close()
  35.                      
  36.                       await self.send_message(author, "Foram comprados " + x + " decks " +
  37.                                               deck + " com sucesso!\n" +
  38.                                                    "você recebeu as seguintes cartas: ")
  39.                       xi2 = int(x)
  40.                       for i in range(0, xi2):
  41.                         if i == 0:
  42.                             await self.send_message(author, "--------------------------------------------")
  43.                         if i > 0:
  44.                             await self.send_message(author, "---")
  45.                         i = i + 1
  46.                         for i2 in range(0, 5):
  47.                            ran = randint(0, limit2)
  48.                            await self.send_message(author, cartas[ran])
  49.                            
  50.                       await self.send_message(author, "-------------------------------------------------")
  51.                       await self.send_message(author, "Obrigado pela compra " + author.name + "! Volte sempre ^^")
  52.                       await self.send_message(author, "-------------------------------------------------")
  53.                          
  54.                       data.close()
  55.                       return Response("As cartas de " + author.name + " foram enviadas! :mailbox_with_mail:")
  56.                                                  
  57.                      
  58.                    else:
  59.                       await self.send_message(author, "Você não tem DP para comprar" + x + " decks de " + deck + "!")
  60.                       return Response("Não foi possivel enviar as cartas de " + author.name)
  61.             else:
  62.                       return Response("Você não tem um profile. De /cp para criar seu profile")
  63.                
  64.          else:
  65.            return Response("Esse deck não existe!")
  66.       else:
  67.           return Response("Não é possivel comprar menos de 1 deck, " + author.name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement