示例#1
0
 def check(self):
     item = Item.getByKey(Item.makeID(self.__player.id, self.__itemmaster.id))
     if item is None:
         raise AppTestError(u'アイテムデータがない')
     elif item.vnum != 0:
         raise AppTestError(u'無料分の所持数がおかしい')
     elif item.rnum != self.__item.rnum:
         raise AppTestError(u'課金分の所持数がおかしい')
     
     playerdeck = PlayerDeck.getByKey(self.__player.id)
     if playerdeck.cardlimititem != (self.__itemmaster.evalue * self.__usenum):
         raise AppTestError(u'BOXが拡張していない')
示例#2
0
 def check(self):
     item = Item.getByKey(Item.makeID(self.__player.id, self.__itemmaster.id))
     if item is None:
         raise AppTestError(u'アイテムデータがない')
     elif item.vnum != 0:
         raise AppTestError(u'無料分の所持数がおかしい')
     elif item.rnum != self.__item.rnum:
         raise AppTestError(u'課金分の所持数がおかしい')
     
     player = PlayerGachaPt.getByKey(self.__player.id)
     if player.gachapt != (self.__player.gachapt + self.__itemmaster.evalue * self.__usenum):
         raise AppTestError(u'引抜Ptが増えていない')
示例#3
0
    def check(self):
        item = Item.getByKey(
            Item.makeID(self.__player.id, self.__itemmaster.id))
        if item is None:
            raise AppTestError(u'アイテムデータがない')
        elif item.vnum != 0:
            raise AppTestError(u'無料分の所持数がおかしい')
        elif item.rnum != self.__item.rnum:
            raise AppTestError(u'課金分の所持数がおかしい')

        playerap = PlayerAp.getByKey(self.__player.id)
        if playerap.ap != (self.__itemmaster.evalue * self.__usenum):
            raise AppTestError(u'体力が回復していない')
示例#4
0
 def check(self):
     item = Item.getByKey(Item.makeID(self.__player.id, self.__itemmaster.id))
     if item is None:
         raise AppTestError(u'アイテムデータがない')
     elif item.vnum != 0:
         raise AppTestError(u'無料分の所持数がおかしい')
     elif item.rnum != self.__item.rnum:
         raise AppTestError(u'課金分の所持数がおかしい')
     itemdata = CabaClubItemPlayerData.getByKey(self.__player.id)
     if itemdata.preferential_id != self.__itemmaster.id:
         raise AppTestError(u'CabaClubItemPlayerDataにアイテムIDが正しく設定されていない')
     elif itemdata.preferential_time < (self.__itemdata.preferential_time + datetime.timedelta(seconds=3600*6)):
         raise AppTestError(u'CabaClubItemPlayerDataの有効期限が正しく設定されていない')
示例#5
0
    def check(self):
        self.checkResponseStatus()

        keys = ('item', )
        for k in keys:
            if self.resultbody.get(k, None) is None:
                raise AppTestError(u'%sが設定されていない' % k)

        item = Item.getByKey(
            Item.makeID(self.__player.id, self.__itemmaster.id))
        if item is None:
            raise AppTestError(u'アイテムデータがない')
        elif item.vnum != 0:
            raise AppTestError(u'無料分の所持数がおかしい')
        elif item.rnum != self.__item.rnum:
            raise AppTestError(u'課金分の所持数がおかしい')

        playerap = PlayerAp.getByKey(self.__player.id)
        if playerap.bp != (self.__itemmaster.evalue * self.__usenum):
            raise AppTestError(u'気力が回復していない')
示例#6
0
 def __procView(self, uid):
     """詳細表示.
     """
     model_mgr = self.getModelMgr()
     now = OSAUtil.get_now()
     
     playerlist = BackendApi.get_players(self, [uid], using=backup_db)
     if not playerlist:
         self.putAlertToHtmlParam(u'見つかりませんでした', AlertCode.ERROR)
         self.__procSearch()
         return
     player = playerlist[0]
     person = BackendApi.get_dmmplayers(self, [player], using=backup_db, do_execute=True).get(player.dmmid)
     obj_player = Objects.player(self, player, person)
     obj_player['userType'] = person.userType or u'一般'
     self.html_param['player'] = obj_player
     
     # 招待してくれた人.
     invitedata = BackendApi.get_model(model_mgr, InviteData, player.dmmid, using=backup_db)
     if invitedata and invitedata.fid:
         playerlist = BackendApi.get_players(self, [invitedata.fid], [], using=backup_db, model_mgr=model_mgr)
         invite_from_player = playerlist[0] if playerlist else None
         if invite_from_player:
             invite_from_person = BackendApi.get_dmmplayers(self, [invite_from_player], using=backup_db, do_execute=True).get(invite_from_player.dmmid)
             self.html_param['invitedata'] = {
                 'url' : self.makeAppLinkUrlAdmin(UrlMaker.view_player(invite_from_player.id)),
                 'player' : Objects.player(self, invite_from_player, invite_from_person),
                 'ctime' : invitedata.ctime,
                 'state' : Defines.InviteState.NAMES[invitedata.state],
             }
     
     # 招待した人数.
     inviterecordlist = Invite.fetchValues(filters={'uid':player.id}, order_by='mid', using=backup_db)
     if inviterecordlist:
         midlist = [inviterecord.mid for inviterecord in inviterecordlist]
         invitemasterdict = BackendApi.get_model_dict(model_mgr, InviteMaster, midlist, get_instance=True, using=backup_db)
         
         obj_inviterecordlist = []
         for inviterecord in inviterecordlist:
             invitemaster = invitemasterdict.get(inviterecord.mid)
             obj_inviterecordlist.append({
                 'id' : invitemaster.id,
                 'name' : invitemaster.name,
                 'cnt' : inviterecord.cnt,
             })
         self.html_param['inviterecordlist'] = obj_inviterecordlist
     
     regist = False
     if player.getModel(PlayerRegist) is not None:
         regist = True
         
         # アイテム.
         itemidlist = Defines.ItemEffect.NAMES.keys()
         itemmasterdict = BackendApi.get_model_dict(model_mgr, ItemMaster, itemidlist, using=backup_db)
         itemnums = BackendApi.get_model_list(model_mgr, Item, [Item.makeID(uid, iid) for iid in Defines.ItemEffect.NAMES.keys()], using=backup_db)
         iteminfolist = []
         for item in itemnums:
             master = itemmasterdict.get(item.mid)
             if master:
                 iteminfolist.append({
                     'master' : master,
                     'nums' : item,
                 })
         self.html_param['itemlist'] = iteminfolist
         
         # 所持カード.
         deck = BackendApi.get_deck(uid, arg_model_mgr=model_mgr, using=backup_db)
         raiddeck = BackendApi.get_raid_deck(uid, arg_model_mgr=model_mgr, using=backup_db)
         
         cardlist = BackendApi.get_card_list(uid, arg_model_mgr=model_mgr, using=backup_db)
         obj_cardlist = []
         obj_deckcards = {}
         obj_raiddeckcards = {}
         cardcounts = {}
         for cardset in cardlist:
             obj_card = Objects.card(self, cardset, deck)
             obj_card['way'] = Defines.CardGetWayType.NAMES.get(cardset.card.way, u'不明')
             obj_card['raiddeckmember'] = raiddeck.is_member(cardset.id)
             if obj_card['deckmember']:
                 obj_deckcards[cardset.id] = obj_card
             elif obj_card['raiddeckmember']:
                 obj_card['raiddeckmember'] = True
                 obj_raiddeckcards[cardset.id] = obj_card
             else:
                 obj_cardlist.append(obj_card)
             mid = cardset.master.id
             data = cardcounts[mid] = cardcounts.get(mid) or {'name':cardset.master.name, 'cnt':0}
             data['cnt'] += 1
         self.html_param['deckcardlist'] = [obj_deckcards[cardid] for cardid in deck.to_array()]
         self.html_param['raiddeckcardlist'] = [obj_raiddeckcards[cardid] for cardid in raiddeck.to_array() if obj_raiddeckcards.get(cardid)]
         self.html_param['cardlist'] = obj_cardlist
         self.html_param['cardcounts'] = cardcounts
         
         # フレンド.
         table = {
             'friendlist' : BackendApi.get_friend_idlist,
             'friendrequestlist' : BackendApi.get_friendrequest_send_idlist,
             'friendreceivelist' : BackendApi.get_friendrequest_receive_idlist,
         }
         for k,func in table.items():
             uidlist = func(uid, arg_model_mgr=model_mgr, using=backup_db)
             friendlist = BackendApi.get_players(self, uidlist, [], using=backup_db)
             friendmodels = BackendApi.get_model_dict(model_mgr, Friend, [Friend.makeID(uid, fid) for fid in uidlist], using=backup_db)
             obj_friendlist = []
             for friend in friendlist:
                 obj_friend = self.makeListPlayer(friend)
                 friendmodel = friendmodels.get(Friend.makeID(uid, friend.id))
                 if friendmodel:
                     obj_friend['f_time'] = friendmodel.ctime.strftime("%Y/%m/%d %H:%M:%S")
                 obj_friendlist.append(obj_friend)
             self.html_param[k] = obj_friendlist
         
         # バトル情報.
         self.html_param['battleKOs'] = BackendApi.get_battleKOs(uid, arg_model_mgr=model_mgr, using=backup_db)
         battleplayer = BackendApi.get_battleplayer(model_mgr, uid, using=backup_db)
         if battleplayer:
             # 最大ランク.
             self.html_param['max_rank'] = BackendApi.get_battlerank_max(model_mgr, using=backup_db)
             
             rankmaster = BackendApi.get_battlerank(model_mgr, battleplayer.rank, using=backup_db)
             self.html_param['battleplayer'] = Objects.battleplayer(self, battleplayer, rankmaster)
         
         # ハプニング.
         if player.getModel(PlayerHappening):
             happeningraidset = BackendApi.get_happeningraidset(model_mgr, player.happening, using=backup_db)
             if happeningraidset:
                 model_happening = happeningraidset.happening.happening
                 prize = BackendApi.aggregate_happeningprize(model_happening, model_happening.is_canceled())
                 self.html_param['happening'] = Objects.happening(self, happeningraidset, prize)
         
         self.html_param['is_ban'] = not BackendApi.check_player_ban(model_mgr, uid, using=backup_db)
         
         # スカウトイベント.
         scevent = []
         config = BackendApi.get_current_scouteventconfig(model_mgr, using=backup_db)
         if config:
             eventmaster = BackendApi.get_scouteventmaster(model_mgr, config.mid, using=backup_db)
             if eventmaster:
                 playdata = BackendApi.get_event_playdata(model_mgr, eventmaster.id, uid, using=backup_db)
                 arr = BackendApi.get_event_stages(model_mgr, [playdata.stage], using=backup_db)
                 stage = arr[0] if arr else None
                 arr = BackendApi.get_event_stages(model_mgr, [playdata.cleared], using=backup_db)
                 cleared = arr[0] if arr else None
                 scorerecord = BackendApi.get_scoutevent_scorerecord(model_mgr, eventmaster.id, uid, using=backup_db)
                 produce_list = BackendApi.get_scoutevent_presentprizemaster_by_eventid(model_mgr, eventmaster.id, using=backup_db)
                 produce_data = BackendApi.get_scoutevent_presentnums_record(model_mgr, eventmaster.id, uid, using=backup_db)
                 if produce_data:
                     nums = produce_data.nums
                 else:
                     nums = {}
                 obj_produce_list = [(produce.name, nums.get(produce.number, 0)) for produce in produce_list]
                 
                 tanzaku_list = BackendApi.get_scoutevent_tanzakumaster_by_eventid(model_mgr, eventmaster.id, using=backup_db)
                 obj_tanzaku_list = None
                 current_cast_number = -1
                 if tanzaku_list:
                     tanzakudata = ScoutEventTanzakuCastData.getByKey(ScoutEventTanzakuCastData.makeID(uid, eventmaster.id), using=backup_db)
                     current_cast_number = tanzakudata.current_cast if tanzakudata else -1
                     obj_tanzaku_list = [dict(Objects.scoutevent_tanzaku(self, tanzakumaster, tanzakudata), current=current_cast_number==tanzakumaster.number) for tanzakumaster in tanzaku_list]
                 
                 event = {'name': eventmaster.name,
                          'stage': stage,
                          'cleared': cleared,
                          'scorerecord': scorerecord,
                          'produce_list' : obj_produce_list,
                          'tanzaku_list' : obj_tanzaku_list,
                         }
                 scevent.insert(0, event)
         self.html_param['scevent'] = scevent
         
         # バトルイベント.
         battleevent_config = BackendApi.get_current_battleeventconfig(model_mgr, using=backup_db)
         if battleevent_config.mid:
             eventmaster = BackendApi.get_battleevent_master(model_mgr, battleevent_config.mid, using=backup_db)
             if eventmaster:
                 eventid = eventmaster.id
                 obj_battleevent = {
                     'id' : eventmaster.id,
                     'name' : eventmaster.name,
                     'point' : 0,
                     'point_total' : 0,
                     'rank' : 0,
                     'rankname' : u'未参加',
                     'fame' : 0,
                     'fame_next' : 0,
                 }
                 scorerecord = BackendApi.get_battleevent_scorerecord(model_mgr, eventid, uid, using=backup_db)
                 if scorerecord:
                     obj_battleevent.update({
                         'point' : scorerecord.getPointToday(),
                         'point_total' : scorerecord.point_total,
                     })
                 rankrecord = BackendApi.get_battleevent_rankrecord(model_mgr, eventid, uid, using=backup_db)
                 if rankrecord:
                     rank = rankrecord.getRank(battleevent_config)
                     rankmaster = BackendApi.get_battleevent_rankmaster(model_mgr, eventid, rank, using=backup_db)
                     
                     obj_battleevent.update({
                         'rank' : rank,
                         'rankname' : rankmaster.name if rankmaster else u'不明',
                         'fame' : rankrecord.fame,
                         'fame_next' : rankrecord.fame_next,
                     })
                 # ランク別バトルポイント.
                 rankmasterlist = BackendApi.get_battleevent_rankmaster_by_eventid(model_mgr, eventid, using=backup_db, do_check_open=False)
                 idlist = [BattleEventScorePerRank.makeID(uid, BattleEventScorePerRank.makeMid(eventid, rankmaster.rank)) for rankmaster in rankmasterlist]
                 scoredata_dict = BackendApi.get_model_dict(model_mgr, BattleEventScorePerRank, idlist, using=backup_db, key=lambda x:x.rank)
                 obj_rankscorelist = []
                 rankmasterlist.sort(key=lambda x:x.rank, reverse=True)
                 for rankmaster in rankmasterlist:
                     obj_rankscorelist.append({
                         'rank' : rankmaster.rank,
                         'rankname' : rankmaster.name if rankmaster else u'不明',
                         'score' : scoredata_dict[rankmaster.rank].point if scoredata_dict.get(rankmaster.rank) else 0,
                     })
                 obj_battleevent['rankscorelist'] = obj_rankscorelist
                 
                 # 現在の贈り物.
                 presentdata = BackendApi.get_model(model_mgr, BattleEventPresentData, BattleEventPresentData.makeID(uid, eventid), using=backup_db)
                 obj_presentdata = None
                 if presentdata and presentdata.getData():
                     data = presentdata.getData()
                     presentmaster = BackendApi.get_battleeventpresent_master(model_mgr, eventid, data['number'], using=backup_db)
                     contentmaster = BackendApi.get_battleeventpresent_content_master(model_mgr, data['content'], using=backup_db)
                     obj_presentdata = {
                         'present' : presentmaster,
                         'content' : contentmaster,
                         'point' : presentdata.point,
                     }
                 obj_battleevent['presentdata'] = obj_presentdata
                 
                 self.html_param['battleevent'] = obj_battleevent
     
     obj_player['regist'] = regist
     
     # ガチャチケット.
     tickettypes = Defines.GachaConsumeType.GachaTicketType.NAMES.keys()
     ticket_num_models = BackendApi.get_additional_gachaticket_nums(model_mgr, uid, tickettypes, using=backup_db)
     ticket_list = []
     for tickettype in tickettypes:
         num_model = ticket_num_models.get(tickettype)
         ticket_list.append({
             'name' : Defines.GachaConsumeType.GachaTicketType.NAMES[tickettype],
             'num' : num_model.num if num_model else 0,
         })
     self.html_param['ticket_list'] = ticket_list
     
     # ランキングガチャ.
     rankinggachascore_list = RankingGachaScore.fetchByOwner(uid, using=backup_db)
     rankinggacha_master_dict = BackendApi.get_rankinggacha_master_dict(model_mgr, [rankinggachascore.mid for rankinggachascore in rankinggachascore_list], using=backup_db)
     obj_rankinggacha_list = []
     for rankinggachascore in rankinggachascore_list:
         rankinggacha_master = rankinggacha_master_dict.get(rankinggachascore.mid)
         obj_rankinggacha_list.append({
             'id' : rankinggachascore.mid,
             'name' : rankinggacha_master.name if rankinggacha_master else u'不明',
             'single' : rankinggachascore.single,
             'total' : rankinggachascore.total,
             'firstpoint' : rankinggachascore.firstpoint,
             'firsttime' : (rankinggachascore.firsttime or OSAUtil.get_datetime_min()).strftime("%Y-%m-%d %H:%M:%S"),
         })
     self.html_param['rankinggacha_list'] = obj_rankinggacha_list
     
     # 店舗.
     cabaclubstoremaster_all = BackendApi.get_cabaretclub_store_master_all(model_mgr, using=backup_db)
     midlist = [cabaclubstoremaster.id for cabaclubstoremaster in cabaclubstoremaster_all]
     store_set_dict = BackendApi.get_cabaretclub_storeset_dict(model_mgr, uid, midlist, using=backup_db)
     obj_store_list = []
     for cabaclubstoremaster in cabaclubstoremaster_all:
         store_set = store_set_dict.get(cabaclubstoremaster.id) or CabaclubStoreSet(cabaclubstoremaster, None)
         obj = Objects.cabaclubstore(self, store_set, now)
         obj['utime'] = store_set.playerdata.utime
         obj['rtime'] = store_set.playerdata.rtime
         obj['etime'] = store_set.playerdata.etime
         obj_store_list.append(obj)
     self.html_param['cabaclubstore_list'] = obj_store_list
     
     # 称号.
     title_set = BackendApi.get_current_title_set(model_mgr, uid, now, using=backup_db)
     if title_set:
         self.html_param['title'] = Objects.title(self, title_set.master, title_set.playerdata, now)
     
     self.writeAppHtml('infomations/view_player/detail')
示例#7
0
    def process(self):
        
#        v_player = self.getViewerPlayer()
        try:
            #if self.is_pc:
            #    mid = int(self.request.get(Defines.URLQUERY_ITEM))
            #    confirmkey = v_player.req_confirmkey
            #else:
            #    args = self.getUrlArgs('/item_use2/')
            #    mid = int(args.get(0))
            #    confirmkey = urllib.unquote(args.get(1))
            args = self.getUrlArgs('/item_use2/')
            mid = int(args.get(0))
            confirmkey = urllib.unquote(args.get(1))
            usenum = int(self.request.get(Defines.URLQUERY_NUMBER) or 1)
        except:
            self.redirectWithError(CabaretError(u'リクエストが正しくありません', CabaretError.Code.ILLEGAL_ARGS))
            return
        
        if not mid in Defines.ItemEffect.USE_ABLE and not mid in Defines.ItemEffect.CABACLUB_STORE_ITEMS:
            self.redirectWithError(CabaretError(u'このアイテムは使用できません', CabaretError.Code.ILLEGAL_ARGS))
            return
        elif Defines.ItemEffect.USE_NUM_MAX.get(mid, usenum) < usenum:
            url = UrlMaker.item_useyesno(mid)
            self.redirectWithError(CabaretError(u'一度に使用できる上限数を超えています', CabaretError.Code.ILLEGAL_ARGS), url)
            return
        
        model_mgr = ModelRequestMgr()
        
        # プレイヤー情報.
        v_player = self.getViewerPlayer()
        
        # 所持数.
        num = BackendApi.get_item_nums(model_mgr, v_player.id, [mid], using=settings.DB_DEFAULT).get(mid, None)
        if num is None or num < usenum:
            # 正しく処理できない.
            url = None
            if num is not None:
                # 所持数情報が間違っているのかもしれないので消しておく.
                url = UrlMaker.item_useyesno(mid)
                model_mgr.delete_models_from_cache(Item, [Item.makeID(v_player.id, mid)])
            self.redirectWithError(CabaretError(u'正しく処理できません出来ませんでした', CabaretError.Code.ILLEGAL_ARGS), url)
            return
        
        self.__before_num = num
        self.__after_num = self.__before_num - usenum
        
        # マスターデータ.
        itemmaster = BackendApi.get_itemmaster(model_mgr, mid, using=settings.DB_READONLY)
        
        # 書き込み.
        table = {
            Defines.ItemEffect.CARD_BOX_EXPANSION : self.writeBoxExpansion,
            Defines.ItemEffect.CABACLUB_SCOUTMAN : self.writeUseCabaClubScoutMan,
            Defines.ItemEffect.CABACLUB_PREFERENTIAL : self.writeUseCabaClubPreferentialItem,
            Defines.ItemEffect.CABACLUB_BARRIER : self.writeUseCabaClubBarrierItem,
        }
        table.update(**dict.fromkeys(Defines.ItemEffect.ACTION_RECOVERY_ITEMS, self.writeApRecover))
        table.update(**dict.fromkeys(Defines.ItemEffect.TENSION_RECOVERY_ITEMS, self.writeBpRecover))
        table.update(**dict.fromkeys(Defines.ItemEffect.GACHA_PT_ACQUISITION_ITEMS, self.writeAddGachaPoint))
        table.update(**dict.fromkeys(Defines.ItemEffect.GOLD_ACQUISITION_ITEMS, self.writeAddGold))
        table.update(**dict.fromkeys(Defines.ItemEffect.SCOUT_GUM_ITEMS, self.writeUseGum))
        
        func = table.get(mid)
        if not func:
            raise CabaretError(u'未実装のアイテムです', CabaretError.Code.UNKNOWN)
        
        self.__before_value = 0
        self.__after_value = 0
        
        errcode = CabaretError.Code.UNKNOWN
        try:
            func(itemmaster, usenum, confirmkey)
            errcode = CabaretError.Code.OK
        except CabaretError,e:
            if e.code == CabaretError.Code.ALREADY_RECEIVED:
                # 既にDBに反映済み.
                errcode = e.code
                self.__after_num = BackendApi.get_item_nums(ModelRequestMgr(), v_player.id, [mid], using=settings.DB_DEFAULT).get(mid, 0)
                self.__before_num = self.__after_num + usenum
            elif e.code == CabaretError.Code.OVER_LIMIT:
                # これ以上使用できない.
                model_mgr.delete_models_from_cache(Item, [Item.makeID(v_player.id, mid)])
                
                errcode = e.code
                self.__before_num = BackendApi.get_item_nums(ModelRequestMgr(), v_player.id, [mid], using=settings.DB_DEFAULT).get(mid, 0)
                self.__after_num = self.__before_num
            else:
                raise
 def handle(self, *args, **options):
     
     print '================================'
     print 'create_benchmark_csv'
     print '================================'
     
     
     USER_ID_START = OSAUtil.BENCH_USER_ID_START
     USER_NUM = 0
     if args:
         USER_NUM = int(args[0])
     USER_NUM = max(OSAUtil.BENCH_USER_ID_NUM, USER_NUM)
     
     print '================================'
     print 'USER_NUM=%d' % USER_NUM
     
     LEVEL = 1
     GOLD = 100000
     GACHA_PT = 3000
     CARD_NUM = 100
     CARD_LIMIT = CARD_NUM + 50
     FRIEND = 50
     FRIEND_REQUEST = 50
     FRIEND_EMPTY = 50
     FRIENDLIMIT = FRIEND + FRIEND_REQUEST * 2 + FRIEND_EMPTY
     RAID_ENDTIME = DateTimeUtil.strToDateTime("20150101", "%Y%m%d")
     RAIDLOG = 100
     GREETLOG = 100
     PRESENT = int(100 / len(Defines.ItemType.PRESENT_TYPES.keys()))
     PRESENT_LIMITTIME = DateTimeUtil.strToDateTime("20150101", "%Y%m%d")
     ITEM_RNUM = 50
     ITEM_VNUM = 50
     DECK_CAPACITY = 1000000
     CABARET_TREASURE = 100000
     
     TREASURE_NUM = 20
     
     OUTPUT_DIR = os.path.join(settings_sub.TMP_DOC_ROOT, 'dummy')
     csvmgr = ModelCSVManager(OUTPUT_DIR)
     
     model_mgr = ModelRequestMgr()
     
     # 各種マスターデータ.
     levelexpmaster = model_mgr.get_model(PlayerLevelExpMaster, LEVEL)
     item_all = model_mgr.get_mastermodel_all(ItemMaster)
     card_all = [master for master in model_mgr.get_mastermodel_all(CardMaster) if master.ckind == Defines.CardKind.NORMAL and master.hklevel == 1]
     happeningall = model_mgr.get_mastermodel_all(HappeningMaster)
     arealist = model_mgr.get_mastermodel_all(AreaMaster, order_by='id')[:2]
     scoutlist = ScoutMaster.fetchValues(filters={'area__in':[area.id for area in arealist]}, order_by='id')
     treasure_gold_all = model_mgr.get_mastermodel_all(TreasureGoldMaster)
     treasure_silver_all = model_mgr.get_mastermodel_all(TreasureSilverMaster)
     treasure_bronze_all = model_mgr.get_mastermodel_all(TreasureBronzeMaster)
     
     now = OSAUtil.get_now()
     
     print '================================'
     print 'players..'
     
     class ModelList:
         def __init__(self):
             self.modellist_all = []
         
         def add(self, modellist):
             csvmgr.setModelList(modellist)
     
     modellist_all = ModelList()
     
     for i in xrange(USER_NUM):
         modellist = []
         
         uid = i + USER_ID_START
         
         # プレイヤー作成.
         player = self.install(uid)
         
         # タイプ決定とか.
         self.regist(player, levelexpmaster, GOLD, GACHA_PT, FRIENDLIMIT, CARD_LIMIT, DECK_CAPACITY, CABARET_TREASURE)
         
         modellist.append(player.getModel(Player))
         for model_cls in ModelPlayer.Meta.MODELS:
             p = player.getModel(model_cls)
             if p:
                 modellist.append(p)
         
         # スカウト完了.
         for scout in scoutlist:
             playdata = ScoutPlayData.makeInstance(ScoutPlayData.makeID(uid, scout.id))
             playdata.progress = scout.execution
             modellist.append(playdata)
             
             # フレンドの近況.
             logdata = ScoutClearLog.makeData(player.id, scout.id)
             modellist.append(logdata)
         
         for area in arealist:
             model = AreaPlayData.makeInstance(AreaPlayData.makeID(uid, area.id))
             model.clevel = levelexpmaster.level
             modellist.append(model)
             
             # フレンドの近況.
             logdata = BossWinLog.makeData(player.id, area.id)
             modellist.append(logdata)
         
         # カード付与.
         playercard = player.getModel(PlayerCard)
         cardidlist = []
         for _ in xrange(CARD_NUM):
             playercard.card += 1
             cardid = Card.makeID(uid, playercard.card)
             
             cardmaster = random.choice(card_all)
             card = BackendApi.create_card_by_master(cardmaster)
             card.id = cardid
             card.uid = uid
             modellist.append(card)
             
             cardidlist.append(cardid)
         
         # デッキ設定.
         deck = Deck()
         deck.id = uid
         deck.set_from_array(cardidlist[:Defines.DECK_CARD_NUM_MAX])
         modellist.append(deck)
         
         # カード獲得フラグ.
         for cardmaster in card_all:
             cardacquisition = CardAcquisition.makeInstance(CardAcquisition.makeID(uid, cardmaster.id))
             cardacquisition.maxlevel = cardmaster.maxlevel
             modellist.append(cardacquisition)
             
             albumacquisition = AlbumAcquisition.makeInstance(AlbumAcquisition.makeID(uid, cardmaster.album))
             modellist.append(albumacquisition)
         
         # アイテム.
         for itemmaster in item_all:
             item = Item.makeInstance(Item.makeID(uid, itemmaster.id))
             item.rnum = ITEM_RNUM
             item.vnum = ITEM_VNUM
             modellist.append(item)
         
         # レイド履歴.
         states = (Defines.HappeningState.END, Defines.HappeningState.MISS, Defines.HappeningState.CANCEL)
         for lognumber in xrange(RAIDLOG):
             happeningmaster = random.choice(happeningall)
             raidmaster = BackendApi.get_raid_master(model_mgr, happeningmaster.boss)
             self.putRaidLog(modellist, player, happeningmaster, raidmaster, states[lognumber % len(states)])
         
         # レイド.
         happeningmaster = random.choice(happeningall)
         raidmaster = BackendApi.get_raid_master(model_mgr, happeningmaster.boss)
         self.putRaid(modellist, player, happeningmaster, raidmaster, RAID_ENDTIME)
         
         # プレゼント.
         def putPresent(itype, itemid, itemvalue):
             presentlist = BackendApi.create_present(model_mgr, 0, uid, itype, itemid, itemvalue, Defines.TextMasterID.ACCESS_BONUS, PRESENT_LIMITTIME, do_set_save=False)
             modellist.extend(presentlist)
             presentlist = BackendApi.create_present(model_mgr, 0, uid, itype, itemid, itemvalue, Defines.TextMasterID.ACCESS_BONUS, now, do_set_save=False)
             modellist.extend(presentlist)
         
         for _ in xrange(PRESENT):
             putPresent(Defines.ItemType.GOLD, 0, 1000)
             putPresent(Defines.ItemType.GACHA_PT, 0, 10)
             putPresent(Defines.ItemType.ITEM, random.choice(item_all).id, 1)
             putPresent(Defines.ItemType.CARD, random.choice(card_all).id, 1)
             putPresent(Defines.ItemType.RAREOVERTICKET, 0, 1)
             putPresent(Defines.ItemType.TRYLUCKTICKET, 0, 1)
             putPresent(Defines.ItemType.MEMORIESTICKET, 0, 1)
             putPresent(Defines.ItemType.GACHATICKET, 0, 1)
             putPresent(Defines.ItemType.GOLDKEY, 0, 1)
             putPresent(Defines.ItemType.SILVERKEY, 0, 1)
         
         # 宝箱.
         def makeTreasure(masterlist, model_cls, etime):
             master = random.choice(masterlist)
             model = model_cls()
             model.uid = uid
             model.mid = master.id
             model.etime = etime
             modellist.append(model)
         
         for _ in xrange(TREASURE_NUM):
             makeTreasure(treasure_gold_all, TreasureGold, now)
             makeTreasure(treasure_gold_all, TreasureGold, PRESENT_LIMITTIME)
             
             makeTreasure(treasure_silver_all, TreasureSilver, now)
             makeTreasure(treasure_silver_all, TreasureSilver, PRESENT_LIMITTIME)
             
             makeTreasure(treasure_bronze_all, TreasureBronze, now)
             makeTreasure(treasure_bronze_all, TreasureBronze, PRESENT_LIMITTIME)
         
         modellist_all.add(modellist)
         
         print 'complete uid=%d' % uid
     
     print '================================'
     print 'friends..'
     
     # ユーザーがそろっていないと作れないレコード.
     for i in xrange(USER_NUM):
         modellist = []
         
         uid = i + USER_ID_START
         
         # フレンド設定.
         self.putFriends(modellist, uid, USER_ID_START, USER_NUM, FRIEND, FRIEND_REQUEST)
         
         # あいさつ履歴.
         fid = uid
         for _ in xrange(GREETLOG):
             fid = ((fid - USER_ID_START + 1) % USER_NUM) + USER_ID_START
             while fid == uid:
                 fid = ((fid - USER_ID_START + 1) % USER_NUM) + USER_ID_START
             
             model = GreetLog()
             model.fromid = fid
             model.toid = uid
             modellist.append(model)
         
         modellist_all.add(modellist)
         
         print 'complete uid=%d' % uid
     
     csvmgr.output()
     
     print '================================'
     print 'all done..'