Пример #1
0
    def process(self):

        args = self.getUrlArgs('/battleeventgrouplog/list/')
        eventid = args.getInt(0)

        model_mgr = self.getModelMgr()
        eventmaster = None
        if eventid:
            eventmaster = BackendApi.get_battleevent_master(
                model_mgr, eventid, using=settings.DB_READONLY)
        if eventmaster is None:
            self.redirectToTop()
            return

        cur_eventmaster = self.getCurrentBattleEvent(quiet=True)

        v_player = self.getViewerPlayer()
        uid = v_player.id

        basetime = DateTimeUtil.toLoginTime(OSAUtil.get_now())
        cdate_max = datetime.date(basetime.year, basetime.month, basetime.day)
        if cur_eventmaster and cur_eventmaster.id == eventid:
            cdate_max -= datetime.timedelta(days=1)

        # グループ履歴ID.
        rankrecord = BackendApi.get_battleevent_rankrecord(
            model_mgr, eventid, uid, using=settings.DB_READONLY)
        obj_list = []
        if rankrecord and rankrecord.groups:
            groupidlist = rankrecord.groups[:]
            num = len(groupidlist)
            for idx in xrange(num):
                obj = self.makeRankRecordObj(rankrecord,
                                             groupidlist[-(idx + 1)],
                                             logonly=True,
                                             cdate_max=cdate_max)
                if obj:
                    obj_list.append(obj)
        self.html_param['battleevent_rank_list'] = obj_list

        self.putEventTopic(eventmaster.id)

        if eventmaster.is_goukon:
            self.writeAppHtml('gcevent/rankloglist')
        else:
            self.writeAppHtml('btevent/rankloglist')
Пример #2
0
    def process(self):
        self.__args = self.getUrlArgs('/shopdo/')
        try:
            mid = int(self.__args.get(0))
            buynum = int(self.request.get(Defines.URLQUERY_NUMBER))
            if not (0 < buynum <= Defines.BUY_NUM_MAX):
                raise
        except:
            raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS)
        self.set_masterid(mid)

        self.__now = OSAUtil.get_now()

        # プレイヤー情報.
        v_player = self.getViewerPlayer()

        # 購入可能かをチェック.
        master = self.getShopMaster()
        buydata = self.getShopBuyData(True)
        if buydata is None:
            mgr = db_util.run_in_transaction(Handler.tr_write_buydata,
                                             v_player.id, master.id)
            mgr.write_end()
            buydata = mgr.get_wrote_model(
                ShopItemBuyData,
                ShopItemBuyData.makeID(v_player.id, master.id))

        model_mgr = self.getModelMgr()
        if not BackendApi.check_buyable_shopitem(model_mgr,
                                                 v_player,
                                                 master,
                                                 buydata,
                                                 buynum,
                                                 self.__now,
                                                 using=settings.DB_READONLY):
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'購入できない')
            url = UrlMaker.shop()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        if master.consumetype == Defines.ShopConsumeType.PAYMENT:
            self.proc_payment(master, buynum)
        else:
            self.proc_free(master, buynum)
Пример #3
0
 def process(self):
     args = self.getUrlArgs('/infomations/view_panelmission/')
     uid = args.getInt(0)
     
     model_mgr = self.getModelMgr()
     
     self.html_param['now'] = OSAUtil.get_now()
     
     player = BackendApi.get_player(self, uid, [], using=backup_db, model_mgr=model_mgr)
     if player is None:
         self.putAlertToHtmlParam(u'存在しないプレイヤーです', alert_code=AlertCode.ERROR)
     else:
         person = BackendApi.get_dmmplayers(self, [player], using=backup_db).get(player.dmmid)
         self.html_param['player'] = Objects.player(self, player, person)
         
         # 現在のパネル.
         playerpanelmission = PlayerPanelMission.getByKey(uid, using=backup_db)
         cur_panelid = playerpanelmission.panel if playerpanelmission else 1
         
         # 進行情報.
         panelmissiondata_dict = dict([(model.mid, model) for model in PanelMissionData.fetchByOwner(uid, using=backup_db)])
         
         # 現在のパネルまでの進行情報.
         obj_panel_list = []
         for panelid in xrange(1, cur_panelid+1):
             panelmaster = BackendApi.get_panelmission_panelmaster(model_mgr, panelid, using=backup_db)
             if panelmaster is None:
                 continue
             
             missionmaster_list = BackendApi.get_panelmission_missionmaster_by_panelid(model_mgr, panelid, using=backup_db)
             panelmissiondata = panelmissiondata_dict.get(panelid)
             
             obj_mission_list = []
             is_cleared = cur_panelid < panelid
             for missionmaster in missionmaster_list:
                 obj_mission_list.append(self.__makeMissionObj(missionmaster, panelmissiondata, is_cleared))
             obj_panel_list.append({
                 'name' : panelmaster.name,
                 'current' : cur_panelid == panelid,
                 'missionlist' : obj_mission_list,
                 'stime' : panelmissiondata.stime if panelmissiondata else None
             })
         self.html_param['panellist'] = obj_panel_list[::-1]
     
     self.writeAppHtml('infomations/view_panelmission')
Пример #4
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)
Пример #5
0
 def process(self):
     # 現在時刻.
     self.__now = OSAUtil.get_now()
     # ModelRequestMgr.
     model_mgr = self.getModelMgr()
     # 店舗のマスターデータ.
     args = self.getUrlArgs('/cabaclubuayesno/')
     mid = args.getInt(0)
     master = None
     if mid:
         master = BackendApi.get_cabaretclub_store_master(model_mgr, mid, using=settings.DB_READONLY)
     if master is None:
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubtop()))
         return
     # ユーザ情報.
     v_player = self.getViewerPlayer()
     uid = v_player.id
     # 店舗情報.
     storeset = BackendApi.get_cabaretclub_storeset(model_mgr, uid, mid, using=settings.DB_READONLY)
     if storeset is None or not storeset.is_alive(self.__now):
         # 店舗を借りていない.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     eventmaster = storeset.get_current_eventmaster(self.__now)
     if eventmaster is None or storeset.playerdata.ua_flag:
         # イベントが発生していない.もしくはユーザアクションを実行済み.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     elif eventmaster.ua_type == Defines.CabaClubEventUAType.NONE:
         # ユーザアクションのないイベント.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     # スコア情報.
     scoredata = BackendApi.get_cabaretclub_scoreplayerdata(model_mgr, uid, using=settings.DB_READONLY)
     obj_cabaclub_management_info = Objects.cabaclub_management_info(self, scoredata)
     # イベント情報.
     obj_cabaclubstoreeventmaster = Objects.cabaclubstoreeventmaster(self, eventmaster)
     # HTML書き込み.
     self.html_param.update(
         cabaclubstoreeventmaster = obj_cabaclubstoreeventmaster,
         cabaclub_management_info = obj_cabaclub_management_info,
         url_store = self.makeAppLinkUrl(UrlMaker.cabaclubstore(mid)),
         url_write = self.makeAppLinkUrl(UrlMaker.cabaclubuado(mid)),
     )
     self.writeAppHtml('cabaclub/uayesno')
Пример #6
0
 def process(self):
     # 現在時刻.
     self.__now = OSAUtil.get_now()
     # ModelRequestMgr.
     model_mgr = self.getModelMgr()
     # 店舗のマスターデータ.
     args = self.getUrlArgs('/cabaclubuado/')
     mid = args.getInt(0)
     master = None
     if mid:
         master = BackendApi.get_cabaretclub_store_master(
             model_mgr, mid, using=settings.DB_READONLY)
     if master is None:
         self.appRedirect(
             self.makeAppLinkUrlRedirect(UrlMaker.cabaclubtop()))
         return
     # ユーザ情報.
     v_player = self.getViewerPlayer()
     uid = v_player.id
     # 書き込み前店舗情報.
     storeset = BackendApi.get_cabaretclub_storeset(
         model_mgr, uid, mid, using=settings.DB_READONLY)
     if storeset is None or not storeset.is_alive(self.__now):
         # 店舗を借りていない.
         self.appRedirect(
             self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     eventmaster = storeset.get_current_eventmaster(self.__now)
     if eventmaster is None or storeset.playerdata.ua_flag:
         # イベントが発生していない.もしくはユーザアクションを実行済み.
         self.appRedirect(
             self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     # 書き込み.
     try:
         db_util.run_in_transaction(self.tr_write, uid, master, self.__now)
     except CabaretError, err:
         if err.code == CabaretError.Code.ALREADY_RECEIVED:
             pass
         elif err.code == CabaretError.Code.ILLEGAL_ARGS:
             self.appRedirect(
                 self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
             return
         else:
             raise
Пример #7
0
 def writeUseGum(self, itemmaster, usenum, confirmkey):
     """スカウトガム使用.
     """
     v_player = self.getViewerPlayer()
     model_mgr = ModelRequestMgr()
     eventmaster = BackendApi.get_current_scouteventmaster(model_mgr, using=settings.DB_READONLY)
     if eventmaster is None:
         raise CabaretError(u'Event Closed.', CabaretError.Code.EVENT_CLOSED)
     playdata = BackendApi.get_event_playdata(model_mgr, eventmaster.id, v_player.id, using=settings.DB_READONLY)
     now = OSAUtil.get_now()
     if now <= playdata.feveretime:
         raise CabaretError(u'Fever time.', CabaretError.Code.OVER_LIMIT)
     
     model_mgr = db_util.run_in_transaction(self.tr_write_use_gum, eventmaster.id, v_player.id, itemmaster, usenum, confirmkey)
     model_mgr.write_end()
     # 結果に渡す値を設定.
     self.__before_value = 0
     self.__after_value = 0
Пример #8
0
 def checkStep(self, master, playcount):
     """ステップの確認.
     """
     if master.consumetype not in (Defines.GachaConsumeType.STEPUP, Defines.GachaConsumeType.STEPUP2):
         return True
     
     model_mgr = self.getModelMgr()
     if playcount:
         BackendApi.stepup_reset(model_mgr, master, playcount,OSAUtil.get_now())
         step = playcount.step + 1
     else:
         step = 1
     
     if step != master.step:
         # ステップが不正.
         return False
     
     return True
Пример #9
0
 def check(self):
     # 店舗情報の確認.
     storeplayerdata = CabaClubStorePlayerData.getByKey(
         CabaClubStorePlayerData.makeID(self.__player.id,
                                        self.__storemaster.id))
     store = CabaclubStoreSet(self.__storemaster, storeplayerdata)
     if not store.is_alive(OSAUtil.get_now()):
         raise AppTestError(u'期限が切れています')
     elif not store.playerdata.is_open:
         raise AppTestError(u'開店していません')
     elif storeplayerdata.utime.strftime(
             "%Y%m%d%H%M%S") != self.__cabaclub_dummy.now.strftime(
                 "%Y%m%d%H%M%S"):
         raise AppTestError(u'utimeが正しくありません')
     elif storeplayerdata.etime.strftime("%Y%m%d%H%M%S") != (
             self.__cabaclub_dummy.now - datetime.timedelta(
                 seconds=(self.__storemaster.customer_interval *
                          (self.__exec_cnt - 1)) %
                 Defines.CABARETCLUB_STORE_EVENT_INTERVAL)
     ).strftime("%Y%m%d%H%M%S"):
         raise AppTestError(u'etimeが正しくありません')
     elif storeplayerdata.event_id != self.__eventmaster.id:
         raise AppTestError(u'イベントが設定されていません')
     # 獲得ポイントの確認.
     scoredata_weekly = CabaClubScorePlayerDataWeekly.getByKey(
         self.__cabaclub_dummy.score_weekly.id)
     customer, proceeds = self.calcCustomerAndProceeds(
         self.__cabaclub_dummy.master, self.__storemaster, self.__exec_cnt,
         self.__storeplayerdata.scoutman_add,
         self.__cabaclub_dummy.cardlist,
         self.__eventmaster.customer_up * self.__exec_cnt,
         self.__eventmaster.proceeds_up * self.__exec_cnt)
     if (storeplayerdata.customer -
             self.__storeplayerdata.customer) != customer:  # 仮.
         raise AppTestError(u'集客数が正しくありません')
     elif (storeplayerdata.proceeds -
           self.__storeplayerdata.proceeds) != proceeds:  # 仮.
         raise AppTestError(u'売上が正しくありません')
     elif (scoredata_weekly.customer -
           self.__cabaclub_dummy.score_weekly.customer) != customer:  # 仮.
         raise AppTestError(u'週間集客数が正しくありません')
     elif (scoredata_weekly.proceeds -
           self.__cabaclub_dummy.score_weekly.proceeds) != proceeds:  # 仮.
         raise AppTestError(u'週間売上が正しくありません')
Пример #10
0
 def setUp(self):
     model_mgr = ModelRequestMgr()
     
     # Player.
     self.__player0 = self.create_dummy(DummyType.PLAYER)
     
     # 報酬.
     prize = self.create_dummy(DummyType.PRIZE_MASTER, gold=100, gachapt=10)
     
     # イベントマスター.
     pointprizes = [
         [1, [prize.id]],
     ]
     eventmaster = self.create_dummy(DummyType.SCOUT_EVENT_MASTER, pointprizes=pointprizes)
     self.__eventmaster = eventmaster
     
     # ステージマスター.
     stagemaster = self.create_dummy(DummyType.SCOUT_EVENT_STAGE_MASTER, eventid=eventmaster.id, stage=1)
     self.__stagemaster = stagemaster
     
     # OPを閲覧済みに.
     flagrecord = self.create_dummy(DummyType.SCOUT_EVENT_FLAGS, self.__player0.id, self.__eventmaster.id, OSAUtil.get_now())
     self.__flagrecord = flagrecord
     
     # 項目作成.
     pointprizes = [
         [100, [prize.id]],
     ]
     self.__target_number = 1
     self.__eventmasterprizemaster = self.create_dummy(DummyType.SCOUT_EVENT_PRESENT_PRIZE_MASTER, self.__eventmaster.id, self.__target_number, pointprizes)
     
     # ハート数.
     self.create_dummy(DummyType.SCOUT_EVENT_PRESENT_NUM, self.__player0.id, self.__eventmaster.id, point=100)
     
     # イベント発生中設定.
     config = BackendApi.get_current_scouteventconfig(model_mgr)
     self.__preconfig_mid = config.mid
     self.__preconfig_starttime = config.starttime
     self.__preconfig_endtime = config.endtime
     self.__preconfig_present_endtime = config.present_endtime
     now = OSAUtil.get_now()
     BackendApi.update_scouteventconfig(self.__eventmaster.id, now, now + datetime.timedelta(days=1), present_endtime=now + datetime.timedelta(days=1))
     
     self.__present_num = BackendApi.get_present_num(self.__player0.id)
Пример #11
0
 def setUp(self):
     self.__now = OSAUtil.get_now()
     # DMMID.
     self.__player = self.create_dummy(DummyType.PLAYER)
     # 名誉ポイント.
     self.create_dummy(DummyType.CABA_CLUB_SCORE_PLAYER_DATA,
                       uid=self.__player.id,
                       point=200)
     # 設定する称号.
     self.__titlemaster = self.create_dummy(DummyType.TITLE_MASTER,
                                            cost=100,
                                            days=1)
     # 称号情報.
     titlemaster = self.create_dummy(DummyType.TITLE_MASTER,
                                     cost=100,
                                     days=1)
     self.create_dummy(DummyType.TITLE_PLAYER_DATA,
                       uid=self.__player.id,
                       title=titlemaster.id)
Пример #12
0
 def setUp(self):
     self.__now = OSAUtil.get_now()
     # DMMID.
     self.__usenum = 1
     self.__player = self.create_dummy(DummyType.PLAYER)
     self.__itemmaster = self.create_dummy(
         DummyType.ITEM_MASTER,
         mid=Defines.ItemEffect.CABACLUB_BARRIER,
         evalue=30)
     self.__item = self.create_dummy(DummyType.ITEM,
                                     self.__player,
                                     self.__itemmaster,
                                     vnum=self.__usenum,
                                     rnum=1)
     # キャバクラのアイテム使用状況.
     self.__itemdata = self.create_dummy(
         DummyType.CABA_CLUB_ITEM_PLAYER_DATA,
         self.__player.id,
         barrier_time=self.__now)
Пример #13
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)
Пример #14
0
 def process(self):
     # 現在時刻.
     self.__now = OSAUtil.get_now()
     # ModelRequestMgr.
     model_mgr = self.getModelMgr()
     # 店舗のマスターデータ.
     args = self.getUrlArgs('/cabaclubrentyesno/')
     mid = args.getInt(0)
     master = None
     if mid:
         master = BackendApi.get_cabaretclub_store_master(model_mgr, mid, using=settings.DB_READONLY)
     if master is None:
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubtop()))
         return
     # 借りる日数.
     days = self.request.get(Defines.URLQUERY_DAYS)
     days = int(days) if days and days.isdigit() else 0
     # ユーザ情報.
     v_player = self.getViewerPlayer()
     uid = v_player.id
     # 店舗情報.
     storeset = BackendApi.get_cabaretclub_storeset(model_mgr, uid, mid, using=settings.DB_READONLY)
     if storeset and (storeset.is_alive(self.__now) or storeset.get_rental_cost(days) is None):
         # 既に借り入れ済み.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     # スコア情報.
     scoredata = BackendApi.get_cabaretclub_scoreplayerdata(model_mgr, uid, using=settings.DB_READONLY)
     obj_cabaclub_management_info = Objects.cabaclub_management_info(self, scoredata)
     # 店舗マスター.
     obj_cabaclubstoremaster = Objects.cabaclubstoremaster(self, master)
     # 書き込みのURL.
     url_write = UrlMaker.cabaclubrentdo(mid)
     url_write = OSAUtil.addQuery(url_write, Defines.URLQUERY_DAYS, days)
     # HTML書き込み.
     self.html_param.update(
         cabaclub_management_info = obj_cabaclub_management_info,
         cabaclubstoremaster = obj_cabaclubstoremaster,
         url_write = self.makeAppLinkUrl(url_write),
         days = days,
     )
     self.writeAppHtml('cabaclub/rentyesno')
Пример #15
0
    def process(self):

        model_mgr = self.getModelMgr()
        cur_eventmaster = self.getCurrentRaidEvent()
        v_player = self.getViewerPlayer()
        uid = v_player.id

        # OP閲覧フラグを確認.
        flagrecord = self.getCurrentRaidFlagRecord()
        if flagrecord is None:
            # OPを見ていない.
            url = UrlMaker.raidevent_opening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # タイムボーナス演出閲覧判定.
        now = OSAUtil.get_now()
        stime, etime = BackendApi.get_raidevent_timebonus_time(
            model_mgr, using=settings.DB_READONLY, now=now)
        if stime is None or etime is None:
            # タイムボーナス中じゃない.
            url = UrlMaker.raidevent_start()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        elif not (stime <= flagrecord.tbvtime < etime):
            # タイムボーナス演出閲覧時間を更新.
            flagrecord = BackendApi.update_raideventflagrecord(
                model_mgr, cur_eventmaster.id, uid, tbvtime=now)
            model_mgr.set_got_models([flagrecord])

        # 演出のパラメータ.


#        effectpath = '%s/timebonus/effect.html' % cur_eventmaster.effectname
#        effectpath = 'levelup/effect.html'
#        params = {
#            'backUrl' : self.makeAppLinkUrl(UrlMaker.raidevent_start()),
#        }
#        self.appRedirectToEffect(self.makeAppLinkUrlEffect(effectpath, params))
        self.appRedirect(
            self.makeAppLinkUrlRedirect(UrlMaker.raidevent_start()))
Пример #16
0
 def getCurrentBattleGroup(self, do_search_log=False):
     """現在発生中のイベントで参加しているグループを取得.
     """
     if self.__current_event_group is None:
         basetime = DateTimeUtil.toLoginTime(OSAUtil.get_now())
         cdate = datetime.date(basetime.year, basetime.month, basetime.day)
         
         rankrecord = self.getCurrentBattleRankRecord()
         if rankrecord and rankrecord.groups:
             model_mgr = self.getModelMgr()
             groupid = rankrecord.groups[-1]
             group = BackendApi.get_battleevent_group(model_mgr, groupid, using=settings.DB_READONLY)
             if do_search_log and (group is None or group.cdate != cdate):
                 grouplog_dict = BackendApi.get_battleevent_grouplog_dict(model_mgr, rankrecord.groups, using=settings.DB_READONLY)
                 for groupid in rankrecord.groups[::1]:
                     group = grouplog_dict.get(groupid)
                     if group:
                         break
             self.__current_event_group = group
     return self.__current_event_group
Пример #17
0
 def process(self):
     # 現在時刻.
     self.__now = OSAUtil.get_now()
     # ModelRequestMgr.
     model_mgr = self.getModelMgr()
     # ユーザ情報.
     v_player = self.getViewerPlayer()
     uid = v_player.id
     # 店舗のマスターデータ.
     args = self.getUrlArgs('/cabaclubcastselectdo/')
     mid = args.getInt(0)
     master = None
     if mid:
         master = BackendApi.get_cabaretclub_store_master(
             model_mgr, mid, using=settings.DB_READONLY)
     if master is None:
         self.appRedirect(
             self.makeAppLinkUrlRedirect(UrlMaker.cabaclubtop()))
         return
     self.__mid = master.id
     # 削除するID.
     cardid_remove = args.getInt(1)
     # 設定するID.
     cardid_add = args.getInt(2)
     if not cardid_add:
         # 設定するカードが設定されていない.
         self.appRedirect(
             self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     try:
         db_util.run_in_transaction(self.tr_write, uid, master, self.__now,
                                    cardid_remove, cardid_add)
     except CabaretError, err:
         if err.code == CabaretError.Code.ALREADY_RECEIVED:
             pass
         elif err.code == CabaretError.Code.ILLEGAL_ARGS:
             self.appRedirect(
                 self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
             return
         else:
             raise
Пример #18
0
    def setUp(self):
        model_mgr = ModelRequestMgr()

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

        # イベントマスター.
        scenario = self.create_dummy(DummyType.EVENT_SCENARIO_MASTER)
        eventmaster = self.create_dummy(DummyType.SCOUT_EVENT_MASTER,
                                        op=scenario.number,
                                        ed=scenario.number)
        self.__eventmaster = eventmaster

        # イベント発生中設定.
        config = BackendApi.get_current_scouteventconfig(model_mgr)
        self.__preconfig_mid = config.mid
        self.__preconfig_starttime = config.starttime
        self.__preconfig_endtime = config.endtime
        now = OSAUtil.get_now()
        BackendApi.update_scouteventconfig(self.__eventmaster.id, now,
                                           now + datetime.timedelta(days=1))
Пример #19
0
    def process(self):

        now = OSAUtil.get_now()

        model_mgr = self.getModelMgr()
        config = BackendApi.get_current_battleeventconfig(
            model_mgr, using=settings.DB_READONLY)
        cur_eventmaster = None
        if config.mid and now < config.endtime:
            cur_eventmaster = BackendApi.get_battleevent_master(
                model_mgr, config.mid, using=settings.DB_READONLY)

        if cur_eventmaster is None or not cur_eventmaster.is_goukon:
            self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.mypage()))
            return

        v_player = self.getViewerPlayer()
        uid = v_player.id

        # 閲覧フラグを立てる.
        if BackendApi.check_battleevent_lead_scenario(
                model_mgr, uid, config.mid, using=settings.DB_READONLY):
            flagrecord = BackendApi.update_battleevent_flagrecord(
                cur_eventmaster.id, uid, scvtime=now)
            model_mgr.set_got_models([flagrecord])

        # 演出のパラメータ.
        effectpath = '%s/event_nakaoshi/effect.html' % cur_eventmaster.effectname
        params = {
            'backUrl':
            self.makeAppLinkUrl(UrlMaker.battleevent_top(cur_eventmaster.id)),
            'pre':
            self.url_static +
            'effect/sp/v2/%s/data/' % cur_eventmaster.effectname,
            'logo_img':
            'scenario/event_logo.png',
            'logo_w_img':
            'scenario/event_logo_w.png',
        }
        self.appRedirectToEffect(effectpath, params)
Пример #20
0
 def check(self):
     # 店舗情報の確認.
     storeplayerdata = CabaClubStorePlayerData.getByKey(
         CabaClubStorePlayerData.makeID(self.__player.id,
                                        self.__storemaster.id))
     store = CabaclubStoreSet(self.__storemaster, storeplayerdata)
     if store.is_alive(OSAUtil.get_now()):
         raise AppTestError(u'期限が切れていません')
     elif store.playerdata.is_open:
         raise AppTestError(u'閉店していません')
     elif storeplayerdata.utime.strftime(
             "%Y%m%d%H%M%S") != self.__cabaclub_dummy.now.strftime(
                 "%Y%m%d%H%M%S"):
         raise AppTestError(u'utimeが正しくありません')
     elif storeplayerdata.etime.strftime(
             "%Y%m%d%H%M%S") != self.__cabaclub_dummy.now.strftime(
                 "%Y%m%d%H%M%S"):
         raise AppTestError(u'etimeが正しくありません')
     elif storeplayerdata.event_id != self.__eventmaster.id:
         raise AppTestError(u'イベントが設定されていません')
     # 獲得ポイントの確認.
     scoredata_weekly = CabaClubScorePlayerDataWeekly.getByKey(
         self.__cabaclub_dummy.score_weekly.id)
     customer, proceeds = self.calcCustomerAndProceeds(
         self.__cabaclub_dummy.master, self.__storemaster, self.__exec_cnt,
         self.__storeplayerdata.scoutman_add,
         self.__cabaclub_dummy.cardlist, 100 * self.__exec_cnt,
         100 * self.__exec_cnt)
     if (storeplayerdata.customer -
             self.__storeplayerdata.customer) != customer:  # 仮.
         raise AppTestError(u'集客数が正しくありません')
     elif (storeplayerdata.proceeds -
           self.__storeplayerdata.proceeds) != proceeds:  # 仮.
         raise AppTestError(u'売上が正しくありません')
     elif (scoredata_weekly.customer -
           self.__cabaclub_dummy.score_weekly.customer) != customer:  # 仮.
         raise AppTestError(u'週間集客数が正しくありません')
     elif (scoredata_weekly.proceeds -
           self.__cabaclub_dummy.score_weekly.proceeds) != proceeds:  # 仮.
         raise AppTestError(u'週間売上が正しくありません')
Пример #21
0
 def get_maxhp(self):
     """最大HP.
     """
     if (self.raid.ctime or OSAUtil.get_now()) < RaidBoss.HP_UPDATE_TIME:
         # 旧仕様.
         return max(
             1,
             (self.master.hpbase + self.raid.level * self.master.hpgrowth) *
             self.raid.hprate / 100)
     elif self.raideventraidmaster:
         lvband = max(0, int(self.raid.level / 10 - 1))
         cnt = lvband * (lvband + 1) / 2
         pre = cnt * 10 - lvband
         return max(1,
                    (self.master.hpbase + pre * 10 * self.master.hpgrowth +
                     self.master.hpgrowth * 10 * (self.raid.level - 1)) *
                    self.raid.hprate / 100)
     else:
         return max(
             1,
             (self.master.hpbase + self.raid.level * self.master.hpgrowth) *
             self.raid.hprate / 100)
Пример #22
0
    def putGachaData(self):
        """スカウトイベント専用ガチャ情報を埋め込む.
        """
        model_mgr = self.getModelMgr()

        eventmaster = BackendApi.get_current_present_scouteventmaster(
            model_mgr, using=settings.DB_READONLY)
        if eventmaster is None:
            return

        gachamasterlist = BackendApi.get_playablegacha_list_by_consumetype(
            model_mgr,
            Defines.GachaConsumeType.SCOUTEVENT,
            using=settings.DB_READONLY,
            now=OSAUtil.get_now())

        # ガチャ情報埋め込み.
        BackendApi.put_gachahtmldata(
            self,
            gachamasterlist,
            topic=Defines.GachaConsumeType.GachaTopTopic.SCOUTEVENT,
            do_put_rare_log=False)
Пример #23
0
    def setUp(self):
        now = OSAUtil.get_now()
        testtime = BackendApi.to_cabaretclub_section_starttime(
            now) + datetime.timedelta(seconds=500)
        OSAUtil.set_now_diff(int((testtime - now).total_seconds()))

        ua_type = Defines.CabaClubEventUAType.LIVEN_UP
        # ユーザーを用意.
        self.__player = self.create_dummy(DummyType.PLAYER)
        # 店舗を用意.
        cabaclub_dummy = self.setUpCabaclub(self.__player, now=testtime)
        self.__cabaclub_dummy = cabaclub_dummy
        self.__storemaster = cabaclub_dummy.stores[ua_type]
        self.__eventmaster = cabaclub_dummy.events[ua_type]
        self.__exec_cnt = 3
        # キャストを配置しておく.
        self.create_dummy(DummyType.CABA_CLUB_CAST_PLAYER_DATA,
                          self.__player.id, self.__storemaster.id,
                          cabaclub_dummy.cardlist)
        # 前回更新時間を戻しておく.
        storeplayerdata = cabaclub_dummy.storeplayerdata[ua_type]
        storeplayerdata.is_open = True
        storeplayerdata.etime = cabaclub_dummy.now - datetime.timedelta(
            seconds=Defines.CABARETCLUB_STORE_EVENT_INTERVAL)
        storeplayerdata.utime = cabaclub_dummy.now - datetime.timedelta(
            seconds=self.__storemaster.customer_interval * self.__exec_cnt)
        storeplayerdata.save()
        self.__storeplayerdata = storeplayerdata

        # 時間進行実行.
        def tr():
            model_mgr = ModelRequestMgr()
            BackendApi.tr_cabaclubstore_advance_the_time(
                model_mgr, self.__player.id, self.__storemaster,
                cabaclub_dummy.now)
            model_mgr.write_all()
            model_mgr.write_end()

        db_util.run_in_transaction(tr)
Пример #24
0
    def setUp(self):
        model_mgr = ModelRequestMgr()

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

        # イベントマスター.
        eventmaster = self.create_dummy(DummyType.SCOUT_EVENT_MASTER)
        self.__eventmaster = eventmaster

        now = OSAUtil.get_now()

        # OPを閲覧済みに.
        flagrecord = self.create_dummy(DummyType.SCOUT_EVENT_FLAGS,
                                       self.__player0.id,
                                       self.__eventmaster.id, now)
        self.__flagrecord = flagrecord

        # イベント発生中設定.
        config = BackendApi.get_current_scouteventconfig(model_mgr)
        self.__preconfig_mid = config.mid
        self.__preconfig_starttime = config.starttime
        self.__preconfig_endtime = config.endtime
        BackendApi.update_scouteventconfig(self.__eventmaster.id, now,
                                           now + datetime.timedelta(days=1))

        PLAYER_NUM = 20
        # スコア設定.
        score = 10000000
        rankdata = []
        model_mgr = ModelRequestMgr()
        for _ in xrange(PLAYER_NUM):
            player = self.create_dummy(DummyType.PLAYER)
            BackendApi.tr_add_scoutevent_score(model_mgr, self.__eventmaster,
                                               player.id, score)
            rankdata.insert(0, (player.id, score))
            score *= 2
        model_mgr.write_all()
        model_mgr.write_end()
Пример #25
0
 def process(self):
     # 現在時刻.
     self.__now = OSAUtil.get_now()
     # ModelRequestMgr.
     model_mgr = self.getModelMgr()
     # 店舗のマスターデータ.
     args = self.getUrlArgs('/cabaclubuaend/')
     mid = args.getInt(0)
     master = None
     if mid:
         master = BackendApi.get_cabaretclub_store_master(model_mgr, mid, using=settings.DB_READONLY)
     if master is None:
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubtop()))
         return
     # イベント情報.
     eventmaster_id = self.request.get(Defines.URLQUERY_ID)
     eventmaster = None
     if eventmaster_id and eventmaster_id.isdigit():
         eventmaster_id = int(eventmaster_id)
         eventmaster = BackendApi.get_cabaretclub_event_master(model_mgr, eventmaster_id, using=settings.DB_READONLY)
     if eventmaster is None:
         # 存在しないイベント.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.cabaclubstore(mid)))
         return
     obj_cabaclubstoreeventmaster = Objects.cabaclubstoreeventmaster(self, eventmaster)
     # ユーザ情報.
     v_player = self.getViewerPlayer()
     uid = v_player.id
     # スコア情報.
     scoredata = BackendApi.get_cabaretclub_scoreplayerdata(model_mgr, uid, using=settings.DB_READONLY)
     obj_cabaclub_management_info = Objects.cabaclub_management_info(self, scoredata)
     # HTML書き込み.
     self.html_param.update(
         cabaclubstoreeventmaster = obj_cabaclubstoreeventmaster,
         cabaclub_management_info = obj_cabaclub_management_info,
         url_store = self.makeAppLinkUrl(UrlMaker.cabaclubstore(mid)),
     )
     self.writeAppHtml('cabaclub/uaend')
Пример #26
0
 def process(self):
     # 現在時刻.
     now = OSAUtil.get_now()
     # ModelRequestMgr.
     model_mgr = self.getModelMgr()
     # 交換する称号.
     args = self.getUrlArgs('/titleend/')
     mid = args.getInt(0)
     master = BackendApi.get_title_master(
         model_mgr, mid, using=settings.DB_READONLY) if mid else None
     if master is None:
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.titletop()))
         return
     # ユーザ情報.
     v_player = self.getViewerPlayer()
     uid = v_player.id
     # 経営情報.
     scoredata = BackendApi.get_cabaretclub_scoreplayerdata(
         model_mgr, uid, using=settings.DB_DEFAULT)
     obj_cabaclub_management_info = Objects.cabaclub_management_info(
         self, scoredata)
     # 現在の称号.
     title_playerdata = BackendApi.get_title_playerdata(
         model_mgr, uid, using=settings.DB_DEFAULT)
     current_title_id = title_playerdata.title if title_playerdata else 0
     if current_title_id != master.id or (
             title_playerdata.stime +
             datetime.timedelta(days=master.days)) <= now:
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.titletop()))
         return
     obj_title = Objects.title(self, master, title_playerdata)
     # HTML書き込み.
     self.html_param.update(
         cabaclub_management_info=obj_cabaclub_management_info,
         title=obj_title,
         url_title=self.makeAppLinkUrl(UrlMaker.titletop()),
     )
     self.writeAppHtml('title/end')
Пример #27
0
    def execute(self, missionmaster, missionpaneldata, now=None):
        """ミッション進行と達成確認.
        """
        now = now or OSAUtil.get_now()

        # 現在の進行情報.
        missiondata = missionpaneldata.get_data(missionmaster.number)
        if missiondata['etime'] <= now:
            # 達成済み.
            return False

        # チェック項目.
        arr = self.__check_targets.get(missionmaster.condition_type)
        if not arr:
            return False

        # 確認用メソッド.
        engname = Defines.PanelMissionCondition.ENG_NAMES.get(
            missionmaster.condition_type)
        func = getattr(self, '_updateCount%s' % engname, None)
        if func is None:
            raise CabaretError(u'未実装のパネルミッションです.%d' %
                               missionmaster.condition_type)

        # 確認項目を順番に処理.
        flag = False
        for args in arr:
            is_clear = func(missiondata, missionmaster.condition_value1,
                            missionmaster.condition_value2, now, *args)
            if is_clear:
                # 達成した.
                missiondata['etime'] = now
                flag = True
                break
        # ミッション情報を更新.
        missionpaneldata.set_data(missionmaster.number, **missiondata)

        return flag
Пример #28
0
 def process(self):
     args = self.getUrlArgs('/battleeventteaser/')
     mid = args.getInt(0)
     
     def redirectToMypage():
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.mypage()))
     
     model_mgr = self.getModelMgr()
     now = OSAUtil.get_now()
     config = BackendApi.get_current_battleeventconfig(model_mgr, using=settings.DB_READONLY)
     mid = mid or config.mid
     
     eventmaster = BackendApi.get_battleevent_master(model_mgr, config.mid, using=settings.DB_READONLY)
     if eventmaster is None or not eventmaster.is_goukon:
         # 合コンイベントじゃない.
         redirectToMypage()
         return
     
     # ティザー期間判定.
     is_teaser_open = config.mid == mid and now < config.starttime
     self.html_param['is_teaser_open'] = is_teaser_open
     
     # イベント情報.
     self.html_param['battleevent'] = Objects.battleevent(self, eventmaster, now)
     
     if is_teaser_open:
         # ティザー期間中.
         v_player = self.getViewerPlayer()
         rankrecord = BackendApi.get_battleevent_rankrecord(model_mgr, eventmaster.id, v_player.id, using=settings.DB_READONLY)
         if rankrecord:
             # 登録済み.
             self.__procRegistered(config, eventmaster, rankrecord)
         else:
             self.__procNotRegistered(config, eventmaster)
         if self.response.isEnd:
             return
     
     self.writeAppHtml('gcevent/teaser_info')
Пример #29
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()]
     
     # 報酬.
     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()]
     scenario = self.create_dummy(DummyType.EVENT_SCENARIO_MASTER)
     eventmaster = self.create_dummy(DummyType.RAID_EVENT_MASTER, raidtable=happenings, op=scenario.number, ed=scenario.number)
     self.__eventmaster = eventmaster
     
     # イベント発生中設定.
     config = BackendApi.get_current_raideventconfig(model_mgr)
     self.__preconfig_mid = config.mid
     self.__preconfig_starttime = config.starttime
     self.__preconfig_endtime = config.endtime
     self.__preconfig_timebonus = config.timebonus_time
     timebonus_time = []
     now = OSAUtil.get_now()
     BackendApi.update_raideventconfig(self.__eventmaster.id, now, now + datetime.timedelta(days=1), timebonus_time=timebonus_time)
Пример #30
0
 def cb():
     now = OSAUtil.get_now()
     
     obj_raidlist = []
     for raidhelp in raidhelplist:
         if happeningraidset_dict.has_key(raidhelp.raidid):
             happeningraidset = happeningraidset_dict[raidhelp.raidid]
             happeningset = happeningraidset.happening
             raidboss = happeningraidset.raidboss
             
             if happeningset.happening.event:
                 eventraidmaster = BackendApi.get_eventraidmaster_by_modeleventvalue(model_mgr, happeningset.happening.event, raidboss.master.id, using=settings.DB_READONLY)
                 raidboss.setEventRaidMaster(eventraidmaster)
             
             o_person = None
             o_player = o_playerdict.get(raidhelp.fromid)
             if o_player:
                 o_person = persons.get(o_player.dmmid)
             obj_raid = Objects.raid(self, raidboss, o_person, leaders.get(raidhelp.fromid))
             obj_raid['timelimit'] = Objects.timelimit(happeningset.happening.etime, now)
             obj_raidlist.append(obj_raid)
     
     self.html_param['raidhelplist'] = obj_raidlist