Пример #1
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)
Пример #2
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)
Пример #3
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_producehappeningraidset(
                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.
        eventvalue = happeningraidset.happening.happening.event

        produceeventid = HappeningUtil.get_produceeventid(eventvalue)
        score = 0

        champagne = None
        if produceeventid:
            produceeventmaster = BackendApi.get_current_produce_event_master(
                model_mgr, using=settings.DB_READONLY)
            raidmaster = raidboss.produceeventraidmaster
            champagne = None

        # 書き込み.
        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.producehappening()
                    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
Пример #4
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.producehappening()
            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.produceraidend(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_producehappening(
            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
        produceeventmaster = None
        eventid = HappeningUtil.get_produceeventid(
            happeningset.happening.event)
        if eventid:
            produceeventmaster = BackendApi.get_produce_event_master(
                model_mgr, eventid, using=settings.DB_READONLY)

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

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

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

            self.html_param['url_produceevent_top'] = self.makeAppLinkUrl(
                UrlMaker.produceevent_top(produceeventmaster.id))

            is_event = True

        # 戻るUrl.
        if raidboss.raid.oid == v_player.id:
            # 発見者.
            if is_event:
                url = UrlMaker.produceevent_battlepre()
            else:
                url = UrlMaker.producehappening()
        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_produceeventid(
            happeningset.happening.event)
        self.writeHtmlSwitchEvent('bosslose',
                                  eventid,
                                  eventmaster=produceeventmaster)
Пример #5
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)
Пример #6
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)
Пример #7
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')