Exemplo n.º 1
0
    def check(self):
        model_mgr = ModelRequestMgr()

        # 進行情報があるかを確認.
        playdata = ScoutPlayData.getByKey(
            ScoutPlayData.makeID(self.__player0.id, self.__scout.id))
        if playdata is None:
            raise AppTestError(u'進行情報が保存されていない')
        elif playdata.progress == 0:
            raise AppTestError(u'進行度が進んでいない')

        # 報酬.
        resultlist = playdata.result.get('result', None)
        if not resultlist:
            raise AppTestError(u'結果が設定されていない')

        for result in resultlist:
            self.__player0.exp += result['exp_add']
            self.__player0.gold += result['gold_add']

        # お金確認.
        playergold = PlayerGold.getByKey(playdata.uid)
        if playergold.gold != self.__player0.gold:
            raise AppTestError(u'お金が正しくない')

        # 経験値.
        playerexp = PlayerExp.getByKey(playdata.uid)
        if playerexp.exp != self.__player0.exp:
            raise AppTestError(u'お金が正しくない')

        # イベント設定されているか.
        eventlist = playdata.result.get('event', None)
        if not eventlist:
            raise AppTestError(u'イベントが設定されていない')

        # ハプニング発生のイベントが設定されているか.
        targetevent = None
        for event in eventlist:
            if event.get_type() == Defines.ScoutEventType.HAPPENING:
                targetevent = event
        if targetevent is None:
            raise AppTestError(u'ハプニング発生イベントが設定されていない')
        elif targetevent.happening != self.__happeningmaster.id:
            raise AppTestError(
                u'ハプニング発生イベントに正しくハプニングが設定されていない.%d vs %d' %
                (targetevent.happening, self.__happeningmaster.id))

        happeningset = BackendApi.get_current_happening(
            model_mgr, self.__player0.id)
        if happeningset is None or happeningset.happening.mid != self.__happeningmaster.id:
            raise AppTestError(u'ハプニングが開始されていない.')

        raidboss = BackendApi.get_raid(
            model_mgr,
            happeningset.id,
            happening_eventvalue=HappeningUtil.make_raideventvalue(
                self.__eventmaster.id))
        record = raidboss.getDamageRecord(self.__player0.id)
        if not record.champagne:
            raise AppTestError(u'シャンパンコールのフラグが立っていない.')
Exemplo n.º 2
0
    def procAnim(self, args):
        """ボス戦アニメーション.
        """
        model_mgr = self.getModelMgr()
        v_player = self.getViewerPlayer()

        raidbattle = BackendApi.get_raid_battleresult(
            model_mgr, v_player.id, using=settings.DB_READONLY)
        if raidbattle is None:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'想定外の遷移です')
            url = UrlMaker.happening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # レイド情報を取得.
        raidboss = None
        happeningraidset = BackendApi.get_happeningraidset(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        if happeningraidset:
            raidboss = happeningraidset.raidboss
        if raidboss is None:
            raise CabaretError(u'超太客が存在しません', CabaretError.Code.NOT_DATA)

        animdata = raidbattle.process
        is_win = animdata.winFlag

        # 演出用パラメータ.
        params = BackendApi.make_bossbattle_animation_params(
            self, animdata, HappeningUtil.makeThumbnailUrl(raidboss.master))

        # 結果へのURL.
        cur_eventmaster = BackendApi.get_current_raideventmaster(
            model_mgr, using=settings.DB_READONLY)
        happeningset = BackendApi.get_happening(model_mgr,
                                                raidbattle.raidid,
                                                using=settings.DB_READONLY)
        eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
        if cur_eventmaster and cur_eventmaster.id == eventid:
            url = UrlMaker.raidresultanim()
        elif is_win:
            url = UrlMaker.raidend(raidbattle.raidid)
        else:
            url = UrlMaker.raidresult()
        params['backUrl'] = self.makeAppLinkUrl(url)

        self.appRedirectToEffect('bossbattle2/effect.html', params)
Exemplo n.º 3
0
    def procLastCardGetAnim(self, args):
        """最後のレア度のキャスト獲得演出
        """
        model_mgr = self.getModelMgr()
        v_player = self.getViewerPlayer()

        # get the card id form url
        cardid = args.getInt(1)

        cur_eventmaster = BackendApi.get_current_produce_event_master(
            model_mgr, using=settings.DB_READONLY)

        if not cur_eventmaster:
            raise CabaretError(u'イベントは終了しました', CabaretError.Code.EVENT_CLOSED)

        raidbattle = BackendApi.get_raid_battleresult(
            model_mgr, v_player.id, using=settings.DB_READONLY)
        if raidbattle is None:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'想定外の遷移です')
            url = UrlMaker.producehappening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # レイド情報を取得.
        raidboss = None
        happeningraidset = BackendApi.get_producehappeningraidset(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        if happeningraidset:
            raidboss = happeningraidset.raidboss
        if raidboss is None:
            raise CabaretError(u'超太客が存在しません', CabaretError.Code.NOT_DATA)

        animdata = raidbattle.process
        is_win = animdata.winFlag

        # 結果へのURL.
        happeningset = BackendApi.get_producehappening(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        eventid = HappeningUtil.get_produceeventid(
            happeningset.happening.event)
        if cur_eventmaster and cur_eventmaster.id == eventid:
            url = UrlMaker.produceraidresultanim()
        elif is_win:
            url = UrlMaker.produceraidend(raidbattle.raidid)
        else:
            url = UrlMaker.produceraidresult()

        cardmaster = BackendApi.get_model(model_mgr,
                                          CardMasterView,
                                          cardid,
                                          using=settings.DB_READONLY)
        params = {}
        params['backUrl'] = self.makeAppLinkUrl(url)
        params['cast'] = self.makeAppLinkUrlImg(
            CardUtil.makeThumbnailUrlMiddle(cardmaster))

        self.appRedirectToEffect(
            'produce_event/produce_lastcastget/effect.html', params)
Exemplo n.º 4
0
    def process(self):

        # OP閲覧判定.
        current_event = self.getCurrentRaidEvent()
        if current_event is None:
            # 通常はマイページへ遷移.
            url = UrlMaker.mypage()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        model_mgr = self.getModelMgr()
        config = BackendApi.get_current_raideventconfig(
            model_mgr, using=settings.DB_READONLY)
        flagrecord = self.getCurrentRaidFlagRecord()
        if flagrecord is None or not (config.starttime <= flagrecord.opvtime <
                                      config.endtime):
            # OPを見ていない.
            url = UrlMaker.raidevent_opening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        mid = flagrecord.mid

        # タイムボーナス演出閲覧判定.
        #        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:
        #            pass
        #        elif not (stime <= flagrecord.tbvtime < etime):
        #            # タイムボーナス演出を見ていない.
        #            url = UrlMaker.raidevent_timebonus()
        #            self.appRedirect(self.makeAppLinkUrlRedirect(url))
        #            return

        # 未確認結果判定.
        cur_happening = self.getHappening()
        if cur_happening:
            eventid = HappeningUtil.get_raideventid(
                cur_happening.happening.event)
            if eventid == mid:
                if (cur_happening.happening.is_cleared()
                        or cur_happening.happening.is_missed_and_not_end()):
                    # 未確認の結果がある.
                    url = UrlMaker.raidresultanim(cur_happening.id)
                    self.appRedirect(self.makeAppLinkUrlRedirect(url))
                    return

        # 通常はマイページへ遷移.
        url = UrlMaker.mypage()
        self.appRedirect(self.makeAppLinkUrlRedirect(url))
Exemplo n.º 5
0
    def procHappening(self, event):
        """ハプニング発生演出.
        """
        using = self.__playdata.current_db

        v_player = self.getViewerPlayer()
        model_mgr = self.getModelMgr()

        happeningid = BackendApi.get_current_producehappeningid(model_mgr,
                                                                v_player.id,
                                                                using=using,
                                                                reflesh=True)
        happeningset = BackendApi.get_producehappening(model_mgr,
                                                       happeningid,
                                                       using=using)
        if happeningset:
            eventid = HappeningUtil.get_produceeventid(
                happeningset.happening.event)
            if eventid:
                eventmaster = BackendApi.get_produce_event_master(
                    model_mgr, eventid, using=settings.DB_READONLY)
                if eventmaster:
                    raidboss = BackendApi.get_raid(model_mgr,
                                                   happeningid,
                                                   using=using)
                    if raidboss:
                        BackendApi.reset_raidboss_eventraidmaster(
                            model_mgr,
                            raidboss,
                            happeningset.happening.event,
                            using=settings.DB_READONLY)
                        self.__swf_params['pre'] = '%s%s/' % (
                            self.url_static_img, raidboss.master.thumb)
                        if raidboss.is_produceevent_bigboss():
                            # Redirect to chohutokyaku effect
                            self.appRedirectToEffect(
                                'produce_event/produce_chohutokyaku/effect.html',
                                self.__swf_params)
                        else:
                            # Redirect to hutokyaku effect
                            self.appRedirectToEffect(
                                'produce_event/produce_hutokyaku/effect.html',
                                self.__swf_params)
                        return
        self.appRedirectToEffect('chohutokyaku/effect.html', self.__swf_params)
Exemplo n.º 6
0
    def check(self):
        keys = ('redirect_url', )
        for k in keys:
            if self.response.get(k, None) is None:
                raise AppTestError(u'%sが設定されていない' % k)

        # 書き込み後の進行情報.
        playdata = self.getWroteEventScoutPlayData()
        self.checkEventCommonResult(playdata)

        stagemaster = self.getStageByNumber(self.eventplaydata.stage)

        # URLを確認.
        redirect_url = self.response['redirect_url']
        if redirect_url.find('/raideventscoutanim/{}/{}'.format(
                stagemaster.id, playdata.alreadykey)) == -1:
            raise AppTestError(u'リダイレクト先が正しくない')

        # 進行度.
        if playdata.progress == 0:
            raise AppTestError(u'進行度が進んでいない')

        self.checkEventScoutResultEvent(playdata,
                                        [Defines.ScoutEventType.HAPPENING])

        model_mgr = ModelRequestMgr()
        # ハプニング発生結果を検証.
        happeningset = BackendApi.get_current_happening(
            model_mgr, self.player.id)
        if happeningset is None or happeningset.happening.mid != self.happeningmaster.id:
            raise AppTestError(u'ハプニングが開始されていない.')

        # シャンパンコール状態の確認.
        raidboss = BackendApi.get_raid(
            model_mgr,
            happeningset.id,
            happening_eventvalue=HappeningUtil.make_raideventvalue(
                self.eventmaster.id))
        record = raidboss.getDamageRecord(self.player.id)
        if not record.champagne:
            raise AppTestError(u'シャンパンコールのフラグが立っていない.')
Exemplo n.º 7
0
    def procYesno(self):
        """諦める確認.
        """
        # プレイヤー情報.
        v_player = self.getViewerPlayer()
        self.html_param['player'] = Objects.player(self, v_player)

        # ハプニング情報.
        self.putHappeningInfo()

        self.html_param['url_happening'] = self.makeAppLinkUrl(
            UrlMaker.happening())
        self.html_param['url_raidevent_battlepre'] = self.makeAppLinkUrl(
            UrlMaker.raidevent_battlepre())

        # 書き込みへのURL.
        url = UrlMaker.happeningcancel_do()
        self.html_param['url_happeningcancel_do'] = self.makeAppLinkUrl(url)

        happeningset = self.getHappening()
        eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
        self.writeHtmlSwitchEvent('cancelyesno', eventid)
Exemplo n.º 8
0
 def makeLinkRaidBattlePre(self, happeningraidset):
     """レイド挑戦ページのURL.
     """
     model_mgr = self.getModelMgr()
     v_player = self.getViewerPlayer()
     
     happeningset = happeningraidset.happening
     raidboss = happeningraidset.raidboss
     
     if happeningraidset is None or happeningset is None or raidboss is None:
         return UrlMaker.happening()
         
     elif v_player.id != happeningset.happening.oid:
         return UrlMaker.raidhelpdetail(happeningset.id)
         
     else:
         model_mgr = self.getModelMgr()
         cur_eventmaster = BackendApi.get_current_raideventmaster(model_mgr, using=settings.DB_READONLY)
         eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
         if cur_eventmaster and cur_eventmaster.id == eventid:
             return UrlMaker.raidevent_battlepre()
         else:
             return UrlMaker.happening()
Exemplo n.º 9
0
 def process(self):
     
     model_mgr = self.getModelMgr()
     v_player = self.getViewerPlayer()
     uid = v_player.id
     
     # 開催中判定.
     cur_eventmaster = self.getCurrentRaidEvent()
     mid = cur_eventmaster.id
     
     # 現在発生中のレイド.
     happeningraidset = self.getHappeningRaidSet()
     if happeningraidset is None or happeningraidset.raidboss is None:
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.mypage()))
         return
     
     # イベントのレイド判定.
     happeningset = happeningraidset.happening
     raidboss = happeningraidset.raidboss
     eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
     if happeningset.happening.oid != uid:
         # 自分のじゃないのは救援詳細へ.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.raidhelpdetail(happeningset.id)))
         return
     elif eventid != mid:
         # イベントじゃないレイド.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.happening()))
         return
     elif not happeningset.happening.is_active():
         # 終了済み.
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.raidend(happeningset.happening.id)))
         return
     
     raideventraidmaster = BackendApi.get_raidevent_raidmaster(model_mgr, cur_eventmaster.id, raidboss.master.id, using=settings.DB_READONLY)
     
     # キャストを借りる.
     func_put_playerlist = self.putHelpFriend(raidboss)
     
     # ダメージ履歴.
     func_put_attacklog = self.putRaidAttackLog(raidboss)
     
     # イベント情報.
     config = BackendApi.get_current_raideventconfig(model_mgr, using=settings.DB_READONLY)
     self.html_param['raidevent'] = Objects.raidevent(self, cur_eventmaster, config)
     
     # レイド情報.
     obj_happening = Objects.happening(self, happeningraidset)
     self.html_param['happening'] = obj_happening
     
     # 実行リンク 等倍と3倍.
     url = UrlMaker.raiddo(raidboss.id, v_player.req_confirmkey)
     self.html_param['url_exec'] = self.makeAppLinkUrl(url)
     self.html_param['url_exec_strong'] = self.makeAppLinkUrl(OSAUtil.addQuery(url, Defines.URLQUERY_STRONG, 1))
     
     # 諦める.
     self.html_param['url_happeningcancel_yesno'] = self.makeAppLinkUrl(UrlMaker.happeningcancel_yesno())
     
     # 初心者フラグ.
     is_beginer = BackendApi.check_raidevent_beginer(model_mgr, uid, cur_eventmaster, config, using=settings.DB_READONLY)
     self.html_param['is_beginer'] = is_beginer
     
     # イベントデータ.
     scorerecord = BackendApi.get_raidevent_scorerecord(model_mgr, mid, uid, using=settings.DB_READONLY)
     rank = BackendApi.get_raidevent_rank(cur_eventmaster.id, uid)
     rank_beginer = BackendApi.get_raidevent_rank(cur_eventmaster.id, uid, is_beginer=True)
     self.html_param['raideventscore'] = Objects.raidevent_score(cur_eventmaster, scorerecord, rank, rank_beginer)
     
     # 特攻カード.
     BackendApi.put_raidevent_specialcard_info(self, uid, raideventraidmaster, using=settings.DB_READONLY)
     
     # このページに戻ってくるリンク.
     self.setFromPage(Defines.FromPages.HAPPENING, happeningset.id)
     BackendApi.put_bprecover_uselead_info(self)
     self.html_param['url_deck_raid'] = self.makeAppLinkUrl(UrlMaker.deck_raid())
     
     # デッキ情報.
     deckcardlist = self.getDeckCardList()
     self.putDeckParams(deckcardlist)
     
     self.execute_api()
     if func_put_attacklog:
         func_put_attacklog()
     if func_put_playerlist:
         func_put_playerlist()
     
     # 説明とランキングのリンク.
     url = UrlMaker.raidevent_top(mid)
     self.html_param['url_raidevent_top'] = self.makeAppLinkUrl(url)
     
     self.html_param['player'] = Objects.player(self, v_player)
     
     self.writeHtml(cur_eventmaster, 'bossappear')
Exemplo n.º 10
0
    def process(self):

        args = self.getUrlArgs('/happeningend/')

        model_mgr = self.getModelMgr()

        happeningid = str(args.get(0, ''))
        happeningraid = None
        if happeningid.isdigit():
            happeningraid = BackendApi.get_happeningraidset(
                model_mgr, int(happeningid), using=settings.DB_READONLY)
        if happeningraid is None:
            raise CabaretError(u'ハプニングが見つかりません',
                               CabaretError.Code.ILLEGAL_ARGS)

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

        happeningset = happeningraid.happening
        raideventid = HappeningUtil.get_raideventid(
            happeningset.happening.event)
        if happeningset.happening.is_end(
        ) and not happeningset.happening.is_missed_and_not_end():
            pass
        else:
            if happeningset.happening.is_cleared():
                if v_player.id == happeningset.happening.oid:
                    # 終了書き込みをさせる.
                    if settings_sub.IS_LOCAL:
                        raise CabaretError(u'まだ終わっていません')
                    url = UrlMaker.raidend(happeningset.happening.id)
                    self.appRedirect(self.makeAppLinkUrlRedirect(url))
                    return
                else:
                    pass
            elif happeningset.happening.is_missed_and_not_end():
                if v_player.id == happeningset.happening.oid:
                    # 終了書き込みをさせる.
                    if settings_sub.IS_LOCAL and not self.request.get('_test'):
                        raise CabaretError(u'終了処理を行っていません')
                    elif raideventid:
                        self.appRedirect(
                            self.makeAppLinkUrlRedirect(UrlMaker.happening()))
                        return
                    else:
                        self.writeHappeningMissed(happeningset.id)
                else:
                    pass
            else:
                if settings_sub.IS_LOCAL:
                    raise CabaretError(u'まだ終わっていません')
                url = UrlMaker.happening()
                self.appRedirect(self.makeAppLinkUrlRedirect(url))
                return

        eventmaster = None
        if raideventid:
            eventmaster = BackendApi.get_raideventmaster(
                model_mgr, raideventid, using=settings.DB_READONLY)

        if eventmaster:
            # イベント開催中.
            self.html_param['url_raidevent_top'] = self.makeAppLinkUrl(
                UrlMaker.raidevent_top(eventmaster.id))
            self.html_param['prize'] = None

            if eventmaster.flag_dedicated_stage:
                self.html_param[
                    'url_raidevent_scouttop'] = self.makeAppLinkUrl(
                        UrlMaker.raidevent_scouttop())

            if happeningset.happening.is_canceled():
                # キャンセル.
                self.html_param['cancel'] = True
                self.writeAppHtml('raidevent/failed')
            elif happeningset.happening.is_missed():
                # 失敗.
                self.html_param['cancel'] = False
                self.writeAppHtml('raidevent/failed')
            else:
                # 成功.
                url = UrlMaker.raidend(happeningset.happening.id)
                self.appRedirect(self.makeAppLinkUrlRedirect(url))
                return
        else:
            model_mgr = self.getModelMgr()

            # スカウトイベント.
            scouteventmaster = BackendApi.get_current_scouteventmaster(
                model_mgr, using=settings.DB_READONLY)
            if scouteventmaster:
                scouteventconfig = BackendApi.get_current_scouteventconfig(
                    model_mgr, using=settings.DB_READONLY)
                self.html_param['scoutevent'] = Objects.scouteventmaster(
                    self, scouteventmaster, scouteventconfig)
                self.html_param[
                    'url_scoutevent_scouttop'] = self.makeAppLinkUrl(
                        UrlMaker.scoutevent())

            # ハプニングの報酬.
            prizeinfo = None
            if v_player.id == happeningset.happening.oid:
                prizelist = self.getPooledPrizeList(
                    happeningset.happening.is_canceled())
                if prizelist:
                    prizeinfo = BackendApi.make_prizeinfo(
                        self, prizelist, using=settings.DB_READONLY)

            # 成否.
            if happeningset.happening.state in (Defines.HappeningState.END,
                                                Defines.HappeningState.CLEAR):

                # ハプニング情報.
                self.html_param['happening'] = Objects.happening(
                    self, happeningraid, prizeinfo)

                # レイドの報酬.
                self.html_param['raidprize'] = Objects.raidprize(
                    self, v_player, happeningraid.raidboss,
                    happeningset.happening.items.get('dropitems', []))

                self.writeAppHtml('happening/prizeget')
            else:
                self.html_param['prize'] = prizeinfo
                self.html_param['cancel'] = happeningset.happening.is_canceled(
                )
                self.writeAppHtml('happening/failed')
Exemplo n.º 11
0
    def procDetail(self, helplog):
        """詳細.
        """
        model_mgr = self.getModelMgr()

        v_player = self.getViewerPlayer()

        # レイド情報.
        raidboss = BackendApi.get_raid(model_mgr,
                                       helplog.raidid,
                                       using=settings.DB_READONLY,
                                       get_instance=True)
        is_owner = v_player.id == raidboss.raid.oid
        if not (is_owner
                or v_player.id in raidboss.getDamageRecordUserIdList()):
            # 閲覧できない.
            self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.happening()))
            return

        damagerecord = raidboss.getDamageRecord(v_player.id)

        is_cleared = raidboss.raid.hp == 0
        is_canceled = False

        prizelist = None

        # ハプニング情報.
        happeningset = BackendApi.get_happening(model_mgr,
                                                raidboss.id,
                                                using=settings.DB_READONLY)
        if happeningset is None:
            BackendApi.save_raidlog_idlist(model_mgr,
                                           v_player.id,
                                           using=settings.DB_READONLY)
            url = UrlMaker.raidloglist()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # イベント情報を設定.
        BackendApi.reset_raidboss_eventraidmaster(model_mgr,
                                                  raidboss,
                                                  happeningset.happening.event,
                                                  using=settings.DB_READONLY)

        raideventmaster = None
        excludes = None
        raideventid = HappeningUtil.get_raideventid(
            happeningset.happening.event)
        if raideventid:
            raideventmaster = BackendApi.get_raideventmaster(
                model_mgr, raideventid, using=settings.DB_READONLY)

            destroypoint_info = None

            if is_cleared:
                bonusscore = 0
                if happeningset.happening.oid == v_player.id:
                    specialscore_obj = BackendApi.get_model(
                        model_mgr,
                        RaidEventSpecialBonusScoreLog,
                        raidboss.id,
                        using=settings.DB_READONLY)
                    if isinstance(specialscore_obj,
                                  RaidEventSpecialBonusScoreLog):
                        bonusscore = specialscore_obj.bonusscore
                else:
                    _helpbonusscore = BackendApi.get_raidevent_helpspecialbonusscore(
                        raidboss.id, v_player.id, using=settings.DB_DEFAULT)
                    if isinstance(_helpbonusscore,
                                  RaidEventHelpSpecialBonusScore):
                        bonusscore = _helpbonusscore.bonusscore
                destroypoint_info = BackendApi.make_raidevent_destroypoint_info(
                    model_mgr,
                    v_player.id,
                    raideventmaster,
                    HappeningRaidSet(happeningset, raidboss),
                    bonusscore,
                    using=settings.DB_READONLY)

                # MVP.
                mvp_uidlist = raidboss.getMVPList()
                self.html_param['mvp_uidlist'] = mvp_uidlist

                self.html_param['destroy_time'] = helplog.ctime

            # イベント情報.
            config = BackendApi.get_current_raideventconfig(
                model_mgr, using=settings.DB_READONLY)
            self.html_param['raidevent'] = Objects.raidevent(
                self, raideventmaster, config)

            # シャンパン.
            if 0 < damagerecord.champagne_num_add:
                self.html_param[
                    'champagne_num_pre'] = damagerecord.champagne_num_pre
                self.html_param[
                    'champagne_num_post'] = damagerecord.champagne_num_post
                self.html_param[
                    'champagne_num_add'] = damagerecord.champagne_num_add

            # 素材.
            if 0 < damagerecord.material_num:
                materials = raideventmaster.getMaterialDict()
                material_id = materials.get(
                    raidboss.raideventraidmaster.material)
                if material_id:
                    materialmaster = BackendApi.get_raidevent_materialmaster(
                        model_mgr, material_id, using=settings.DB_READONLY)
                    materialnumdata = BackendApi.get_raidevent_materialdata(
                        model_mgr, v_player.id, using=settings.DB_READONLY)
                    obj = Objects.raidevent_material(
                        self, materialmaster,
                        materialnumdata.getMaterialNum(
                            raideventid,
                            raidboss.raideventraidmaster.material))
                    obj['num_add'] = damagerecord.material_num
                    self.html_param['material'] = obj

            self.html_param['destroypoint_info'] = destroypoint_info
        elif raidboss.scouteventraidmaster:
            scouteventid = raidboss.scouteventraidmaster.eventid
            tanzaku_number = raidboss.get_tanzaku_number(v_player.id)
            tanzakumaster = BackendApi.get_scoutevent_tanzakumaster(
                model_mgr,
                scouteventid,
                tanzaku_number,
                using=settings.DB_READONLY
            ) if tanzaku_number is not None else None

            if tanzakumaster is not None:
                # 短冊.
                self.html_param[
                    'scoutevent_tanzaku'] = Objects.scoutevent_tanzaku(
                        self, tanzakumaster)
                self.html_param[
                    'tanzaku_num_pre'] = damagerecord.tanzaku_num_pre
                self.html_param[
                    'tanzaku_num_post'] = damagerecord.tanzaku_num_post
                self.html_param['tanzaku_num_add'] = damagerecord.tanzaku_num

        if raideventmaster or RaidBoss.RAIDEVENT_PRIZE_UPDATETIME <= happeningset.happening.ctime:
            if is_cleared:
                # 報酬.
                prizelist = []
                if is_owner:
                    # 発見者.
                    if raideventmaster:
                        cabaretking = raidboss.get_cabaretking()
                        if 0 < cabaretking:
                            prizelist.append(
                                PrizeData.create(cabaretking=cabaretking))
                    prizelist.extend(
                        BackendApi.get_prizelist(model_mgr,
                                                 raidboss.master.prizes,
                                                 using=settings.DB_READONLY))
                    prizelist.extend(
                        BackendApi.aggregate_happeningprize(
                            happeningset.happening))
                elif 0 < damagerecord.damage_cnt:
                    # 救援者.
                    if raideventmaster:
                        demiworld = raidboss.get_demiworld()
                        if 0 < demiworld:
                            prizelist.append(
                                PrizeData.create(demiworld=demiworld))
                    prizelist = BackendApi.get_prizelist(
                        model_mgr,
                        raidboss.master.helpprizes,
                        using=settings.DB_READONLY)
            elif happeningset.happening.is_canceled(
            ) and v_player.id == happeningset.happening.oid:
                # キャンセル.
                prizelist = BackendApi.aggregate_happeningprize(
                    happeningset.happening, cancel=True)
                is_canceled = True

        # ダメージ履歴.
        func_put_attacklog = self.putRaidAttackLog(raidboss, excludes=excludes)

        prizeinfo = None
        if prizelist:
            prizeinfo = BackendApi.make_prizeinfo(self,
                                                  prizelist,
                                                  using=settings.DB_READONLY)

        persons = {}
        dmmid = ''
        if not is_owner:
            o_players = BackendApi.get_players(self,
                                               [happeningset.happening.oid],
                                               [],
                                               using=settings.DB_READONLY)
            if o_players:
                o_player = o_players[0]
                dmmid = o_player.dmmid
                persons = BackendApi.get_dmmplayers(self,
                                                    o_players,
                                                    using=settings.DB_READONLY,
                                                    do_execute=False)

        self.html_param['player'] = Objects.player(self, v_player)

        self.html_param['is_cleared'] = is_cleared
        self.html_param['is_canceled'] = is_canceled

        self.execute_api()

        self.html_param['happening'] = Objects.happening(
            self,
            HappeningRaidSet(happeningset, raidboss),
            prizeinfo,
            o_person=persons.get(dmmid))

        if func_put_attacklog:
            func_put_attacklog()

        self.setFromPage(Defines.FromPages.RAIDLOG, helplog.id)
        self.html_param['url_trade'] = self.makeAppLinkUrl(UrlMaker.trade(),
                                                           add_frompage=True)

        self.writeHtmlSwitchEvent('log',
                                  eventmaster=raideventmaster,
                                  basedir_normal='raid')
Exemplo n.º 12
0
    def procDo(self, args):
        """書き込み.
        """
        self.addloginfo('procDo')

        if settings_sub.IS_BENCH:
            v_player = self.getViewerPlayer()
            raidid = str(Happening.makeID(v_player.id, 101))
            confirmkey = ''
        else:
            raidid = str(args.get(1, ''))
            confirmkey = urllib.unquote(args.get(2, ''))
        is_strong = self.request.get(Defines.URLQUERY_STRONG) == '1'

        model_mgr = self.getModelMgr()
        self.addloginfo('get args')

        # レイド情報を取得.
        raidboss = None
        if raidid.isdigit():
            happeningraidset = BackendApi.get_happeningraidset(
                model_mgr, int(raidid))
            if happeningraidset:
                raidboss = happeningraidset.raidboss
        self.addloginfo('get raidboss')

        if raidboss is None:
            raise CabaretError(u'超太客にを接客できません', CabaretError.Code.ILLEGAL_ARGS)

        # プレイヤー.
        v_player = self.getViewerPlayer()
        uid = v_player.id
        self.addloginfo('getViewerPlayer')

        # デッキ.
        deckcardlist = self.getDeckCardList()
        self.addloginfo('getDeckCardList')

        # 助っ人.
        friendcard = self.getSelectedFriendCard(raidboss.id,
                                                do_set_default=False)
        self.addloginfo('getSelectedFriendCard')

        # SHOWTIME.
        champagne = False
        eventvalue = happeningraidset.happening.happening.event

        raideventid = HappeningUtil.get_raideventid(eventvalue)
        score = 0

        if raideventid:
            raideventmaster = BackendApi.get_current_raideventmaster(
                model_mgr, using=settings.DB_READONLY)
            raidmaster = raidboss.raideventraidmaster
            #raidhelp = RaidHelp.getValues(filters={'toid':uid, 'raidid':raidboss.id})
            if uid == raidboss.raid.oid:
                score = BackendApi.get_raidevent_specialbonusscore(
                    model_mgr,
                    uid,
                    raidmaster.specialcard,
                    raidmaster.specialcard_treasure,
                    deckcardlist,
                    using=settings.DB_DEFAULT)
            else:
                score = BackendApi.get_raidevent_specialbonusscore(
                    model_mgr,
                    uid,
                    raidmaster.specialcard,
                    raidmaster.specialcard_treasure,
                    deckcardlist,
                    raidid=raidboss.raid.id,
                    using=settings.DB_DEFAULT)

            if raideventmaster and raideventmaster.id == raideventid:
                champagnedata = BackendApi.get_raidevent_champagne(
                    model_mgr, uid, using=settings.DB_READONLY)
                if champagnedata and champagnedata.isChampagneCall(
                        raideventid):
                    champagne = True

        scouteventid = HappeningUtil.get_scouteventid(eventvalue)
        if scouteventid:
            scouteventmaster = BackendApi.get_current_scouteventmaster(
                model_mgr, using=settings.DB_READONLY)
            if scouteventmaster and scouteventmaster.id == scouteventid:
                playdata = BackendApi.get_event_playdata(
                    model_mgr, scouteventid, uid, using=settings.DB_READONLY)
                if playdata and playdata.is_lovetime():
                    champagne = True

        # 書き込み.
        try:
            model_mgr = db_util.run_in_transaction(self.tr_write, uid,
                                                   raidboss.id, confirmkey,
                                                   raidboss.master,
                                                   deckcardlist, friendcard,
                                                   is_strong, champagne, score)
            model_mgr.write_end()
        except CabaretError, err:
            if settings_sub.IS_LOCAL:
                raise
            elif err.code == CabaretError.Code.ALREADY_RECEIVED:
                # アニメーションにいけるはず.
                model_mgr = ModelRequestMgr()
                battleresult = BackendApi.get_raid_battleresult(
                    model_mgr, v_player.id, using=settings.DB_DEFAULT)
                if battleresult.is_strong != is_strong:
                    # 戻す.
                    if raidboss.raid.oid == v_player.id:
                        # 発見者.
                        url = UrlMaker.happening()
                    else:
                        # 救援者.
                        url = UrlMaker.raidhelpdetail(raidboss.raid.id)
                    self.appRedirect(self.makeAppLinkUrlRedirect(url))
                    return
            elif err.code == CabaretError.Code.OVER_LIMIT:
                # 撃破済みか終了済み.結果に飛ばすか.
                if raidboss.raid.oid == v_player.id:
                    # 発見者.
                    url = UrlMaker.raidend(raidboss.id)
                else:
                    # 救援者.終了しましたを出せるようになったので飛ばす.
                    url = UrlMaker.raidhelpdetail(raidboss.raid.id)
                self.appRedirect(self.makeAppLinkUrlRedirect(url))
                return
            else:
                raise
Exemplo n.º 13
0
    def __procView(self, raidid):
        """詳細表示.
        """
        model_mgr = self.getModelMgr()

        happeningraidset = BackendApi.get_happeningraidset(
            model_mgr, raidid, using=settings.DB_READONLY)
        if not happeningraidset:
            self.putAlertToHtmlParam(u'見つかりませんでした', AlertCode.ERROR)
            self.__procSearch()
            return

        happeningset = happeningraidset.happening

        eventmaster = None
        raidevent_id = HappeningUtil.get_raideventid(
            happeningset.happening.event)
        if raidevent_id:
            eventmaster = BackendApi.get_raideventmaster(
                model_mgr, raidevent_id, using=settings.DB_READONLY)

        # レイド詳細.
        raidboss = happeningraidset.raidboss
        BackendApi.reset_raidboss_eventraidmaster(model_mgr,
                                                  raidboss,
                                                  happeningset.happening.event,
                                                  using=settings.DB_READONLY)

        member_uidlist = list(
            set(raidboss.getDamageRecordUserIdList() + [raidboss.raid.oid]))
        playerlist = BackendApi.get_players(self,
                                            member_uidlist, [],
                                            using=settings.DB_READONLY)
        tmp = BackendApi.get_dmmplayers(self,
                                        playerlist,
                                        using=settings.DB_READONLY)
        players = dict([(player.id, player) for player in playerlist])
        persons = dict([(player.id, tmp.get(player.dmmid))
                        for player in playerlist])

        self.html_param['raid'] = self.makeRaidObj(
            happeningraidset, players[raidboss.raid.oid],
            persons.get(raidboss.raid.oid), eventmaster)

        mvpuidlist = []
        helppoints = {}
        if eventmaster:
            mvpuidlist = raidboss.getMVPList()
            helppoints = raidboss.getHelpEventPoints()
            self.html_param['event'] = {
                'id': eventmaster.id,
                'name': eventmaster.name,
            }

        # 秘宝ボーナス.
        fastbonusdata = BackendApi.get_raidevent_fastbonusdata(
            eventmaster, raidboss, happeningset.happening.etime)
        rate = 1
        if fastbonusdata:
            rate = fastbonusdata['rate']

        # ダメージ履歴.
        obj_playerlist = []
        for player in playerlist:
            record = raidboss.getDamageRecord(player.id)

            obj_player = self.makeListPlayer(player)
            obj_player['name'] = Objects.person(self, player,
                                                persons.get(
                                                    player.id))['nickname']
            obj_player['damage'] = record.damage

            ownerpoint = 0
            mvppoint = 0
            helppoint = 0

            if eventmaster and raidboss.hp < 1:
                if player.id == raidboss.raid.oid:
                    ownerpoint = raidboss.get_owner_eventpoint() * rate
                else:
                    helppoint = helppoints.get(player.id, 0) * rate

                if player.id in mvpuidlist:
                    mvppoint = raidboss.get_mvp_eventpoint() * rate

            obj_player['eventpoints'] = {
                'owner': ownerpoint,
                'mvp': mvppoint,
                'help': helppoint,
            }

            obj_playerlist.append(obj_player)
        self.html_param['playerlist'] = obj_playerlist

        self.writeAppHtml('infomations/view_raid/detail')
Exemplo n.º 14
0
 def process(self):
     
     args = self.getUrlArgs('/raidhelpdetail/')
     raidid = str(args.get(0, ''))
     
     if not raidid.isdigit():
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'レイドIDの指定がおかしい')
         self.__redirectWithError(self.makeAppLinkUrlRedirect(UrlMaker.happening()), u'Illegal ID.')
         return
     raidid = int(raidid)
     
     model_mgr = self.getModelMgr()
     v_player = self.getViewerPlayer()
     uid = v_player.id
     
     # レイド情報.
     raidboss = BackendApi.get_raid(model_mgr, raidid, using=settings.DB_READONLY)
     if raidboss is None:
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'存在しないレイド')
         raidlog = BackendApi.get_raidlog_by_raidid(model_mgr, uid, raidid, using=settings.DB_READONLY)
         if raidlog:
             self.__redirectWithError(self.makeAppLinkUrlRedirect(UrlMaker.raidlogdetail(raidlog.id)), u'Raid not Found.')
         else:
             self.__redirectWithError(self.makeAppLinkUrlRedirect(UrlMaker.happening()), u'Raid not Found and Log not Found.')
         return
     elif raidboss.raid.oid == uid:
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'自分のレイド')
         self.__redirectWithError(self.makeAppLinkUrlRedirect(UrlMaker.happening()), u'Mine.')
         return
     
     happeningset = BackendApi.get_happening(model_mgr, raidid, using=settings.DB_READONLY)
     is_end = False
     if happeningset.happening.is_active():
         # 参加可能かを確認.
         if not BackendApi.check_raid_joinable(model_mgr, raidboss, uid, using=settings.DB_READONLY):
             # もう一度開催確認.
             happeningset = BackendApi.get_happening(ModelRequestMgr(), raidid, using=settings.DB_DEFAULT)
             if happeningset.happening.is_active():
                 if settings_sub.IS_LOCAL:
                     raise CabaretError(u'参加できないレイド')
                 self.__redirectWithError(self.makeAppLinkUrlRedirect(UrlMaker.happening()), u'Cannot Join.')
                 return
             else:
                 # チェック中に終了した.
                 is_end = True
     else:
         is_end = True
     
     BackendApi.reset_raidboss_eventraidmaster(model_mgr, raidboss, happeningset.happening.event, using=settings.DB_READONLY)
     
     # プレイヤー情報.
     self.html_param['player'] = Objects.player(self, v_player)
     
     # ダメージ履歴.
     func_put_attacklog = self.putRaidAttackLog(raidboss)
     # お助け.
     func_put_playerlist = self.putHelpFriend(raidboss)
     
     # ハプニング情報.
     o_players = BackendApi.get_players(self, [happeningset.happening.oid], [], using=settings.DB_READONLY)
     dmmid = ''
     if o_players:
         o_player = o_players[0]
         dmmid = o_player.dmmid
         persons = BackendApi.get_dmmplayers(self, o_players, using=settings.DB_READONLY, do_execute=False)
     else:
         persons = {}
     
     if not is_end:
         # デッキ情報.
         deckcardlist = self.getDeckCardList()
         self.putDeckParams(deckcardlist)
     
     self.execute_api()
     
     obj_happening = Objects.happening(self, HappeningRaidSet(happeningset, raidboss), o_person=persons.get(dmmid))
     self.html_param['happening'] = obj_happening
     
     if func_put_attacklog or func_put_playerlist:
         if func_put_attacklog:
             func_put_attacklog()
         if func_put_playerlist:
             func_put_playerlist()
     
     self.setFromPage(Defines.FromPages.RAID, raidid)
     BackendApi.put_bprecover_uselead_info(self)
     
     self.html_param['url_deck_raid'] = self.makeAppLinkUrl(UrlMaker.deck_raid())
     
     # 実行Url.
     url = UrlMaker.raiddo(raidboss.id, v_player.req_confirmkey)
     self.html_param['url_exec_strong'] = self.makeAppLinkUrl(OSAUtil.addQuery(url, Defines.URLQUERY_STRONG, 1))
     self.html_param['url_exec'] = self.makeAppLinkUrl(url)
     self.html_param['url_trade'] = self.makeAppLinkUrl(UrlMaker.trade(), add_frompage=True)
     
     cur_eventmaster = BackendApi.get_current_raideventmaster(model_mgr, using=settings.DB_READONLY)
     eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
     if cur_eventmaster and cur_eventmaster.id == eventid:
         # イベント情報.
         config = BackendApi.get_current_raideventconfig(model_mgr, using=settings.DB_READONLY)
         self.html_param['raidevent'] = Objects.raidevent(self, cur_eventmaster, config)
         
         # イベントデータ.
         scorerecord = BackendApi.get_raidevent_scorerecord(model_mgr, cur_eventmaster.id, uid, using=settings.DB_READONLY)
         rank = BackendApi.get_raidevent_rank(cur_eventmaster.id, uid)
         self.html_param['raideventscore'] = Objects.raidevent_score(cur_eventmaster, scorerecord, rank)
         
         # 特攻カード.
         raideventraidmaster = BackendApi.get_raidevent_raidmaster(model_mgr, cur_eventmaster.id, raidboss.master.id, using=settings.DB_READONLY)
         BackendApi.put_raidevent_specialcard_info(self, uid, raideventraidmaster, using=settings.DB_READONLY)
         
         self.html_param['url_raidevent_top'] = self.makeAppLinkUrl(UrlMaker.raidevent_top(cur_eventmaster.id))
         
         self.html_param['is_end'] = is_end
         
         self.writeAppHtml('raidevent/bossappear')
     elif is_end:
         self.writeAppHtml('raid/helpend')
     else:
         self.writeAppHtml('raid/helpdetail')
Exemplo n.º 15
0
    def procRarityAnim(self, args):
        """レア度上昇演出
        """
        model_mgr = self.getModelMgr()
        v_player = self.getViewerPlayer()

        # カードのorder情報を取得する
        new_order = args.getInt(1)
        old_order = args.getInt(2)

        cur_eventmaster = BackendApi.get_current_produce_event_master(
            model_mgr, using=settings.DB_READONLY)

        if not cur_eventmaster:
            raise CabaretError(u'イベントは終了しました', CabaretError.Code.EVENT_CLOSED)

        raidbattle = BackendApi.get_raid_battleresult(
            model_mgr, v_player.id, using=settings.DB_READONLY)
        if raidbattle is None:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'想定外の遷移です')
            url = UrlMaker.producehappening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # レイド情報を取得.
        raidboss = None
        happeningraidset = BackendApi.get_producehappeningraidset(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        if happeningraidset:
            raidboss = happeningraidset.raidboss
        if raidboss is None:
            raise CabaretError(u'超太客が存在しません', CabaretError.Code.NOT_DATA)

        animdata = raidbattle.process
        is_win = animdata.winFlag

        # 結果へのURL.
        happeningset = BackendApi.get_producehappening(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        eventid = HappeningUtil.get_produceeventid(
            happeningset.happening.event)
        if cur_eventmaster and cur_eventmaster.id == eventid:
            url = UrlMaker.produceraidresultanim()
        elif is_win:
            url = UrlMaker.produceraidend(raidbattle.raidid)
        else:
            url = UrlMaker.produceraidresult()

        params = {}
        castmasters = cur_eventmaster.get_produce_castmasters(
            filters={'order__in': [old_order, new_order]},
            order_by='order',
            using=settings.DB_READONLY)

        old_rarity_card = BackendApi.get_model(model_mgr, CardMasterView,
                                               castmasters[0].produce_cast)
        new_rarity_card = BackendApi.get_model(model_mgr, CardMasterView,
                                               castmasters[1].produce_cast)

        params['backUrl'] = self.makeAppLinkUrl(url)
        params['old_rarity'] = self.makeAppLinkUrlImg(
            CardUtil.makeThumbnailUrlMiddle(old_rarity_card))
        params['new_rarity'] = self.makeAppLinkUrlImg(
            CardUtil.makeThumbnailUrlMiddle(new_rarity_card))

        self.appRedirectToEffect('produce_event/produce_rareup/effect.html',
                                 params)
Exemplo n.º 16
0
    def procAnim(self, args):
        """ボス戦アニメーション.
        """
        model_mgr = self.getModelMgr()
        v_player = self.getViewerPlayer()
        uid = v_player.id
        cur_eventmaster = BackendApi.get_current_produce_event_master(
            model_mgr, using=settings.DB_READONLY)

        if not cur_eventmaster:
            raise CabaretError(u'イベントは終了しました', CabaretError.Code.EVENT_CLOSED)

        raidbattle = BackendApi.get_raid_battleresult(
            model_mgr, v_player.id, using=settings.DB_READONLY)
        if raidbattle is None:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'想定外の遷移です')
            url = UrlMaker.producehappening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # レイド情報を取得.
        raidboss = None
        happeningraidset = BackendApi.get_producehappeningraidset(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        if happeningraidset:
            raidboss = happeningraidset.raidboss
        if raidboss is None:
            raise CabaretError(u'超太客が存在しません', CabaretError.Code.NOT_DATA)

        animdata = raidbattle.process
        is_win = animdata.winFlag

        player_result = model_mgr.get_model(ProduceEventHappeningResult,
                                            ProduceEventHappeningResult.makeID(
                                                uid, cur_eventmaster.id),
                                            using=settings.DB_DEFAULT)
        player_education = model_mgr.get_model(PlayerEducation,
                                               PlayerEducation.makeID(
                                                   uid, cur_eventmaster.id),
                                               using=settings.DB_DEFAULT)
        cur_event_castmasters = cur_eventmaster.get_produce_castmasters(
            order_by='order', using=settings.DB_READONLY)
        produce_castmaster = player_education.get_produce_castmaster_for_array(
            cur_event_castmasters)
        max_order = ProduceCastMaster.get_maxorder(cur_event_castmasters)

        # 演出用パラメータ.
        params = {}

        rarityup = False
        new_order = 0
        old_order = 0
        if player_result and player_education and produce_castmaster:
            new_order = player_education.cast_order
            order_rate = player_result.order

            if order_rate != 0:
                old_order = new_order - order_rate
                rarityup = bool(old_order)

            # get the correct remaining cast masters that the player hasn't gotten yet
            # NOTE: at this point new_order == player_education.cast_order == produce_castmaster.order
            # (they have the same value)
            if rarityup:
                remaining_castmaster = [
                    castmaster for castmaster in cur_event_castmasters
                    if castmaster.order >= new_order
                ]
            else:
                remaining_castmaster = [
                    castmaster for castmaster in cur_event_castmasters
                    if castmaster.order > new_order
                ]

            params['bigwinFlag'] = player_result.is_perfect_win
            params['heartBefore'] = player_result.before_heart
            params['heartGotten'] = player_result.education_point
            params['after_level'] = player_result.after_level
            params['level_min'] = player_result.before_level
            params['level_max'] = produce_castmaster.max_education_level
            params['education_levelup'] = (player_result.after_level -
                                           player_result.before_level) > 0
            params['levels'] = ":".join([
                str(castmaster.max_education_level)
                for castmaster in remaining_castmaster
            ])

        # ボスとボスキャストの画像パラメータ
        castorder = old_order if rarityup else player_education.cast_order
        eventboss_thumbnail = HappeningUtil.makeProduceEventBossThumbnailUrl(
            raidboss.master)
        eventcast_thumbnail = HappeningUtil.makeProduceEventCastThumbnailUrl(
            cur_eventmaster, castorder)
        boss_parameters = BackendApi.make_bossbattle_animation_params(
            self, animdata, eventboss_thumbnail, eventcast_thumbnail)
        params.update(boss_parameters)

        # 結果へのURL.
        happeningset = BackendApi.get_producehappening(
            model_mgr, raidbattle.raidid, using=settings.DB_READONLY)
        eventid = HappeningUtil.get_produceeventid(
            happeningset.happening.event)
        max_education_level = ProduceCastMaster.get_max_maxeducationlevel(
            cur_event_castmasters)
        # 最後のレア度のキャスト獲得??
        last_card = player_education.is_education_limit(
            max_education_level,
            max_order) and player_result.education_point > 0
        if rarityup:
            url = UrlMaker.produceraidrarityanim(new_order, old_order)
            old_produce_castmaster = ProduceCastMaster.getValues(
                filters={'order': old_order})
            params['level_max'] = old_produce_castmaster.max_education_level
        elif last_card:
            url = UrlMaker.produceraidlastcastgetanim(
                produce_castmaster.produce_cast)
        elif cur_eventmaster and cur_eventmaster.id == eventid:
            url = UrlMaker.produceraidresultanim()
        elif is_win:
            url = UrlMaker.produceraidend(raidbattle.raidid)
        else:
            url = UrlMaker.produceraidresult()
        params['backUrl'] = self.makeAppLinkUrl(url)

        self.appRedirectToEffect(
            'produce_event/produce_bossbattle/effect.html', params)
Exemplo n.º 17
0
    def process(self):
        model_mgr = self.getModelMgr()
        v_player = self.getViewerPlayer()
        uid = v_player.id

        # 開催中判定.
        cur_eventmaster = self.getCurrentProduceEvent()
        mid = cur_eventmaster.id

        # 現在発生中のレイド.
        happeningraidset = self.getHappeningRaidSet()
        if happeningraidset is None or happeningraidset.raidboss is None:
            self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.mypage()))
            return

        # イベントのレイド判定.
        happeningset = happeningraidset.happening
        raidboss = happeningraidset.raidboss
        eventid = HappeningUtil.get_produceeventid(
            happeningset.happening.event)
        if happeningset.happening.oid != uid:
            # 自分のじゃないのは救援詳細へ.
            self.appRedirect(
                self.makeAppLinkUrlRedirect(
                    UrlMaker.raidhelpdetail(happeningset.id)))
            return
        elif eventid != mid:
            # イベントじゃないレイド.
            self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.happening()))
            return
        elif not happeningset.happening.is_active():
            # 終了済み.
            self.appRedirect(
                self.makeAppLinkUrlRedirect(
                    UrlMaker.produceraidend(happeningset.happening.id)))
            return

        produceeventraidmaster = BackendApi.get_produceevent_raidmaster(
            model_mgr,
            cur_eventmaster.id,
            raidboss.master.id,
            using=settings.DB_READONLY)

        # キャストを借りる.
        func_put_playerlist = self.putHelpFriend(raidboss)

        # ダメージ履歴.
        func_put_attacklog = self.putRaidAttackLog(raidboss)

        # イベント情報.
        config = BackendApi.get_current_produce_event_config(
            model_mgr, using=settings.DB_READONLY)
        self.html_param['produceevent'] = Objects.produceevent(
            self, cur_eventmaster, config)

        # レイド情報.
        obj_happening = Objects.producehappening(self, happeningraidset)
        self.html_param['happening'] = obj_happening

        # 実行リンク 等倍と3倍.
        url = UrlMaker.produceraiddo(raidboss.id, v_player.req_confirmkey)
        self.html_param['url_exec'] = self.makeAppLinkUrl(url)
        self.html_param['url_exec_strong'] = self.makeAppLinkUrl(
            OSAUtil.addQuery(url, Defines.URLQUERY_STRONG, 1))

        # イベントデータ.
        scorerecord = BackendApi.get_produceevent_scorerecord(
            model_mgr, mid, uid, using=settings.DB_READONLY)
        self.html_param['produceeventscore'] = Objects.produceevent_score(
            cur_eventmaster, scorerecord, None)

        # 特攻カード.
        #BackendApi.put_raidevent_specialcard_info(self, uid, produceeventraidmaster, using=settings.DB_READONLY)

        # このページに戻ってくるリンク.
        self.setFromPage(Defines.FromPages.HAPPENING, happeningset.id)
        BackendApi.put_bprecover_uselead_info(self)
        self.html_param['url_deck_raid'] = self.makeAppLinkUrl(
            UrlMaker.deck_raid())

        # デッキ情報.
        deckcardlist = self.getDeckCardList()
        self.putDeckParams(deckcardlist)

        self.execute_api()
        # if func_put_attacklog:
        #     func_put_attacklog()
        # if func_put_playerlist:
        #     func_put_playerlist()

        self.html_param['player'] = Objects.player(self, v_player)

        event_item_master = BackendApi.get_itemmaster(
            model_mgr, cur_eventmaster.useitem, using=settings.DB_READONLY)
        has_event_item_nums = BackendApi.get_item_nums(
            model_mgr, uid, [event_item_master.id], using=settings.DB_READONLY)
        if not has_event_item_nums:
            num = 0
        else:
            num = has_event_item_nums[event_item_master.id]
        self.html_param['event_item'] = {
            'name': event_item_master.name,
            'num': num
        }
        self.html_param['shop_url'] = self.makeAppLinkUrl(UrlMaker.shop())
        produce_score = ProduceEventScore.get_instance(
            model_mgr, uid, mid, using=settings.DB_READONLY)
        self.html_param['produce_eventscore'] = produce_score.to_dict()
        self.html_param['produce_rank'] = BackendApi.get_ranking_rank(
            ProduceEventRanking, mid, uid)

        self.writeHtml(cur_eventmaster, 'bossappear')
Exemplo n.º 18
0
    def process(self):

        # プレイヤー情報.
        v_player = self.getViewerPlayer()
        self.html_param['player'] = Objects.player(self, v_player)

        # ハプニング情報.
        self.putHappeningInfo()

        self.setFromPage(Defines.FromPages.HAPPENING)

        model_mgr = self.getModelMgr()
        cur_eventmaster = BackendApi.get_current_raideventmaster(
            model_mgr, using=settings.DB_READONLY)

        # 実行Url.
        happeningset = self.getHappening()
        eventid = HappeningUtil.get_raideventid(
            happeningset.happening.event) if happeningset else 0
        if happeningset and happeningset.happening.is_missed(
        ) and happeningset.happening.state != Defines.HappeningState.MISS:
            # 失敗した.
            if cur_eventmaster and cur_eventmaster.id == eventid:
                url = UrlMaker.raidresultanim(happeningset.id)
            else:
                self.writeHappeningMissed(happeningset.id)
                url = UrlMaker.happening()
            self.appRedirect(self.makeAppLinkUrl(url))
            return
        elif happeningset and not happeningset.happening.is_end():

            if happeningset.happening.is_cleared():
                # クリア済み.
                if cur_eventmaster and cur_eventmaster.id == eventid:
                    # イベントレイド.
                    url = UrlMaker.raidresultanim(happeningset.id)
                else:
                    url = UrlMaker.raidend(happeningset.id)
                self.appRedirect(self.makeAppLinkUrl(url, add_frompage=False))
                return
            elif eventid:
                if cur_eventmaster.id == eventid:
                    url = UrlMaker.raidevent_battlepre()
                    self.appRedirect(
                        self.makeAppLinkUrl(url, add_frompage=False))
                    return
                else:
                    # これはデバッグ中だけ起きる想定. ステータスは...メンテでいいかなぁ.
                    raise CabaretError(u'イベントの終了処理が終わっていません',
                                       CabaretError.Code.MAINTENANCE)
            else:
                # 救援要請.
                func_raidhelp_callback = self.putRaidHelpList(do_execute=False)

                raidboss = self.getRaidBoss()
                if raidboss:
                    # ダメージ履歴.
                    func_put_attacklog = self.putRaidAttackLog(raidboss)
                    # お助け.
                    func_put_playerlist = self.putHelpFriend(raidboss)

                    if func_raidhelp_callback or func_put_attacklog or func_put_playerlist:
                        self.execute_api()
                        if func_raidhelp_callback:
                            func_raidhelp_callback()
                        if func_put_attacklog:
                            func_put_attacklog()
                        if func_put_playerlist:
                            func_put_playerlist()

                    BackendApi.put_bprecover_uselead_info(self)

                    deckcardlist = self.getDeckCardList()
                    self.putDeckParams(deckcardlist)

                    url = UrlMaker.raiddo(raidboss.id, v_player.req_confirmkey)
                    htmlname = 'happening/bossappear'

                    self.html_param['url_exec_strong'] = self.makeAppLinkUrl(
                        OSAUtil.addQuery(url, Defines.URLQUERY_STRONG, 1))

                    self.html_param['url_deck_raid'] = self.makeAppLinkUrl(
                        UrlMaker.deck_raid())

                else:
                    if func_raidhelp_callback:
                        self.execute_api()
                        func_raidhelp_callback()
                    url = UrlMaker.happeningdo(v_player.req_confirmkey)
                    htmlname = 'happening/happening'
                self.html_param['url_exec'] = self.makeAppLinkUrl(url)
                self.html_param[
                    'url_happeningcancel_yesno'] = self.makeAppLinkUrl(
                        UrlMaker.happeningcancel_yesno())
        else:
            if cur_eventmaster is not None:
                # イベント.
                eventbanners = BackendApi.get_eventbanners(
                    self, using=settings.DB_READONLY)
                self.html_param['eventbanners'] = [
                    Objects.eventbanner(self, banner)
                    for banner in eventbanners
                ]

            # 救援要請.
            self.putRaidHelpList()
            htmlname = 'happening/happening_none'

        self.html_param['url_trade'] = self.makeAppLinkUrl(UrlMaker.trade(),
                                                           add_frompage=True)

        self.html_param['is_event_open'] = cur_eventmaster is not None

        self.writeAppHtml(htmlname)
Exemplo n.º 19
0
    def setUp(self):
        model_mgr = ModelRequestMgr()

        # Player.
        self.__player0 = self.create_dummy(DummyType.PLAYER)
        self.__player1 = 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)

        # イベントマスター.
        eventmaster = self.create_dummy(DummyType.SCOUT_EVENT_MASTER,
                                        lovetime_tanzakuup=100)
        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

        # 逢引ラブタイム状態にする.
        playdata = self.create_dummy(DummyType.SCOUT_EVENT_PLAY_DATA,
                                     self.__player0.id,
                                     self.__eventmaster.id,
                                     lovetime_etime=OSAUtil.get_now() +
                                     datetime.timedelta(days=1))
        self.__scoutevent_playdata = playdata

        # イベント発生中設定.
        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))

        # レイドマスター.
        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)
        self.__happeningmaster = happeningmaster

        # 短冊とキャストの情報.
        tanzaku_master = self.create_dummy(
            DummyType.SCOUT_EVENT_TANZAKU_CAST_MASTER,
            self.__eventmaster.id,
            0,
            prizes=[prize.id])
        self.__tanzaku_master = tanzaku_master

        # イベント用レイド設定.
        scouteventraidmaster = self.create_dummy(
            DummyType.SCOUT_EVENT_RAID_MASTER,
            self.__eventmaster.id,
            self.__raidmaster.id,
            tanzaku_number=tanzaku_master.number,
            tanzaku_randmin=10,
            tanzaku_randmax=10,
            tanzaku_help_number=tanzaku_master.number,
            tanzaku_help_randmin=3,
            tanzaku_help_randmax=3)
        self.__scouteventraidmaster = scouteventraidmaster

        # 短冊所持情報.
        tanzaku_nums = {tanzaku_master.number: 0}
        tanzaku_data = self.create_dummy(
            DummyType.SCOUT_EVENT_TANZAKU_CAST_DATA,
            self.__player1.id,
            self.__eventmaster.id,
            tanzaku_nums=tanzaku_nums)
        self.__tanzaku_data1 = tanzaku_data
        tanzaku_data = self.create_dummy(
            DummyType.SCOUT_EVENT_TANZAKU_CAST_DATA,
            self.__player0.id,
            self.__eventmaster.id,
            tanzaku_nums=tanzaku_nums)
        self.__tanzaku_data0 = tanzaku_data

        # ハプニング情報.
        eventvalue = HappeningUtil.make_scouteventvalue(self.__eventmaster.id)
        happening = self.create_dummy(DummyType.HAPPENING,
                                      self.__player0.id,
                                      self.__happeningmaster.id,
                                      progress=happeningmaster.execution,
                                      eventid=eventvalue)
        self.__happening = happening

        # レイド.
        raidboss = self.create_dummy(DummyType.RAID, self.__player0,
                                     happeningmaster, happening)
        raidboss.addDamageRecord(self.__player0.id, 1)
        raidboss.refrectDamageRecord()
        raidboss.raid.save()
        self.__raid = raidboss

        # 救援.
        def addRequest(v_player, o_player):
            model_mgr = ModelRequestMgr()
            BackendApi.tr_add_friendrequest(model_mgr, v_player, o_player)
            model_mgr.write_all()
            model_mgr.write_end()

        def addFriend(v_player, o_player):
            model_mgr = ModelRequestMgr()
            BackendApi.tr_add_friend(model_mgr, v_player.id, o_player.id)
            model_mgr.write_all()
            model_mgr.write_end()

        addRequest(self.__player0, self.__player1)
        addFriend(self.__player1, self.__player0)

        model_mgr = ModelRequestMgr()
        BackendApi.tr_send_raidhelp(model_mgr, self.__player0.id)
        model_mgr.write_all()
        model_mgr.write_end()

        raidboss.addDamageRecord(self.__player1.id, 1)
        raidboss.refrectDamageRecord()
        raidboss.raid.save()

        self.__player0.gold = 0
        self.__player0.getModel(PlayerGold).save()

        self.__player0.cardlimititem = 100
        self.__player0.getModel(PlayerDeck).save()

        self.__playerhappening = BackendApi.get_playerhappening(
            model_mgr, self.__player0.id)

        self.__present_num0 = BackendApi.get_present_num(self.__player0.id)
        self.__present_num1 = BackendApi.get_present_num(self.__player1.id)
Exemplo n.º 20
0
    def procResult(self, args):
        """ボス戦結果.
        """
        model_mgr = self.getModelMgr()

        v_player = self.getViewerPlayer()

        raidbattle = BackendApi.get_raid_battleresult(
            model_mgr, v_player.id, using=settings.DB_READONLY)
        if raidbattle is None:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'想定外の遷移です')
            url = UrlMaker.happening()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # レイド情報を取得.
        raidboss = BackendApi.get_raid(model_mgr,
                                       raidbattle.raidid,
                                       using=settings.DB_READONLY)
        if raidboss is None:
            raise CabaretError(u'超太客が存在しません', CabaretError.Code.NOT_DATA)

        animdata = raidbattle.process

        raidboss.raid.hp = animdata.bossHpPost
        if raidboss.raid.hp < 1:
            url = UrlMaker.raidend(raidbattle.raidid)
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # 借りたカード.
        func_put_playerlist = None
        helpleadercard = raidbattle.getHelpCard()
        if helpleadercard:
            cardmaster = BackendApi.get_cardmasters(
                [helpleadercard.mid], model_mgr,
                using=settings.DB_READONLY).get(helpleadercard.mid)
            helpleader = CardSet(helpleadercard, cardmaster)
            func_put_playerlist = self.putPlayerListByLeaderList(
                raidbattle.raidid, [helpleader])

        # 与えたダメージ.
        self.html_param['damage'] = animdata.bossDamage
        specialcard_powup = getattr(animdata, 'specialcard_powup', 0)
        str_specialcard_powup = None
        if 0 < specialcard_powup:
            str_specialcard_powup = '+%s' % specialcard_powup
        elif specialcard_powup < 0:
            str_specialcard_powup = '%s' % specialcard_powup
        self.html_param['specialcard_powup'] = str_specialcard_powup

        # 属性ボーナス.
        weak_powup = getattr(animdata, 'weak_powup', 0)
        str_weak_powup = None
        if 0 < weak_powup:
            str_weak_powup = '+%s' % weak_powup
        elif weak_powup < 0:
            str_weak_powup = '%s' % weak_powup
        self.html_param['weak_powup'] = str_weak_powup

        # 発動したスキル.
        self.html_param['skilllist'] = animdata.make_html_skilllist()

        # プレイヤー情報.
        self.html_param['player'] = Objects.player(self, v_player)

        # 救援のUrl(フレンド).
        url = UrlMaker.raidhelpsend()
        self.html_param['url_helpsend'] = self.makeAppLinkUrl(url)
        self.html_param['url_helpsend_other'] = self.makeAppLinkUrl(
            OSAUtil.addQuery(url, Defines.URLQUERY_FLAG, "1"))

        # ハプニング情報.
        happeningset = BackendApi.get_happening(model_mgr,
                                                raidboss.id,
                                                using=settings.DB_READONLY)
        func_happeninginfo_callback = self.putHappeningInfo(happeningset,
                                                            raidboss,
                                                            do_execute=False)

        func_put_attacklog = None

        is_event = False
        raideventmaster = None
        eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
        if eventid:
            raideventmaster = BackendApi.get_raideventmaster(
                model_mgr, eventid, using=settings.DB_READONLY)

        if raideventmaster:
            # イベント情報.
            config = BackendApi.get_current_raideventconfig(
                model_mgr, using=settings.DB_READONLY)
            self.html_param['raidevent'] = Objects.raidevent(
                self, raideventmaster, config)

            # ダメージ履歴.
            func_put_attacklog = self.putRaidAttackLog(raidboss)

            # イベント用の設定.
            eventraidmaster = BackendApi.get_raidevent_raidmaster(
                model_mgr,
                raideventmaster.id,
                raidboss.raid.mid,
                using=settings.DB_READONLY)
            BackendApi.put_raidevent_specialcard_info(
                self, v_player.id, eventraidmaster, using=settings.DB_READONLY)

            url = OSAUtil.addQuery(
                UrlMaker.gacha(), Defines.URLQUERY_CTYPE,
                Defines.GachaConsumeType.GachaTopTopic.TICKET)
            self.html_param['url_gacha_event'] = self.makeAppLinkUrl(url)

            self.html_param['url_raidevent_top'] = self.makeAppLinkUrl(
                UrlMaker.raidevent_top(raideventmaster.id))

            is_event = True

        # 戻るUrl.
        if raidboss.raid.oid == v_player.id:
            # 発見者.
            if is_event:
                url = UrlMaker.raidevent_battlepre()
            else:
                url = UrlMaker.happening()
        else:
            # 救援者.
            url = UrlMaker.raidhelpdetail(raidboss.raid.id)
        self.html_param['url_return'] = self.makeAppLinkUrl(url,
                                                            add_frompage=False)

        # デッキ情報.
        deckcardlist = self.getDeckCardList()
        self.__putDeckParams(deckcardlist)

        self.execute_api()
        func_happeninginfo_callback()

        if func_put_playerlist:
            func_put_playerlist()

        if func_put_attacklog:
            func_put_attacklog()

        eventid = HappeningUtil.get_raideventid(happeningset.happening.event)
        self.writeHtmlSwitchEvent('bosslose',
                                  eventid,
                                  eventmaster=raideventmaster)
Exemplo n.º 21
0
    def process(self):
        def to_i(v):
            if str(v).isdigit():
                return int(v)
            else:
                return None

        serchtype = self.request.get('_serchtype')
        value = self.request.get('_value')
        page = (to_i(self.request.get('_page')) or 0)

        model_mgr = self.getModelMgr()
        raid_all = dict([
            (master.id, master) for master in model_mgr.get_mastermodel_all(
                RaidMaster, fetch_deleted=True, using=settings.DB_READONLY)
        ])
        event_all = dict([(
            master.id, master
        ) for master in model_mgr.get_mastermodel_all(
            RaidEventMaster, fetch_deleted=True, using=settings.DB_READONLY)])

        uid = None
        if serchtype == 'uid':
            uid = to_i(value)
        elif serchtype == 'dmmid':
            uid = BackendApi.dmmid_to_appuid(
                self, [value], using=settings.DB_READONLY).get(value)

        if uid:
            PAGE_CONTENT_NUM = 100

            filters = {
                'uid': uid,
            }
            nummax = RaidLog.count(filters, using=settings.DB_READONLY)
            page_max = (nummax + PAGE_CONTENT_NUM - 1) / PAGE_CONTENT_NUM

            offset = page * PAGE_CONTENT_NUM
            raidloglist = RaidLog.fetchValues(filters=filters,
                                              order_by='-ctime',
                                              limit=PAGE_CONTENT_NUM,
                                              offset=offset,
                                              using=settings.DB_READONLY)
            raididlist = [raidlog.raidid for raidlog in raidloglist]
            recorddict = BackendApi.get_model_dict(model_mgr,
                                                   Raid,
                                                   raididlist,
                                                   using=settings.DB_READONLY)
            happeningdict = BackendApi.get_model_dict(
                model_mgr, Happening, raididlist, using=settings.DB_READONLY)

            raidlist = []
            for raidlog in raidloglist:
                happening = happeningdict.get(raidlog.raidid)
                record = recorddict.get(raidlog.raidid)
                raidboss = None
                eventmaster = None

                if record and happening:
                    master = raid_all.get(record.mid)
                    if master:
                        raidevent_id = HappeningUtil.get_raideventid(
                            happening.event)
                        eventmaster = event_all.get(raidevent_id)
                        eventraidmaster = None
                        if eventmaster:
                            eventraidmaster = BackendApi.get_raidevent_raidmaster(
                                model_mgr, raidevent_id, master.id)
                        raidboss = RaidBoss(record, master, eventraidmaster)

                if raidboss:
                    point = 0
                    eventdata = None
                    is_champagne_call = False
                    champagne_num_add = 0
                    champagne_num_post = 0
                    material = 0
                    if eventmaster:
                        if raidboss.hp < 1:
                            fastbonusdata = BackendApi.get_raidevent_fastbonusdata(
                                eventmaster, raidboss, happening.etime)
                            rate = 1
                            if fastbonusdata:
                                rate = fastbonusdata['rate']
                            if happening.oid == uid:
                                point += raidboss.get_owner_eventpoint()
                            else:
                                point += raidboss.getHelpEventPoints(uid).get(
                                    uid, 0)
                            if uid in raidboss.getMVPList():
                                point += raidboss.get_mvp_eventpoint()
                            point = point * rate

                        record = raidboss.getDamageRecord(uid)
                        is_champagne_call = record.champagne
                        champagne_num_add = record.champagne_num_add
                        champagne_num_post = record.champagne_num_post
                        material = record.material_num

                        eventdata = {
                            'id': eventmaster.id,
                            'name': eventmaster.name,
                        }

                    raidlist.append({
                        'id':
                        raidboss.id,
                        'mid':
                        raidboss.master.id,
                        'name':
                        '%s%s' %
                        (raidboss.master.name,
                         u'[イベ]' if raidboss.raideventraidmaster else ''),
                        'level':
                        raidboss.raid.level,
                        'ctime':
                        DateTimeUtil.dateTimeToStr(raidboss.raid.ctime),
                        'url':
                        self.makeAppLinkUrlAdmin(
                            UrlMaker.view_raid(raidboss.id)),
                        'point':
                        point,
                        'eventdata':
                        eventdata,
                        'is_champagne_call':
                        is_champagne_call,
                        'champagne_num_add':
                        champagne_num_add,
                        'champagne_num_post':
                        champagne_num_post,
                        'material':
                        material,
                    })
                else:
                    raidlist.append({
                        'id':
                        raidlog.raidid,
                        'mid':
                        record.mid if record else 0,
                        'name':
                        master.name if master else u'不明',
                        'level':
                        record.level if record else 0,
                        'ctime':
                        DateTimeUtil.dateTimeToStr(record.ctime)
                        if record else u'不明',
                        'url':
                        None,
                        'point':
                        0,
                        'eventdata':
                        None,
                    })

            url = UrlMaker.view_raidlog()
            url = OSAUtil.addQuery(url, '_serchtype', serchtype)
            url = OSAUtil.addQuery(url, '_value', value)

            def __makePage(index):
                return {
                    'num':
                    index,
                    'url':
                    self.makeAppLinkUrlAdmin(
                        OSAUtil.addQuery(url, '_page', index - 1)),
                }

            pagination_data = {
                'page_list': [__makePage(p) for p in xrange(1, page_max + 1)],
                'now_page': __makePage(page + 1),
                'has_next': False,
                'has_prev': False,
            }
            if page < page_max:
                pagination_data['next_page'] = __makePage(page + 1)
                pagination_data['has_next'] = True
            if 1 < page:
                pagination_data['prev_page'] = __makePage(page - 1)
                pagination_data['has_prev'] = True
            self.html_param['pagination'] = pagination_data

            self.html_param['raidlist'] = raidlist

        self.html_param['serchtype'] = serchtype
        self.html_param['value'] = value

        self.html_param['url_view_raidlog'] = self.makeAppLinkUrlAdmin(
            UrlMaker.view_raidlog())

        self.writeAppHtml('infomations/view_raid/log')
Exemplo n.º 22
0
 def putHappeningInfo(self):
     """ハプニングとレイドの発生チェック.
     """
     model_mgr = self.getModelMgr()
     cur_eventmaster = BackendApi.get_current_raideventmaster(model_mgr, using=settings.DB_READONLY)
     
     v_player = self.getViewerPlayer()
     # 自分の.
     cur_happeningset = BackendApi.get_current_happening(model_mgr, v_player.id, using=settings.DB_READONLY)
     if cur_happeningset and not cur_happeningset.happening.is_end():
         is_event = cur_eventmaster and cur_eventmaster.id == HappeningUtil.get_raideventid(cur_happeningset.happening.event)
         happeninginfo = None
         timellimit = None
         if cur_happeningset.happening.is_cleared():
             # クリア済み.
             happeninginfo = 'cleared'
             if is_event:
                 url = UrlMaker.raidresultanim(cur_happeningset.happening.id)
             else:
                 url = UrlMaker.raidend(cur_happeningset.happening.id)
             self.__news_num += 1
         elif cur_happeningset.happening.is_boss_appeared():
             # レイド発生中.
             happeninginfo = 'bossappeared'
             if is_event:
                 url = UrlMaker.raidevent_battlepre()
             else:
                 url = UrlMaker.happening()
             timellimit = Objects.timelimit(cur_happeningset.happening.etime, OSAUtil.get_now())
         else:
             # ハプニング中.
             happeninginfo = 'open'
             url = UrlMaker.happening()
             timellimit = Objects.timelimit(cur_happeningset.happening.happening.etime, OSAUtil.get_now())
         self.html_param['happeninginfo'] = {
             'info' : happeninginfo,
             'timelimit' : timellimit,
             'url' : self.makeAppLinkUrl(url),
             'is_event' : is_event,
         }
     
     # 救援.
     helpnum = BackendApi.get_raidhelp_num(model_mgr, v_player.id, using=settings.DB_READONLY, nummax=Defines.RAIDHELP_LIST_MAXLENGTH)
     if cur_eventmaster:
         url = None
         if 0 < helpnum:
             raidhelpidlist = BackendApi.get_raidhelpidlist(model_mgr, v_player.id, limit=min(5, helpnum), offset=0, using=settings.DB_READONLY)
             if raidhelpidlist:
                 raidhelplist = BackendApi.get_raidhelplist(model_mgr, raidhelpidlist, using=settings.DB_READONLY)
                 helpnum = len(raidhelplist)
                 if helpnum == 1:
                     url = UrlMaker.raidhelpdetail(raidhelplist[0].raidid)
             else:
                 helpnum = 0
         if url is None:
             url = OSAUtil.addQuery(UrlMaker.raidevent_helplist(), Defines.URLQUERY_FLAG, '_mypage')
         is_event_opened = True
     else:
         url = UrlMaker.happening()
         is_event_opened = False
     self.html_param['raidhelpnuminfo'] = {
         'num' : helpnum,
         'url' : self.makeAppLinkUrl(url),
     }
     self.html_param['is_event_opened'] = is_event_opened
     
     # 救援成功通知.
     if BackendApi.get_raidlog_notification_num(v_player.id):
         # 救援成功したらしい.
         self.html_param['raidhelp_notification'] = True
         self.__news_num += 1