def start_draft(self, draft): draft.in_setup = False draft.in_progress = True #shuffle user_keys to create random order random.shuffle(draft.user_keys) #create the individual drafter items position = 0 drafter_entities = [] for user_key in draft.user_keys: drafter_entities.append(Drafter.create(user_key=user_key, draft_key=draft.key, position=position)) position += 1 draft.drafter_keys = ndb.put_multi(drafter_entities) # logging.error('424: draft') # logging.error(draft) pack_entities = [] #get boosters for all the packs for pack_code in draft.pack_codes: packs = SetUtil().generate_boosters( num=draft.num_drafters, set_code=pack_code) random.shuffle(packs) for pack in packs: pack_entities.append(Pack.create(draft_key=draft.key, cards=pack)) draft.unopened_pack_keys = ndb.put_multi(pack_entities) draft.put() # time.sleep(5) # logging.error('440: draft') # logging.error(draft) self.next_pack(draft)
def start_draft(self, draft): draft.in_setup = False draft.in_progress = True #shuffle user_keys to create random order random.shuffle(draft.user_keys) #create the individual drafter items position = 0 drafter_entities = [] for user_key in draft.user_keys: drafter_entities.append( Drafter.create(user_key=user_key, draft_key=draft.key, position=position)) position += 1 draft.drafter_keys = ndb.put_multi(drafter_entities) # logging.error('424: draft') # logging.error(draft) pack_entities = [] #get boosters for all the packs for pack_code in draft.pack_codes: packs = SetUtil().generate_boosters(num=draft.num_drafters, set_code=pack_code) random.shuffle(packs) for pack in packs: pack_entities.append( Pack.create(draft_key=draft.key, cards=pack)) draft.unopened_pack_keys = ndb.put_multi(pack_entities) draft.put() # time.sleep(5) # logging.error('440: draft') # logging.error(draft) self.next_pack(draft)
def lookup_drafter(self, user_key, draft_key): drafters_found = Drafter.query(Drafter.user_key == user_key, Drafter.draft_key == draft_key).fetch(1) if len(drafters_found) > 0: return drafters_found[0]