Esempio n. 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
Esempio n. 2
0
    def setUp(self):
        # Player.
        self.__player0 = self.create_dummy(DummyType.PLAYER)

        # アイテム.
        itemmaster = self.create_dummy(DummyType.ITEM_MASTER)

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

        # パネル.
        self.__panelmaster = self.create_dummy(
            DummyType.PANEL_MISSION_PANEL_MASTER, prizes=prizes)

        missiondata_dict = {}
        for number in xrange(1, Defines.PANELMISSION_MISSIN_NUM_PER_PANEL + 1):
            # ミッション.
            self.create_dummy(DummyType.PANEL_MISSION_MISSION_MASTER,
                              self.__panelmaster.id,
                              number,
                              prizes=prizes,
                              condition_type=number,
                              condition_value1=number,
                              condition_value2=number)

            # 達成度.
            missiondata_dict[number] = {
                'cnt':
                number,
                'etime':
                OSAUtil.get_now() if number %
                2 == 0 else OSAUtil.get_datetime_max(),
                'rtime':
                OSAUtil.get_now() if number %
                2 == 0 else OSAUtil.get_datetime_max(),
            }

        self.__panelmission_player = self.create_dummy(
            DummyType.PLAYER_PANEL_MISSION, self.__player0.id,
            self.__panelmaster.id)
        self.__panelmission_data = self.create_dummy(
            DummyType.PANEL_MISSION_DATA,
            self.__player0.id,
            self.__panelmaster.id,
            missiondata_dict=missiondata_dict)
Esempio n. 3
0
 def create_loginbonus(self, maplist, is_open=True):
     """双六のログインボーナスを作成.
     """
     map_id_list = [
         map_id.id
         if isinstance(map_id, LoginBonusSugorokuMapMaster) else map_id
         for map_id in maplist
     ]
     loginbonusmaster = self.create_dummy(
         DummyType.LOGIN_BONUS_SUGOROKU_MASTER, map_id_list)
     if is_open:
         # ログインボーナスを設定.
         model_mgr = ModelRequestMgr()
         config = BackendApi.get_current_loginbonustimelimitedconfig(
             model_mgr)
         if self.__config_datalist is None:
             self.__config = config
             self.__config_datalist = config.datalist[:]
             config.datalist = []
         config.setData(loginbonusmaster.id,
                        OSAUtil.get_now(),
                        OSAUtil.get_datetime_max(),
                        sugoroku=True)
         config.save()
         model_mgr.save_models_to_cache([config])
     return loginbonusmaster
Esempio n. 4
0
    def setUp(self):
        # DMMID.
        self.__player = self.create_dummy(DummyType.PLAYER)
        self.__player.lbtime = OSAUtil.get_now() - datetime.timedelta(days=1)
        self.__player.tlmid = 0
        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)

        # ログインボーナス.
        master = self.create_dummy(DummyType.LOGIN_BONUS_TIME_LIMITED_MASTER)
        self.create_dummy(DummyType.LOGIN_BONUS_TIME_LIMITED_DAYS_MASTER,
                          master.id,
                          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,
                                                master.id,
                                                OSAUtil.get_datetime_min(),
                                                OSAUtil.get_datetime_max(),
                                                continuity_login=False)

        # プレゼント数.
        self.__present_num = BackendApi.get_present_num(self.__player.id)
Esempio n. 5
0
 def setUp(self):
     # Player.
     self.__player0 = self.create_dummy(DummyType.PLAYER)
     
     # カード.
     cardmaster = self.create_dummy(DummyType.CARD_MASTER)
     
     # 報酬.
     prize = self.create_dummy(DummyType.PRIZE_MASTER, card=cardmaster)
     prizes = [prize.id]
     
     # パネル.
     self.__panelmaster = self.create_dummy(DummyType.PANEL_MISSION_PANEL_MASTER, prizes=prizes)
     
     missiondata_dict = {}
     now = OSAUtil.get_now()
     yesterday = now - datetime.timedelta(days=1)
     for number in xrange(1, Defines.PANELMISSION_MISSIN_NUM_PER_PANEL+1):
         # ミッション.
         self.create_dummy(DummyType.PANEL_MISSION_MISSION_MASTER, self.__panelmaster.id, number, prizes=prizes, condition_type=number, condition_value1=number, condition_value2=number)
         
         # 達成度.
         etime = now
         if number % 3 == 0:
             etime = yesterday
         elif number % 3 == 1:
             etime = OSAUtil.get_datetime_max()
         
         missiondata_dict[number] = {
             'cnt' : number,
             'etime' : etime,
             'rtime' : etime,
         }
     self.__now = now
     
     self.__panelmission_player = self.create_dummy(DummyType.PLAYER_PANEL_MISSION, self.__player0.id, self.__panelmaster.id)
     self.__panelmission_data = self.create_dummy(DummyType.PANEL_MISSION_DATA, self.__player0.id, self.__panelmaster.id, missiondata_dict=missiondata_dict)
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
0
 def process(self):
     
     model_mgr = self.getModelMgr()
     
     config = BackendApi.get_current_raideventconfig(model_mgr, using=settings.DB_READONLY)
     
     args = self.getUrlArgs('/raideventtop/')
     mid = str(args.get(0))
     eventmaster = None
     
     if mid and mid.isdigit():
         mid = int(mid)
     elif config:
         mid = config.mid
     
     if mid:
         eventmaster = BackendApi.get_raideventmaster(model_mgr, mid, using=settings.DB_READONLY)
     
     if eventmaster is None:
         raise CabaretError(u'Event Closed.', CabaretError.Code.EVENT_CLOSED)
         return
     
     cur_eventmaster = self.getCurrentRaidEvent(quiet=True)
     
     mid = eventmaster.id
     
     # 開催中判定.
     is_open = cur_eventmaster and cur_eventmaster.id == mid
     
     v_player = self.getViewerPlayer()
     uid = v_player.id
     scorerecord = BackendApi.get_raidevent_scorerecord(model_mgr, mid, uid, using=settings.DB_READONLY)
     flagrecord = BackendApi.get_raidevent_flagrecord(model_mgr, mid, uid, using=settings.DB_READONLY)
     
     # イベント情報.
     self.html_param['raidevent'] = Objects.raidevent(self, eventmaster, config)
     
     # 説明とランキングのリンク.
     self.putEventTopic(mid, 'top')
     
     if is_open:
         # 救援(1件だけ).
         func_raidhelp = self.putRaidHelpList(do_execute=False, limit=1)
         self.html_param['url_raidhelp_list'] = self.makeAppLinkUrl(UrlMaker.raidevent_helplist())
         
         # 履歴(1件だけ).
         raidlogidlist = BackendApi.get_raidlog_idlist(model_mgr, v_player.id, 0, 1, using=settings.DB_READONLY)
         raidloglist = BackendApi.get_raidlogs(model_mgr, raidlogidlist, using=settings.DB_READONLY).values()
         func_raidlog = BackendApi.put_list_raidlog_obj(self, raidloglist)
         self.html_param['url_raidloglist'] = self.makeAppLinkUrl(UrlMaker.raidloglist())
         
         # 発生中のレイド情報.
         happeningraidset = self.getHappeningRaidSet()
         happeningset = None
         if happeningraidset:
             happeningset = happeningraidset.happening
         if happeningset:
             # レイドがある.
             if (happeningset.happening.is_cleared() or happeningset.happening.is_missed_and_not_end()):
                 # 未確認の結果がある.
                 url = UrlMaker.raidresultanim(happeningset.id)
                 self.appRedirect(self.makeAppLinkUrlRedirect(url))
                 return
             elif not happeningset.happening.is_end():
                 obj_happening = Objects.happening(self, happeningraidset)
                 obj_happening['url_battlepre'] = self.makeAppLinkUrl(UrlMaker.raidevent_battlepre())
                 self.html_param['happening'] = obj_happening
         
         # デッキ編成へのリンクを上書き.
         self.setFromPage(Defines.FromPages.RAIDEVENT)
         self.html_param['url_deck_raid'] = self.makeAppLinkUrl(UrlMaker.deck_raid())
     elif BackendApi.check_raidevent_lead_epilogue(model_mgr, uid, mid, using=settings.DB_READONLY):
         # EDを見ないといけない.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.raidevent_epilogue()))
         return
     
     # 報酬受取り判定.
     flag = False
     if scorerecord:
         if flagrecord is None:
             flagrecord = BackendApi.update_raideventflagrecord(model_mgr, eventmaster.id, uid, OSAUtil.get_datetime_max())
         if scorerecord.destroy and BackendApi.choice_raidevent_notfixed_destroy_prizeids(eventmaster, scorerecord.destroy, flagrecord, False):
             flag = True
         elif scorerecord.destroy_big and BackendApi.choice_raidevent_notfixed_destroy_prizeids(eventmaster, scorerecord.destroy_big, flagrecord, True):
             flag = True
     if flag:
         self.html_param['url_raidevent_prizereceive'] = self.makeAppLinkUrl(UrlMaker.raidevent_prizereceive_do(mid, v_player.req_confirmkey))
     
     # イベント秘宝所持数.
     # 討伐回数.
     rank = BackendApi.get_raidevent_rank(mid, uid)
     rank_beginer = BackendApi.get_raidevent_rank(mid, uid, is_beginer=True)
     self.html_param['raideventscore'] = Objects.raidevent_score(eventmaster, scorerecord, rank, rank_beginer)
     
     # イベントガチャのリンク.
     self.putEventGachaUrl()
     
     # 初心者フラグ.
     is_beginer = BackendApi.check_raidevent_beginer(model_mgr, uid, eventmaster, config, using=settings.DB_READONLY)
     self.html_param['is_beginer'] = is_beginer
     
     # ランキング.
     view_myrank = False
     view_beginer = self.request.get(Defines.URLQUERY_BEGINER) == "1"
     if not view_beginer or is_beginer:
         view_myrank = self.request.get(Defines.URLQUERY_FLAG) == "1"
     url_ranking = OSAUtil.addQuery(UrlMaker.raidevent_top(mid), Defines.URLQUERY_FLAG, "0")
     url_myrank = OSAUtil.addQuery(UrlMaker.raidevent_top(mid), Defines.URLQUERY_FLAG, "1")
     self.putRanking(uid, mid, view_myrank, url_ranking, url_myrank, view_beginer)
     
     # シャンパン.
     self.putChampagneData()
     
     # 素材.
     self.putMaterialHtml()
     
     # 交換所のURL.
     self.putRecipeUrl()
     
     if eventmaster.flag_dedicated_stage:
         # イベント専用ステージ情報.
         eventstageplaydata = BackendApi.get_raideventstage_playdata(model_mgr, mid, uid, using=settings.DB_READONLY)
         # 現在のステージ.
         cur_stagemaster = BackendApi.get_current_raideventstage_master(model_mgr, eventmaster, eventstageplaydata, using=settings.DB_READONLY)
         if cur_stagemaster is None:
             raise CabaretError(u'ステージが存在いません', CabaretError.Code.INVALID_MASTERDATA)
         
         # 現在のステージ情報.
         progress = eventstageplaydata.progress
         confirmkey = eventstageplaydata.confirmkey
         self.html_param['raideventstage'] = Objects.raidevent_stage(self, v_player, cur_stagemaster.stage, cur_stagemaster, progress, confirmkey)
         
         # イベント専用スカウトのTOPページへのリンク.
         self.html_param['url_raidevent_scouttop'] = self.makeAppLinkUrl(UrlMaker.raidevent_scouttop())
     
     self.execute_api()
     if is_open:
         if func_raidhelp:
             func_raidhelp()
         func_raidlog()
         
         # イベント参加のKPIを保存.
         BackendApi.save_kpi_raidevent_join(uid, self.is_pc)
     
     self.writeHtml(eventmaster, 'top')