예제 #1
0
    def setUpEvent(self,
                   eventmaster_kwargs=None,
                   model_mgr=None,
                   is_open=True,
                   opening=True):

        # シナリオ.
        scenario = self.create_dummy(DummyType.EVENT_SCENARIO_MASTER)

        # イベントマスター.
        eventmaster_kwargs = eventmaster_kwargs or {}
        eventmaster_kwargs.update(op=scenario.number, ed=scenario.number)
        eventmaster = self.create_dummy(DummyType.BATTLE_EVENT_MASTER,
                                        **eventmaster_kwargs)
        self.__eventmaster = eventmaster

        # イベント発生中設定.
        model_mgr = model_mgr or ModelRequestMgr()

        if is_open:
            stime = OSAUtil.get_datetime_min()
            etime = OSAUtil.get_datetime_max()
        else:
            stime = OSAUtil.get_datetime_min()
            etime = stime

        config = BackendApi.get_current_battleeventconfig(model_mgr)
        self.__preconfig_mid = config.mid
        self.__preconfig_starttime = config.starttime
        self.__preconfig_endtime = config.endtime
        self.__preconfig_ependtime = config.epilogue_endtime
        BackendApi.update_battleeventconfig(eventmaster.id, stime, etime,
                                            OSAUtil.get_datetime_max())

        return eventmaster
예제 #2
0
 def procGacha(self, uid, is_complete, stime, etime):
     """ガチャの課金情報.
     """
     paymentlist = BackendApi.get_gachapaymententry_list(uid, is_complete, using=backup_db)
     if stime or etime:
         stime = stime or OSAUtil.get_datetime_min()
         etime = etime or OSAUtil.get_datetime_min()
         paymentlist = [payment for payment in paymentlist if stime <= payment.ctime < etime]
     obj_paymentlist = self.makePaymentObjList(paymentlist, GachaMaster)
     return obj_paymentlist
예제 #3
0
 def __init__(self,
              uid,
              damage=0,
              cnt=0,
              number=0,
              feverendtime=None,
              champagne=False,
              champagne_post=0,
              champagne_add=0,
              material=0,
              tanzaku=0,
              tanzaku_post=0):
     self.__uid = uid
     self.__damage = damage
     self.__damage_cnt = cnt
     self.__number = number
     if not feverendtime:
         feverendtime = OSAUtil.get_datetime_min()
     elif not isinstance(feverendtime, datetime.datetime):
         feverendtime = DateTimeUtil.strToDateTime(feverendtime)
     self.__feverendtime = feverendtime
     self.__champagne = bool(champagne)
     self.__champagne_post = champagne_post
     self.__champagne_add = champagne_add
     self.__material_num = material
     self.__tanzaku = tanzaku
     self.__tanzaku_post = tanzaku_post
예제 #4
0
    def setUp(self):
        ua_type = Defines.CabaClubEventUAType.LIVEN_UP
        # ユーザーを用意.
        self.__player = self.create_dummy(DummyType.PLAYER)
        # 店舗を用意.
        cabaclub_dummy = self.setUpCabaclub(self.__player)
        self.__cabaclub_dummy = cabaclub_dummy
        self.__storemaster = cabaclub_dummy.stores[ua_type]
        # 期限切れにしておく.
        storeplayerdata = cabaclub_dummy.storeplayerdata[ua_type]
        storeplayerdata.ltime = OSAUtil.get_datetime_min()
        storeplayerdata.customer = 1000
        storeplayerdata.proceeds = 2000
        storeplayerdata.save()

        # 借り入れ実行.
        def tr():
            model_mgr = ModelRequestMgr()
            BackendApi.tr_cabaclub_store_rent(model_mgr, self.__player.id,
                                              self.__storemaster.id,
                                              self.__storemaster.days_0,
                                              cabaclub_dummy.now)
            model_mgr.write_all()
            model_mgr.write_end()

        db_util.run_in_transaction(tr)
예제 #5
0
class BaseMaster(BaseModel):
    class Meta:
        abstract = True

    pubstatus = models.PositiveSmallIntegerField(
        default=Defines.PublishStatus.PUBLIC,
        choices=dict_to_choices(Defines.PublishStatus.NAMES),
        verbose_name="公開ステータス")
    edittime = AppDateTimeField(default=OSAUtil.get_datetime_min(),
                                db_index=True,
                                verbose_name=u'更新時間')

    @property
    def is_public(self):
        return self.pubstatus == Defines.PublishStatus.PUBLIC

    @classmethod
    def get_formfields(cls):
        pkeyname = cls.get_primarykey_column()
        fields = [pkeyname, 'pubstatus']
        for field in cls.get_fields():
            if not field.name in fields:
                fields.append(field.name)
        return fields

    @classmethod
    def makeID(cls, uid, mid):
        return (uid << 32) + mid
예제 #6
0
 def is_update(update_time, edit_time):
     # 更新されたデータか.
     if update_time < edit_time:
         return True
     elif update_time == OSAUtil.get_datetime_min():
         return True
     else:
         return False
예제 #7
0
    def setUp(self):
        # DMMID.
        self.__player = self.create_dummy(DummyType.PLAYER)
        self.__player.pdays = 0
        self.__player.lbtime = OSAUtil.get_now() - datetime.timedelta(days=1)
        self.__player.getModel(PlayerLogin).save()

        model_mgr = ModelRequestMgr()
        # ログインボーナスを消しておく.
        for model in model_mgr.get_mastermodel_all(LoginBonusMaster):
            model_mgr.set_delete(model)
        for model in model_mgr.get_mastermodel_all(AccessBonusMaster):
            model_mgr.set_delete(model)
        # 全プレ渡しておくかぁ.
        presenteveryone_list = BackendApi.get_presenteveryone_list_forloginbonus(
            model_mgr)
        if presenteveryone_list:
            BackendApi.tr_receive_presenteveryone(model_mgr, self.__player.id,
                                                  presenteveryone_list)

        # ロングログインの設定も消しておく.
        config = BackendApi.get_current_loginbonustimelimitedconfig(model_mgr)
        self.__datalist = [data[1] for data in config.datalist]
        BackendApi.update_loginbonustimelimitedconfig(model_mgr, [])

        model_mgr.write_all()
        model_mgr.write_end()

        # 報酬.
        prize = self.create_dummy(DummyType.PRIZE_MASTER, gold=100)

        # アクセスボーナス.
        self.create_dummy(DummyType.ACCESS_BONUS_MASTER, 1, prizes=[prize.id])

        # プレゼント数.
        self.__present_num = BackendApi.get_present_num(
            self.__player.id, model_mgr)

        BackendApi.update_totalloginbonusconfig(
            model_mgr,
            0,
            stime=OSAUtil.get_datetime_min(),
            etime=OSAUtil.get_datetime_min(),
            mid_next=0,
            continuity_login=False)
예제 #8
0
파일: Trade.py 프로젝트: hitandaway100/caba
class TradeResetTime(Singleton):
    """秘宝交換リセット時間.
    """
    class Meta:
        abstract = False
        app_label = settings_sub.APP_NAME

    resettime = AppDateTimeField(default=OSAUtil.get_datetime_min(),
                                 verbose_name=u'リセット予定時間')
예제 #9
0
    def setUp(self):
        # DMMID.
        self.__player = self.create_dummy(DummyType.PLAYER)
        self.__player.ldays = 2
        self.__player.lbtime = OSAUtil.get_now() - datetime.timedelta(days=2)
        self.__player.getModel(PlayerLogin).save()

        model_mgr = ModelRequestMgr()
        # アクセスボーナスを消しておく.
        for model in model_mgr.get_mastermodel_all(AccessBonusMaster):
            model_mgr.set_delete(model)
        # 全プレ渡しておくかぁ.
        presenteveryone_list = BackendApi.get_presenteveryone_list_forloginbonus(
            model_mgr)
        if presenteveryone_list:
            BackendApi.tr_receive_presenteveryone(model_mgr, self.__player.id,
                                                  presenteveryone_list)

        model_mgr.write_all()
        model_mgr.write_end()

        # 報酬.
        prize = self.create_dummy(DummyType.PRIZE_MASTER, gold=100)

        # ログインボーナス.
        self.create_dummy(DummyType.LOGIN_BONUS_MASTER, 1, prizes=[prize.id])

        # 設定.
        model_mgr = ModelRequestMgr()
        config = BackendApi.get_current_totalloginbonusconfig(model_mgr)
        self.__ori_config = cPickle.dumps(config)
        BackendApi.update_totalloginbonusconfig(model_mgr,
                                                0,
                                                OSAUtil.get_datetime_min(),
                                                OSAUtil.get_datetime_min(),
                                                continuity_login=True)

        # プレゼント数.
        self.__present_num = BackendApi.get_present_num(
            self.__player.id, model_mgr)
예제 #10
0
 def setUp(self):
     ua_type = Defines.CabaClubEventUAType.LIVEN_UP
     # ユーザーを用意.
     self.__player = self.create_dummy(DummyType.PLAYER)
     # 店舗を用意.
     cabaclub_dummy = self.setUpCabaclub(self.__player)
     self.__cabaclub_dummy = cabaclub_dummy
     self.__storemaster = cabaclub_dummy.stores[ua_type]
     # 期限切れにしておく.
     storeplayerdata = cabaclub_dummy.storeplayerdata[ua_type]
     storeplayerdata.ltime = OSAUtil.get_datetime_min()
     storeplayerdata.save()
     self.__storeplayerdata = storeplayerdata
예제 #11
0
    def __init__(self, raid, master, eventraidmaster=None):
        self.__raid = raid
        self.__master = master
        self.__eventraidmaster = None
        self.__records = {}
        self.__combo_cnt = 0
        self.__combo_etime = OSAUtil.get_datetime_min()
        self.setEventRaidMaster(eventraidmaster)

        combodata = self.__getDBComboData()
        if combodata:
            self.__combo_cnt = combodata['cnt']
            self.__combo_etime = combodata['etime']
예제 #12
0
    def getLastUpdateVersion(model_mgr=None):
        # 現時点で最後に更新した時間の数値を返す.
        memcache_key = 'getLastUpdateVersion:%s' % MasterData.getEditCacheVersion(
        )
        client = OSAUtil.get_cache_client()
        last_update_version = client.get(memcache_key)

        model_mgr = model_mgr or ModelRequestMgr()

        if last_update_version is None:
            update_time = OSAUtil.get_datetime_min()
            last_update = update_time
            for kls in [MasterData.CLASSES[i] for i in MasterData.USE_CLIENT]:
                for obj in model_mgr.get_mastermodel_all(kls,
                                                         fetch_deleted=True):
                    edit_time = getattr(obj, Defines.MASTER_EDITTIME_COLUMN)
                    if MasterData.is_update(last_update, edit_time):
                        if last_update < edit_time:
                            last_update = edit_time
            last_update_version = MasterData.toMasterVersion(last_update)
            client.set(memcache_key, last_update_version)
        return last_update_version
예제 #13
0
    def setUp2(self):
        model_mgr = ModelRequestMgr()

        # Player.
        self.__player0 = self.create_dummy(DummyType.PLAYER)

        # イベントマスター.
        eventmaster = self.setUpEvent(model_mgr=model_mgr)
        self.__eventmaster = eventmaster

        # ランクのマスター.
        prize = self.create_dummy(DummyType.PRIZE_MASTER, gold=100)
        params = {
            'loginbonus': [prize.id],
        }
        eventrankmaster = self.createRankMaster(params=params)
        self.__eventrankmaster = eventrankmaster

        # オープニングを閲覧済みに.
        self.setOpeningViewTime(self.__player0.id)

        # 参加させておく.
        self.joinRank(self.__player0.id)

        cdate = datetime.date.today()
        rankrecord = BattleEventRank.getByKey(
            BattleEventRank.makeID(self.__player0.id, self.__eventmaster.id))
        # 未受け取りにしておく.
        model_mgr = ModelRequestMgr()
        rankrecord.utime = OSAUtil.get_datetime_min()
        model_mgr.set_save(rankrecord)
        model_mgr.write_all()
        model_mgr.write_end()

        for _ in xrange(5):
            cdate -= datetime.timedelta(days=1)
            rankmaster = self.createRankMaster(params=params)
            self.addRankLog(rankrecord, rankmaster, cdate)
예제 #14
0
    def create_player(self, opening_viewed=True, score_args=None):
        player = self.create_dummy(DummyType.PLAYER)

        # 進行情報.
        playdata = self.create_dummy(DummyType.SCOUT_EVENT_PLAY_DATA,
                                     player.id, self.__eventmaster.id)

        # OPを閲覧済みに.
        vtime = OSAUtil.get_now(
        ) if opening_viewed else OSAUtil.get_datetime_min()
        flagrecord = self.create_dummy(DummyType.SCOUT_EVENT_FLAGS, player.id,
                                       self.__eventmaster.id, vtime)

        # スコア情報.
        score_args = score_args or {}
        scorerecord = self.create_dummy(DummyType.SCOUT_EVENT_SCORE, player.id,
                                        self.__eventmaster.id, **score_args)

        self.__players[player.id] = dict(player=player,
                                         playdata=playdata,
                                         flagrecord=flagrecord,
                                         scorerecord=scorerecord)

        return player
예제 #15
0
    def setUp(self):
        model_mgr = ModelRequestMgr()

        # Player.
        self.__player0 = self.create_dummy(DummyType.PLAYER)

        # アイテム.
        itemmaster = self.create_dummy(DummyType.ITEM_MASTER)
        data = ScoutDropItemData.create(
            Defines.ItemType.ITEM,
            itemmaster.id,
            filters={'ptype': Defines.CharacterType.TYPE_001},
            rate=10000)
        items = [data.get_dropitem_dict()]

        # 素材.
        materialidlist = []
        materialnumlist = []
        for _ in xrange(Defines.RAIDEVENT_MATERIAL_KIND_MAX):
            materialmaster = self.create_dummy(
                DummyType.RAID_EVENT_MATERIAL_MASTER)
            materialidlist.append(materialmaster.id)
            materialnumlist.append(100)

        # 報酬.
        prize = self.create_dummy(DummyType.PRIZE_MASTER,
                                  gold=100,
                                  gachapt=10,
                                  item=itemmaster)

        # レイドマスター.
        raidmaster = self.create_dummy(DummyType.RAID_MASTER,
                                       hp=1,
                                       prizes=[prize.id],
                                       helpprizes=[prize.id],
                                       cabaretking=100,
                                       demiworld=10)
        self.__raidmaster = raidmaster

        # ハプニング.
        happeningmaster = self.create_dummy(DummyType.HAPPENING_MASTER,
                                            raidmaster.id,
                                            items=items)
        self.__happeningmaster = happeningmaster

        # レイドイベント.
        data = ScoutHappeningData.create(happeningmaster.id, 10000)
        happenings = [data.get_dict()]
        destroyprizes = [
            [1, [prize.id]],
        ]
        scenario = self.create_dummy(DummyType.EVENT_SCENARIO_MASTER)
        eventmaster = self.create_dummy(DummyType.RAID_EVENT_MASTER,
                                        raidtable=happenings,
                                        destroyprizes=destroyprizes,
                                        op=scenario.number,
                                        ed=scenario.number,
                                        materiallist=materialidlist)
        self.__eventmaster = eventmaster

        # レシピ.
        recipemaster = self.create_dummy(DummyType.RAID_EVENT_RECIPE_MASTER,
                                         eventmaster.id,
                                         material_num_list=materialnumlist)
        self.__recipemaster = recipemaster

        # 素材の所持数.
        materialdata = self.create_dummy(DummyType.RAID_EVENT_MATERIAL_DATA,
                                         self.__player0.id, eventmaster.id,
                                         materialnumlist)
        self.__materialdata = materialdata

        # イベント用レイド設定.
        raideventraidmaster = self.create_dummy(
            DummyType.RAID_EVENT_RAID_MASTER, self.__eventmaster.id,
            self.__raidmaster.id)
        self.__raideventraidmaster = raideventraidmaster

        # イベント終了設定.
        config = BackendApi.get_current_raideventconfig(model_mgr)
        self.__preconfig_mid = config.mid
        self.__preconfig_starttime = config.starttime
        self.__preconfig_endtime = config.endtime
        self.__preconfig_ticket_endtime = config.ticket_endtime
        config = BackendApi.update_raideventconfig(
            self.__eventmaster.id,
            OSAUtil.get_datetime_min(),
            OSAUtil.get_datetime_min(),
            ticket_endtime=OSAUtil.get_datetime_max())

        # オープニングとタイムボーナスを閲覧済みにする.
        eventflagrecord = self.create_dummy(DummyType.RAID_EVENT_FLAGS,
                                            self.__eventmaster.id,
                                            self.__player0.id,
                                            tbvtime=config.starttime)
        self.__eventflagrecord = eventflagrecord
예제 #16
0
 def setUp(self):
     model_mgr = ModelRequestMgr()
     
     trade_num = 8
     recipe_material_num = 10
     self.__trade_num = trade_num
     
     # Player.
     self.__player0 = self.create_dummy(DummyType.PLAYER)
     
     # アイテム.
     itemmaster = self.create_dummy(DummyType.ITEM_MASTER)
     self.__itemmaster = itemmaster
     
     # アイテムの所持数.
     item = self.create_dummy(DummyType.ITEM, self.__player0, itemmaster)
     self.__item = item
     
     # 素材.
     materialidlist = []
     materialnumlist = []
     for _ in xrange(Defines.RAIDEVENT_MATERIAL_KIND_MAX):
         materialmaster = self.create_dummy(DummyType.RAID_EVENT_MATERIAL_MASTER)
         materialidlist.append(materialmaster.id)
         materialnumlist.append(recipe_material_num)
     
     # レイドマスター.
     raidmaster = self.create_dummy(DummyType.RAID_MASTER, hp=1, prizes=[], helpprizes=[], cabaretking=100, demiworld=10)
     self.__raidmaster = raidmaster
     
     # ハプニング.
     happeningmaster = self.create_dummy(DummyType.HAPPENING_MASTER, raidmaster.id, items=[])
     self.__happeningmaster = happeningmaster
     
     # レイドイベント.
     data = ScoutHappeningData.create(happeningmaster.id, 10000)
     happenings = [data.get_dict()]
     destroyprizes = []
     scenario = self.create_dummy(DummyType.EVENT_SCENARIO_MASTER)
     eventmaster = self.create_dummy(DummyType.RAID_EVENT_MASTER, raidtable=happenings, destroyprizes=destroyprizes, op=scenario.number, ed=scenario.number, materiallist=materialidlist)
     self.__eventmaster = eventmaster
     
     # レシピ.
     itype = Defines.ItemType.ITEM
     itemid = self.__itemmaster.id
     itemnum = 1
     recipemaster = self.create_dummy(DummyType.RAID_EVENT_RECIPE_MASTER, eventmaster.id, itype=itype, itemid=itemid, itemnum=itemnum, stock=trade_num, material_num_list=materialnumlist)
     self.__recipemaster = recipemaster
     
     # 交換回数.
     mixdata = self.create_dummy(DummyType.RAID_EVENT_MIX_DATA, self.__player0.id, recipemaster, 0)
     self.__mixdata = mixdata
     
     # 素材の所持数.
     materialdata = self.create_dummy(DummyType.RAID_EVENT_MATERIAL_DATA, self.__player0.id, eventmaster.id, [materialnum * trade_num for materialnum in materialnumlist])
     self.__materialdata = materialdata
     
     # イベント用レイド設定.
     raideventraidmaster = self.create_dummy(DummyType.RAID_EVENT_RAID_MASTER, self.__eventmaster.id, self.__raidmaster.id)
     self.__raideventraidmaster = raideventraidmaster
     
     # イベント終了設定.
     config = BackendApi.get_current_raideventconfig(model_mgr)
     self.__preconfig_mid = config.mid
     self.__preconfig_starttime = config.starttime
     self.__preconfig_endtime = config.endtime
     self.__preconfig_ticket_endtime = config.ticket_endtime
     config = BackendApi.update_raideventconfig(self.__eventmaster.id, OSAUtil.get_datetime_min(), OSAUtil.get_datetime_min(), ticket_endtime=OSAUtil.get_datetime_max())
     
     # オープニングとタイムボーナスを閲覧済みにする.
     eventflagrecord = self.create_dummy(DummyType.RAID_EVENT_FLAGS, self.__eventmaster.id, self.__player0.id, tbvtime=config.starttime)
     self.__eventflagrecord = eventflagrecord
예제 #17
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')
예제 #18
0
 def setUp2(self):
     model_mgr = ModelRequestMgr()
     
     # Player.
     self.__player0 = self.create_dummy(DummyType.PLAYER)
     
     # イベントマスター.
     eventmaster = self.setUpEvent(model_mgr=model_mgr, is_open=False)
     self.__eventmaster = eventmaster
     
     # OPを閲覧済みに.
     self.create_dummy(DummyType.BATTLE_EVENT_FLAGS, self.__player0.id, eventmaster.id, epvtime=OSAUtil.get_datetime_min())