def check(self): deck = Deck.getByKey(self.__player.id) if ApiTest.AUTO: if len(deck.to_array()) != Defines.DECK_CARD_NUM_MAX: raise AppTestError(u'デッキ設定されていない') else: # if deck.member1 == self.__deck.member1 or deck.member1 != self.__deck.member2: # raise AppTestError(u'デッキ設定されていない') if deck.member1 != self.__card.id: raise AppTestError(u'デッキ設定されていない')
def handle(self, *args, **options): print '================================' print 'aggregate_deckmember' print '================================' # 出力先. path = OSAUtil.get_now().strftime(args[0]) # 書き込むデータをここに溜め込む. writer = Command.Writer(path) # 対象を更新. LoginTimeCloneSet.update() # アクティブユーザだと判定される日数. now = OSAUtil.get_now() border_date = now - datetime.timedelta(days=Defines.ACTIVE_DAYS) LIMIT = 300 model_mgr = ModelRequestMgr() cardmasters = dict([(master.id, master) for master in model_mgr.get_mastermodel_all(CardMaster, fetch_deleted=True, using=backup_db)]) cardsortmasters = dict([(master.id, master) for master in model_mgr.get_mastermodel_all(CardSortMaster, fetch_deleted=True, using=backup_db)]) # ヘッダ列. title = [u'ユーザID'] for _ in xrange(Defines.DECK_CARD_NUM_MAX): title.extend([u'name', u'rare', u'hklevel', u'level', u'power']) for rare in Defines.Rarity.LIST: title.append(Defines.Rarity.NAMES[rare]) writer.add(','.join(title)) del title offset = 0 while True: uidlist = LoginTimeCloneSet.fetchByRange(border_date, now, LIMIT, offset) # デッキ取得. decklist = Deck.getByKey(uidlist, using=backup_db) for deck in decklist: row = [] raremap = {} # カード取得. cardidlist = deck.to_array() cards = dict([(card.id, card) for card in Card.getByKey(cardidlist, using=backup_db)]) # ユーザID. row.append(str(deck.id)) for cardid in cardidlist: card = cards.get(cardid) master = None sortmaster = None if card: master = cardmasters.get(card.mid) sortmaster = cardsortmasters.get(card.mid) if card is None or master is None or sortmaster is None: name = u'不明' rare = u'不明' hklevel = u'不明' level = u'不明' power = u'不明' else: # カード名. name = str(master.name) # レア度. rare = str(sortmaster.rare) # ハメ管理度. hklevel = str(sortmaster.hklevel) # レベル. level = str(card.level) # 接客力. power = str(CardUtil.calcPower(master.gtype, master.basepower, master.maxpower, card.level, master.maxlevel, card.takeover)) raremap[sortmaster.rare] = raremap.get(sortmaster.rare, 0) + 1 row.extend([name, rare, hklevel, level, power]) for _ in xrange(Defines.DECK_CARD_NUM_MAX - len(cardidlist)): row.extend(['', '', '', '', '']) for rare in Defines.Rarity.LIST: row.append(str(raremap.get(rare, 0))) line = ','.join(row) writer.add(line) offset += LIMIT if len(uidlist) < LIMIT: break writer.output(overwrite=False) print '================================' print 'all done..'