Exemple #1
0
 def get(self):
     user = users.get_current_user()
     if user:
         key = self.request.get("key")
         card = int(self.request.get("card"))
         draft = Draft.get(key)
         if draft.owner != user:
             self.redirect('/')
         packs, decks = draft_backend.draft_unpack(draft.packs, draft.decks,
                                                   draft.num_picked)
         packs, decks, draft.num_picked = draft_backend.draft_step(
             packs, decks, draft.num_picked, card)
         draft.packs, draft.decks = draft_backend.draft_repack(packs, decks)
         if draft.num_picked == 45:
             deck = Deck()
             deck.cards = []
             deck.sideboard = sorted(draft.decks[:45])
             deck.name = "Completed Booster Draft"
             deck.owner = user
             deck.put()
             draft.delete()
             self.redirect('/')
         else:
             draft.put()
             self.redirect('/draft?key=%s' % (key))
     else:
         url = users.create_login_url(self.request.uri)
         template_values = {'url': url}
         path = os.path.join(os.path.dirname(__file__), 'logged_out.html')
         self.response.out.write(template.render(path, template_values))
Exemple #2
0
 def get(self):
     user = users.get_current_user()
     if user:
         key = self.request.get("key")
         card = int(self.request.get("card"))
         draft = Draft.get(key)
         if draft.owner != user:
             self.redirect("/")
         packs, decks = draft_backend.draft_unpack(draft.packs, draft.decks, draft.num_picked)
         packs, decks, draft.num_picked = draft_backend.draft_step(packs, decks, draft.num_picked, card)
         draft.packs, draft.decks = draft_backend.draft_repack(packs, decks)
         if draft.num_picked == 45:
             deck = Deck()
             deck.cards = []
             deck.sideboard = sorted(draft.decks[:45])
             deck.name = "Completed Booster Draft"
             deck.owner = user
             deck.put()
             draft.delete()
             self.redirect("/")
         else:
             draft.put()
             self.redirect("/draft?key=%s" % (key))
     else:
         url = users.create_login_url(self.request.uri)
         template_values = {"url": url}
         path = os.path.join(os.path.dirname(__file__), "logged_out.html")
         self.response.out.write(template.render(path, template_values))
Exemple #3
0
 def get(self):
     user = users.get_current_user()
     key = self.request.get("key")
     draft = Draft.get(key)
     packs, decks = draft_backend.draft_unpack(draft.packs, draft.decks, draft.num_picked)
     if user and draft.owner == user:
         template_values = {"pack": packs[0], "deck": decks[0], "key": key}
         path = os.path.join(os.path.dirname(__file__), "draft_page.html")
         self.response.out.write(template.render(path, template_values))
     else:
         self.redirect("/")
Exemple #4
0
 def get(self):
     user = users.get_current_user()
     key = self.request.get("key")
     draft = Draft.get(key)
     packs, decks = draft_backend.draft_unpack(draft.packs, draft.decks,
                                               draft.num_picked)
     if user and draft.owner == user:
         template_values = {'pack': packs[0], 'deck': decks[0], 'key': key}
         path = os.path.join(os.path.dirname(__file__), 'draft_page.html')
         self.response.out.write(template.render(path, template_values))
     else:
         self.redirect('/')