Esempio n. 1
0
    def process(self):
        v_player = self.getViewerPlayer()
        model_mgr = self.getModelMgr()

        # 合成結果.
        evolutiondata = BackendApi.get_evolutiondata(
            model_mgr, v_player.id, using=settings.DB_READONLY)

        # ベースカード.
        basecardset = BackendApi.get_cards([evolutiondata.result_baseid],
                                           model_mgr,
                                           using=settings.DB_READONLY)
        if not basecardset:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'ハメ管理したキャストが見つかりません.')
            url = UrlMaker.evolution()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return
        basecardset = basecardset[0]
        self.html_param['basecard_post'] = Objects.card(self, basecardset)

        pre_master = BackendApi.get_cardmasters(
            [evolutiondata.mid], model_mgr,
            using=settings.DB_READONLY).get(evolutiondata.mid)
        if pre_master is None or (pre_master.albumhklevel +
                                  1) != basecardset.master.albumhklevel:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'ハメ管理前のキャストが見つかりません.')
            url = UrlMaker.evolution()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return
        pre_card = copy(basecardset.card)
        evolutiondata.set_to_card(pre_card)
        pre_cardset = CardSet(pre_card, pre_master)
        self.html_param['basecard_pre'] = Objects.card(self, pre_cardset)

        # 素材カード.
        materialcard = BackendApi.get_cards([evolutiondata.result_materialid],
                                            model_mgr,
                                            using=settings.DB_READONLY,
                                            deleted=True)
        if not materialcard:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'ハメ管理に使用したキャストが見つかりません.')
            url = UrlMaker.evolution()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return
        self.html_param['materialcard'] = Objects.card(self, materialcard[0])

        self.writeAppHtml('evolution/complete')
Esempio n. 2
0
    def process(self):
        args = self.getUrlArgs('/evolutiondo/')
        try:
            if settings_sub.IS_BENCH:
                requestkey = OSAUtil.makeSessionID()
            else:
                self.__baseid = int(args.get(0))
                self.__materialid = self.getMaterialId()
                requestkey = urllib.unquote(args.get(1))
        except:
            raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS)

        v_player = self.getViewerPlayer()

        try:
            model_mgr = db_util.run_in_transaction(Handler.tr_write, v_player,
                                                   self.__baseid,
                                                   self.__materialid,
                                                   requestkey)
            model_mgr.write_end()
        except CabaretError, e:
            if e.code == CabaretError.Code.ALREADY_RECEIVED:
                pass
            else:
                if settings_sub.IS_LOCAL:
                    raise CabaretError(u'合成できませんでした.%s' %
                                       CabaretError.getCodeString(e.code))
                url = UrlMaker.evolution()
                self.appRedirect(self.makeAppLinkUrlRedirect(url))
                return
Esempio n. 3
0
 def __makePrizeGetLinkParamEvolution(self, itype, iid):
     dress = 40003
     bag = 40002
     necklace = 40001
     if iid in (dress, bag, necklace):
         return self.__makePrizeGetLinkParamComposition(itype, iid)
     else:
         return self.__makePrizeGetLinkParam(UrlMaker.evolution(),
                                             u'ハメ管理する')
Esempio n. 4
0
 def checkBaseCard(self, basecard):
     v_player = self.getViewerPlayer()
     if basecard is None or basecard.card.uid != v_player.id or not basecard.is_can_evolution:
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'不正なキャストです.%d' % basecard.id)
         url = UrlMaker.evolution()
         self.appRedirect(self.makeAppLinkUrlRedirect(url))
         return False
     return True
Esempio n. 5
0
 def checkMaterialCard(self, basecard, materialcard, deck):
     v_player = self.getViewerPlayer()
     if materialcard is None or materialcard.id == basecard.id or materialcard.card.protection or deck.is_member(
             materialcard.id) or basecard.card.uid != v_player.id:
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'ハメ管理に選択できないキャストです.',
                                CabaretError.Code.ILLEGAL_ARGS)
         url = UrlMaker.evolution()
         self.appRedirect(self.makeAppLinkUrlRedirect(url))
         return False
     return True
Esempio n. 6
0
    def process(self):
        v_player = self.getViewerPlayer()
        model_mgr = self.getModelMgr()

        # 合成結果.
        evolutiondata = BackendApi.get_evolutiondata(
            model_mgr, v_player.id, using=settings.DB_READONLY)

        # 進化後カード.
        basecardset = BackendApi.get_cards([evolutiondata.result_baseid],
                                           model_mgr,
                                           using=settings.DB_READONLY)
        if not basecardset:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'ハメ管理したキャストが見つかりません.')
            url = UrlMaker.evolution()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return
        basecardset = basecardset[0]

        # ベースカード.
        pre_master = BackendApi.get_cardmasters(
            [evolutiondata.mid], model_mgr,
            using=settings.DB_READONLY).get(evolutiondata.mid)
        if pre_master is None or (pre_master.albumhklevel +
                                  1) != basecardset.master.albumhklevel:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'ハメ管理前のキャストが見つかりません.')
            url = UrlMaker.evolution()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        # 素材カード.
        materialcard = BackendApi.get_cards([evolutiondata.result_materialid],
                                            model_mgr,
                                            using=settings.DB_READONLY,
                                            deleted=True)
        if not materialcard:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'ハメ管理に使用したキャストが見つかりません.')
            url = UrlMaker.evolution()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return
        materialcard = materialcard[0]

        miniImg = {}
        endText2 = None
        endText3 = None
        # 文言.
        endText = Defines.EffectTextFormat.EVOLUTION_ENDTEXT % (
            basecardset.master.name, basecardset.master.hklevel - 1,
            evolutiondata.result_takeover)
        if evolutiondata.result_flag_memories_open:
            movie = False
            memories_list = BackendApi.get_album_memories_list(
                self,
                v_player.id,
                basecardset.master.album,
                using=settings.DB_READONLY)

            if memories_list:
                cnt = 0
                for memories in memories_list:
                    if memories.get(
                            'cardid'
                    ) != basecardset.master.id or not memories.get('is_new'):
                        continue
                    elif memories.get(
                            'contenttype') == Defines.MemoryContentType.MOVIE:
                        movie = True
                    if cnt < 2:
                        cnt += 1
                        miniImg['miniCard%d' % cnt] = memories['thumbUrl']

            endText2 = Defines.EffectTextFormat.EVOLUTION_ENDTEXT2 % basecardset.master.maxlevel

            # 思い出アルバム開放.
            if movie:
                endText3 = Defines.EffectTextFormat.EVOLUTION_ENDTEXT3_MOVIE
            else:
                endText3 = Defines.EffectTextFormat.EVOLUTION_ENDTEXT3_MEMORIES

        params = {
            'card1':
            self.makeAppLinkUrlImg(
                CardUtil.makeThumbnailUrlMiddle(pre_master)),
            'card2':
            self.makeAppLinkUrlImg(
                CardUtil.makeThumbnailUrlMiddle(materialcard.master)),
            'mixCard':
            self.makeAppLinkUrlImg(
                CardUtil.makeThumbnailUrlMiddle(basecardset.master)),
            'startText':
            Defines.EffectTextFormat.EVOLUTION_STARTTEXT,
            'endText':
            endText,
            'backUrl':
            self.makeAppLinkUrl(UrlMaker.evolutionresult()),
        }
        if endText2:
            params['endText2'] = endText2
        if endText3:
            params['endText3'] = endText3
        params.update(**miniImg)
        self.appRedirectToEffect('gousei/effect.html', params)
Esempio n. 7
0
 def makeUrlSelf(self):
     return UrlMaker.evolution()
Esempio n. 8
0
 def _getJumpUrlEvolutionRing(self, missionmaster):
     return UrlMaker.evolution()