Beispiel #1
0
 def process(self):
     args = self.getUrlArgs('/scoutcardgetresult/')
     try:
         scoutid = int(args.get(0))
     except:
         raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS)
     
     v_player = self.getViewerPlayer()
     model_mgr = self.getModelMgr()
     
     using = settings.DB_READONLY
     
     # 進行情報.
     playdata = BackendApi.get_scoutprogress(model_mgr, v_player.id, [scoutid], using=using).get(scoutid, None)
     target_event = BackendApi.find_scout_event(playdata, Defines.ScoutEventType.GET_CARD)
     
     if target_event is None:
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'女の子を発見していません')
         url = self.makeAppLinkUrlRedirect(UrlMaker.scout())
         self.appRedirect(url)
         return
     elif not target_event.is_received:
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'まだ女の子をスカウトしていません')
         url = self.makeAppLinkUrlRedirect(UrlMaker.scoutresult(scoutid, playdata.alreadykey))
         self.appRedirect(url)
         return
     
     # プレイヤー.
     self.html_param['player'] = Objects.player(self, v_player)
     
     # 獲得したカード.
     cardmaster = BackendApi.get_cardmasters([target_event.card], arg_model_mgr=model_mgr, using=using).get(target_event.card)
     card = BackendApi.create_card_by_master(cardmaster)
     cardset = CardSet(card, cardmaster)
     self.html_param['card'] = Objects.card(self, cardset, is_new=target_event.is_new)
     
     # スカウト.
     arr = BackendApi.get_scouts(model_mgr, [scoutid], using=using)
     scoutmaster = arr[0] if arr else None
     self.html_param['scout'] = self.makeScoutObj(scoutmaster, playdata)
     
     # スカウト結果.
     resultlist = playdata.result.get('result', [])
     self.html_param['scoutresultinfo'] = BackendApi.make_scoutresult_info(resultlist)
     
     # レイドイベント.
     BackendApi.put_raidevent_champagnedata(self, v_player.id)
     
     if target_event.is_success:
         if target_event.autosell:
             # 自動退店.
             self.html_param['autosell'] = target_event.autosell
             self.html_param['_gold_add'] = target_event.sellprice
             self.html_param['_ckt'] = getattr(target_event, 'sellprice_treasure', 0)
         
         self.writeAppHtml('scout/cardgetresult_success')
     else:
         self.writeAppHtml('scout/cardgetresult_failed')
Beispiel #2
0
    def procYesno(self):
        """タイプ選択確認.
        """
        v_player = self.__getViewerPlayer()
        if v_player is None:
            return
        ptype = self.getSelectedType()
        if ptype is None:
            return

        model_mgr = self.getModelMgr()
        leader = BackendApi.get_defaultleaders(
            model_mgr,
            Defines.CharacterType.NAMES.keys(),
            using=settings.DB_READONLY).get(ptype)
        if leader:
            cardset = CardSet(BackendApi.create_card_by_master(leader), leader)
            self.html_param['leader'] = Objects.card(self, cardset)
        self.html_param['ptype'] = ptype
        self.html_param['is_first'] = self.__args.get(2) == '1'
        self.html_param['url_write'] = self.makeAppLinkUrl(
            UrlMaker.regist_write(ptype))
        self.html_param['url_back'] = self.makeAppLinkUrl(
            UrlMaker.regist_select())

        self.setTutorialHead(Defines.TutorialStatus.REGIST_SELECT)

        self.writeAppHtml('regist/yesno')
Beispiel #3
0
 def get(prefix):
     deck = []
     for i in xrange(Defines.DECK_CARD_NUM_MAX):
         mid = self.request.get(
             KEY_FORMAT.format(prefix=prefix, number=i, param='mid'))
         if mid:
             mid = int(mid)
             level = int(
                 self.request.get(
                     KEY_FORMAT.format(prefix=prefix,
                                       number=i,
                                       param='level')))
             takeover = int(
                 self.request.get(
                     KEY_FORMAT.format(prefix=prefix,
                                       number=i,
                                       param='takeover')))
             skilllevel = int(
                 self.request.get(
                     KEY_FORMAT.format(prefix=prefix,
                                       number=i,
                                       param='skilllevel')))
             cardmaster = BackendApi.get_cardmasters(
                 [mid], model_mgr, using=settings.DB_READONLY).get(mid)
             card = self.createDummyCard(cardmaster)
             card.level = max(1, min(cardmaster.maxlevel, level))
             card.takeover = max(0, takeover)
             card.skilllevel = max(
                 1, min(Defines.SKILLLEVEL_MAX, skilllevel))
             deck.append(CardSet(card, cardmaster))
     return deck
Beispiel #4
0
 def procGetCard(self, mid, stagemaster, playdata, event):
     """カード獲得.
     """
     if event.is_received:
         # 終了済み.
         if settings_sub.IS_LOCAL:
             raise CabaretError(u'判定済みです', CabaretError.Code.ALREADY_RECEIVED)
         self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.scouteventcardgetresult(stagemaster.id)))
         return
     
     model_mgr = self.getModelMgr()
     
     # 獲得したカード.
     cardid = event.card
     cardmaster = BackendApi.get_cardmasters([cardid], model_mgr, using=settings.DB_READONLY).get(cardid)
     if cardmaster is None:
         raise CabaretError(u'一度公開されたキャストが非公開にされました.危険です.', CabaretError.Code.INVALID_MASTERDATA)
     card = BackendApi.create_card_by_master(cardmaster)
     self.html_param['card'] = Objects.card(self, CardSet(card, cardmaster), is_new=event.is_new)
     self.html_param['silhouette'] = event.silhouette
     
     # 獲得判定へ飛ぶ.
     url = UrlMaker.scouteventcardget(stagemaster.id)
     self.html_param['url_exec'] = self.makeAppLinkUrl(url)
     
     # アイテム.
     BackendApi.put_scoutcard_uselead_info(self, UrlMaker.scouteventcardget(stagemaster.id))
     
     self.html_param['num_key'] = Defines.URLQUERY_NUMBER
     
     self.writeScoutEventHTML('cardget', self.eventmaster)
Beispiel #5
0
 def process(self):
     args = self.getUrlArgs('/evolutionyesno/')
     try:
         self.__baseid = int(args.get(0))
         self.__materialid = self.getMaterialId()
     except:
         raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS)
     
     v_player = self.getViewerPlayer()
     model_mgr = self.getModelMgr()
     
     # ベースカード.
     basecard = BackendApi.get_cards([self.__baseid], model_mgr, using=settings.DB_READONLY)
     basecard = basecard[0] if len(basecard) else None
     if not self.checkBaseCard(basecard):
         return
     evolmaster = BackendApi.get_evolution_cardmaster(model_mgr, basecard.master, using=settings.DB_READONLY)
     if evolmaster is None:
         raise CabaretError(u'ハメ管理後のキャストが設定されていません.', CabaretError.Code.INVALID_MASTERDATA)
     
     self.html_param['basecard'] = Objects.card(self, basecard)
     self.__basecard = basecard
     
     # プレイヤー情報.
     self.html_param['player'] = Objects.player(self, v_player)
     
     # デッキ情報.
     deck = BackendApi.get_deck(v_player.id, model_mgr, using=settings.DB_READONLY)
     basecard_post = CardSet(basecard.card, evolmaster)
     cost_over, deck_none = BackendApi.check_evol_deckcost(model_mgr, v_player, basecard_post, using=settings.DB_READONLY)
     self.html_param['deckcapacity_over'] = cost_over
     self.html_param['deck_none'] = deck_none
     
     # 素材カード.
     materialcard = BackendApi.get_cards([self.__materialid], model_mgr, using=settings.DB_READONLY)
     materialcard = materialcard[0] if len(materialcard) else None
     if not self.checkMaterialCard(basecard, materialcard, deck):
         return
     self.html_param['materialcard'] = Objects.card(self, materialcard)
     self.__materialcard = materialcard
     
     # 消費ゴールド.
     cost = evolmaster.evolcost
     self.html_param['cost'] = cost
     self.html_param['cost_over'] = v_player.gold < cost
     self.html_param['gold_post'] = v_player.gold - cost
     
     self.html_param['cardnum'] = BackendApi.get_cardnum(v_player.id, model_mgr, using=settings.DB_READONLY)
     
     BackendApi.get_evolutiondata(model_mgr, v_player.id, using=settings.DB_READONLY)
     
     # 書き込みへのURL.
     url = UrlMaker.evolutiondo(self.__baseid, v_player.req_confirmkey)
     self.html_param['url_do'] = self.makeAppLinkUrl(OSAUtil.addQuery(url, Defines.URLQUERY_CARD, self.__materialcard.id))
     
     self.writeAppHtml('evolution/yesno')
Beispiel #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]
        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')
Beispiel #7
0
    def procDecide(self):
        """タイプ選択完了.
        """
        v_player = self.getViewerPlayer()
        if v_player.tutorialstate != Defines.TutorialStatus.REGIST_COMPLETE:
            self.redirectToTop()
            return
        ptype = v_player.ptype

        model_mgr = self.getModelMgr()
        leader = BackendApi.get_defaultleaders(
            model_mgr,
            Defines.CharacterType.NAMES.keys(),
            using=settings.DB_READONLY).get(ptype)
        if leader:
            cardset = CardSet(BackendApi.create_card_by_master(leader), leader)
            self.html_param['leader'] = Objects.card(self, cardset)
        self.html_param['ptype'] = ptype
        self.html_param['url_enter'] = self.makeAppLinkUrl(UrlMaker.tutorial())

        self.setTutorialHead(Defines.TutorialStatus.REGIST_COMPLETE)

        self.writeAppHtml('regist/decide')
Beispiel #8
0
    def handle(self, *args, **options):
        
        print '================================'
        print 'recov_takeover'
        print '================================'
        
        is_update = 0 < len(args) and args[0] == 'update'
        
        # 修正対象のcardidのリスト.
        if settings_sub.IS_DEV:
            tmp_cards = Card.fetchValues(filters={'mid__gte': 23203, 'mid__lte': 23205})
            TARGET_CARDID_LIST = [card.id for card in tmp_cards]
        else:
            tmp_cards = Card.fetchValues(filters={'mid__gte': 23203, 'mid__lte': 23205})
            TARGET_CARDID_LIST = [card.id for card in tmp_cards]

            # TARGET_CARDID_LIST = (
            #     243554710460995,
            #     259875586181903,
            #     264149078647399,
            #     267898585091933,
            #     289150083275628,
            #     303770151954557,
            #     326108276855142,
            #     2370821955526,
            #     59785944768327,
            #     97268124365984,
            #     164467182686565,
            #     191985038136826,
            #     207399675767609,
            #     207399675767612,
            #     226937481993457,
            #     253566279230399,
            #     298779399950377,
            #     326348795024926,
            #     407317518485754,
            #     425957676551555,
            # )
        # 対象のキャストが本番で公開された時間.
        CTIME_MIN = DateTimeUtil.strToDateTime('201603181400', "%Y%m%d%H%M")
        
        model_mgr = ModelRequestMgr()

        for cardid in TARGET_CARDID_LIST:
            # カードを取得.
            card = Card.getByKey(cardid)
            if card is None:
                print '%s...None' % cardid
                continue
            cardmaster = BackendApi.get_cardmasters([card.mid], model_mgr).get(card.mid)
            
            # このカードのハメ管理履歴を絞り込み.
            log_dict = {}
            for model in UserLogEvolution.fetchValues(filters={'uid':card.uid,'ctime__gte':CTIME_MIN}, order_by='ctime'):
                if cardid == model.data['material']['id']:
                    print '%s...material' % cardid
                    break
                elif cardid != model.data['base']['id']:
                    continue
                log_dict[model.data['base']['mid']] = model
            
            midlist = BackendApi.get_cardmasterid_by_albumhklevel(model_mgr, cardmaster.album)
            masters = dict([(model.hklevel, model) for model in BackendApi.get_cardmasters(midlist, model_mgr).values()])
            
            tmp_basecard = None
            for hklevel in xrange(1, cardmaster.hklevel):
                basemaster = masters[hklevel]
                logdata = log_dict[basemaster.id]
                
                tmp_basecard = CardSet(tmp_basecard.card if tmp_basecard else Card.makeInstance(cardid), basemaster)
                tmp_basecard.card.mid = basemaster.id
                tmp_basecard.card.level = logdata.data['base']['level']
                
                takeover = tmp_basecard.get_evolution_takeover()
                takeover *= 2
                tmp_basecard.card.takeover += takeover
            
            if card.takeover == tmp_basecard.card.takeover:
                print '%s...equal' % cardid
                continue
            
            if is_update:
                def tr(cardid, master, takeover):
                    card = Card.getByKeyForUpdate(cardid)
                    if master.id != card.mid:
                        # これは危険.
                        raise CabaretError()
                    
                    model_mgr = ModelRequestMgr()
                    card.takeover = takeover;
                    model_mgr.set_save(card)
                    
                    def writeEnd():
                        BackendApi.save_cardidset(CardSet(card, master))
                    model_mgr.add_write_end_method(writeEnd)
                    model_mgr.write_all()
                    
                    return model_mgr
                try:
                    db_util.run_in_transaction(tr, tmp_basecard.id, cardmaster, tmp_basecard.card.takeover).write_end()
                except CabaretError:
                    print '%s...danger' % cardid
                    continue
            print '%s...update %s=>%s' % (cardid, card.takeover, tmp_basecard.card.takeover)
        
        print '================================'
        print 'all done..'
Beispiel #9
0
 def writeEnd():
     BackendApi.save_cardidset(CardSet(card, master))
Beispiel #10
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)
Beispiel #11
0
            model_mgr, v_player.id, using=settings.DB_READONLY)
        specialcard_powup = None

        if raidbattle is not None and raidbattle.raidid == raidid:
            animdata = raidbattle.process
            if animdata and animdata.winFlag:
                damage = animdata.bossDamage
                skilllist = animdata.make_html_skilllist()
                # 借りたカード.
                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])
                # デッキ情報.
                deckcardlist = self.getDeckCardList()
                self.__putDeckParams(deckcardlist)

                specialcard_powup = getattr(animdata, 'specialcard_powup',
                                            None)

        self.html_param['skilllist'] = skilllist
        self.html_param['damage'] = damage
        str_specialcard_powup = None
        if specialcard_powup is not None:
            if 0 < specialcard_powup:
                str_specialcard_powup = '+%s' % specialcard_powup
Beispiel #12
0
    def process(self):
        args = self.getUrlArgs('/sceventcardgetresult/')
        try:
            stageid = int(args.get(0))
        except:
            raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS)

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

        using = settings.DB_READONLY

        eventmaster = BackendApi.get_current_scouteventmaster(model_mgr,
                                                              using=using)
        if eventmaster is None:
            raise CabaretError(u'Event Closed.',
                               CabaretError.Code.EVENT_CLOSED)
        mid = eventmaster.id

        # 進行情報.
        playdata = BackendApi.get_event_playdata(model_mgr, mid, v_player.id,
                                                 using)
        target_event = BackendApi.find_scout_event(
            playdata, Defines.ScoutEventType.GET_CARD)

        if target_event is None:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'女の子を発見していません')
            url = self.makeAppLinkUrlRedirect(UrlMaker.scoutevent())
            self.appRedirect(url)
            return
        elif not target_event.is_received:
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'まだ女の子をスカウトしていません')
            url = self.makeAppLinkUrlRedirect(
                UrlMaker.scouteventresult(stageid, playdata.alreadykey))
            self.appRedirect(url)
            return

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

        # 獲得したカード.
        cardmaster = BackendApi.get_cardmasters([target_event.card],
                                                arg_model_mgr=model_mgr,
                                                using=using).get(
                                                    target_event.card)
        card = BackendApi.create_card_by_master(cardmaster)
        cardset = CardSet(card, cardmaster)
        self.html_param['card'] = Objects.card(self,
                                               cardset,
                                               is_new=target_event.is_new)

        # ステージ.
        arr = BackendApi.get_event_stages(model_mgr, [stageid], using=using)
        stagemaster = arr[0] if arr else None
        self.html_param['scout'] = self.makeStageObj(stagemaster, playdata,
                                                     stagemaster.stage)

        # フィーバー
        self.html_param['scouteventfever'] = Objects.scoutevent_fever(playdata)

        # スカウト結果.
        resultlist = playdata.result.get('result', [])
        self.html_param['scoutresultinfo'] = BackendApi.make_scoutresult_info(
            resultlist)

        # イベントポイント
        self.putEventPoint(mid, v_player.id, playdata)

        config = BackendApi.get_current_scouteventconfig(
            model_mgr, using=settings.DB_READONLY)
        obj_scouteventmaster = Objects.scouteventmaster(
            self, eventmaster, config)
        self.html_param['scoutevent'] = obj_scouteventmaster

        if target_event.is_success:
            if target_event.autosell:
                # 自動退店.
                self.html_param['autosell'] = target_event.autosell
                self.html_param['_gold_add'] = target_event.sellprice
                self.html_param['_ckt'] = getattr(target_event,
                                                  'sellprice_treasure', 0)

            self.writeScoutEventHTML('cardgetresult_success', eventmaster)
        else:
            self.writeScoutEventHTML('cardgetresult_failed', eventmaster)
Beispiel #13
0
    def process(self):
        args = self.getUrlArgs('/gacharesult/')
        try:
            mid = int(args.get(0))
            key = urllib.unquote(args.get(1))
            code = int(args.get(2) or 0)
        except:
            raise CabaretError(u'引数が想定外です', CabaretError.Code.ILLEGAL_ARGS)
        self.set_masterid(mid)

        self.__now = OSAUtil.get_now()

        v_player = self.getViewerPlayer()

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

        if code != 0:
            # エラーで引抜できなかった.
            self.procGachaError(code)
            return

        if v_player.req_alreadykey != key:
            # 結果が見当たらない.
            if settings_sub.IS_LOCAL:
                raise CabaretError(u'結果を出せない')
            url = UrlMaker.gacha()
            self.appRedirect(self.makeAppLinkUrlRedirect(url))
            return

        gachamaster = self.getGachaMaster()
        playdata = self.getGachaPlayData()
        model_mgr = self.getModelMgr()

        CONTENT_NUM_PER_PAGE = 10
        PAGING_CONTENT_NUM = CONTENT_NUM_PER_PAGE + 2

        # 獲得したカード.
        resultlist = playdata.result['result'] if isinstance(
            playdata.result, dict) else playdata.result

        if PlayerCrossPromotion.is_session(
        ):  # if we are in a cross promotion event
            self.ssr_card_crosspromotion(v_player, resultlist)

        result_num = len(resultlist)
        page = int(self.request.get(Defines.URLQUERY_PAGE) or 0)
        if PAGING_CONTENT_NUM < result_num:
            # 結果が多いのでページング.
            url = UrlMaker.gacharesult(mid, key, code)
            self.putPagenation(url, page, result_num, CONTENT_NUM_PER_PAGE)

            start = page * CONTENT_NUM_PER_PAGE
            end = start + CONTENT_NUM_PER_PAGE
            self.html_param['is_paging'] = True
        else:
            start = 0
            end = result_num

        cardidlist = [data['id'] for data in resultlist[start:end]]
        cardmasters = BackendApi.get_cardmasters(cardidlist,
                                                 model_mgr,
                                                 using=settings.DB_READONLY)
        obj_cardlist = []
        point_single = 0
        sellprice_total = 0
        sellprice_treasure_total = 0
        sell_num = 0
        for idx, data in enumerate(resultlist):
            point = data['point']
            obj_card = None
            if start <= idx < end:
                master = cardmasters[data['id']]
                card = BackendApi.create_card_by_master(master)
                cardset = CardSet(card, master)
                obj_card = Objects.card(self, cardset, is_new=data['is_new'])
                obj_card['point'] = point
                obj_cardlist.append(obj_card)
            sellprice = data.get('sellprice', 0)
            sellprice_treasure = data.get('sellprice_treasure', 0)
            point_single += point
            if data.get('autosell'):
                if obj_card:
                    obj_card['autosell'] = True
                    obj_card['sellprice'] = sellprice
                    obj_card['sellprice_treasure'] = sellprice_treasure
                sell_num += 1
                sellprice_total += sellprice
                sellprice_treasure_total += sellprice_treasure

        point_total = 0
        if gachamaster.consumetype == Defines.GachaConsumeType.RANKING:
            rankingmaster = BackendApi.get_rankinggacha_master(
                model_mgr, gachamaster.boxid, using=settings.DB_READONLY)
            if rankingmaster and rankingmaster.is_support_totalranking:
                point_total = BackendApi.get_rankinggacha_total_score(
                    playdata.mid, v_player.id)
        elif gachamaster.consumetype == Defines.GachaConsumeType.SR_SSR_PROBABILITY_UP or gachamaster.consumetype == Defines.GachaConsumeType.PTCHANGE:
            #トレードショップが開いていたら
            if gachamaster.trade_shop_master_id is not None and 0 < gachamaster.trade_shop_master_id:
                try:
                    lottery_point = int(args.get(3))
                except:
                    raise CabaretError(u'引数が想定外です',
                                       CabaretError.Code.ILLEGAL_ARGS)
                self.html_param['lottery_point'] = lottery_point
                self.html_param[
                    'user_point'] = BackendApi.get_tradeshop_userpoint(
                        model_mgr, v_player.id)

        if gachamaster.consumetype in {
                Defines.GachaConsumeType.FIXEDSR,
                Defines.GachaConsumeType.STEPUP,
                Defines.GachaConsumeType.STEPUP2
        } and 0 < gachamaster.rarity_fixed_num:
            if page == 0:
                self.html_param['is_rarity_fixed'] = True
                self.html_param[
                    'rarity_fixed_cardlist'] = obj_cardlist[:gachamaster.
                                                            rarity_fixed_num]
                self.html_param['cardlist'] = obj_cardlist[gachamaster.
                                                           rarity_fixed_num:]
            else:
                self.html_param['is_rariry_fixed'] = False
                self.html_param['rarity_fixed_cardlist'] = obj_cardlist
                self.html_param['cardlist'] = obj_cardlist
        else:
            self.html_param['cardlist'] = obj_cardlist

        self.html_param['gacha_result_unique_name'] = gachamaster.unique_name
        self.html_param['point_single'] = point_single
        self.html_param['point_total'] = point_total
        self.html_param['_card_num'] = sell_num
        self.html_param['_gold_add'] = sellprice_total
        self.html_param['_ckt'] = sellprice_treasure_total
        self.html_param['url_tradeshop'] = self.makeAppLinkUrl(
            UrlMaker.tradeshop())
        # 引き抜きガチャチケット消費数.
        self.html_param['gacha_ticket_cost'] = Defines.GACHA_TICKET_COST_NUM

        # 開催中のガチャ情報.
        topic = Defines.GachaConsumeType.TO_TOPIC.get(gachamaster.consumetype)
        self.putOpenGachaList(topic, gachamaster)

        # シート情報.
        seatinfo = BackendApi.make_gachaseatinfo(self,
                                                 v_player.id,
                                                 gachamaster,
                                                 result=True,
                                                 using=settings.DB_READONLY)
        self.html_param['gachaseatinfo'] = seatinfo

        # おまけ等.
        omakelist = []
        if seatinfo and seatinfo['last']:
            omakelist.append(
                '%s%s' %
                (seatinfo['last']['name'], seatinfo['last']['numtext']))
        if isinstance(playdata.result, dict) and playdata.result.get('omake'):
            prizelist = BackendApi.get_prizelist(model_mgr,
                                                 playdata.result['omake'],
                                                 using=settings.DB_READONLY)
            presentlist = BackendApi.create_present_by_prize(
                model_mgr,
                v_player.id,
                prizelist,
                0,
                using=settings.DB_READONLY,
                do_set_save=False)
            presentsetlist = PresentSet.presentToPresentSet(
                model_mgr, presentlist, using=settings.DB_READONLY)
            for presentset in presentsetlist:
                omakelist.append(
                    '%s%s' % (presentset.itemname, presentset.numtext_with_x))
        self.html_param['omakelist'] = omakelist

        seatPlayData = self.__get_seatPlayData_only_firstRound_and_last(
            model_mgr, v_player.id, gachamaster)
        if seatPlayData:
            for i, seat in enumerate(seatinfo["list"]):
                if seat == None:
                    continue
                if i == seatPlayData.last:
                    seat["last"] = True
                else:
                    seat["last"] = False
            itemhash = seatinfo["list"][seatPlayData.last]
            omakelist[0] = '%s%s' % (itemhash['name'], itemhash['numtext'])

        boxgachaprizes = []
        # 条件付きリセット可能BOXガチャの引き切り報酬
        if gachamaster.consumetype in {
                Defines.GachaConsumeType.LIMITED_RESET_BOX,
                Defines.GachaConsumeType.EVENTTICKET
        }:
            boxgacha = GachaBox(gachamaster, playdata)
            if boxgacha.is_empty:
                boxdetail = model_mgr.get_model(GachaBoxGachaDetailMaster,
                                                gachamaster.id,
                                                using=settings.DB_READONLY)
                prizelist = BackendApi.get_prizemaster_list(
                    model_mgr, boxdetail.prizelist)
                presentlist = BackendApi.create_present_by_prize(
                    model_mgr,
                    v_player.id,
                    prizelist,
                    0,
                    using=settings.DB_READONLY,
                    do_set_save=False)
                presentsetlist = PresentSet.presentToPresentSet(
                    model_mgr, presentlist, using=settings.DB_READONLY)
                for presentset in presentsetlist:
                    boxgachaprizes.append(
                        '%s%s' %
                        (presentset.itemname, presentset.numtext_with_x))
                self.html_param['boxgachaprizes'] = boxgachaprizes
        # ガチャ確率 UP の場合最後に引いたガチャをサジェストする
        if gachamaster.consumetype in {
                Defines.GachaConsumeType.SR_SSR_PROBABILITY_UP,
                Defines.GachaConsumeType.FIXEDSR,
                Defines.GachaConsumeType.PTCHANGE,
                Defines.GachaConsumeType.NEWSTORE_SUPPORT_PREMIUM
        }:
            self.put_gacha_probability(gachamaster)

        self.html_param['explain_text'] = self.html_param["gachadata"].values(
        )[0]['explain_text']
        self.writeAppHtml('gacha/result')
Beispiel #14
0
    def setUpCabaclub(self, player, now=None):
        now = now or OSAUtil.get_now()
        etime = BackendApi.to_cabaretclub_section_starttime(now)

        uid = player.id
        # カード.
        cardlist = []
        for _ in xrange(5):
            cardmaster = self.create_dummy(DummyType.CARD_MASTER, cost=1)
            cardmaster = BackendApi.get_cardmasters([cardmaster.id
                                                     ]).get(cardmaster.id)
            cardlist.append(
                CardSet(self.create_dummy(DummyType.CARD, player, cardmaster),
                        cardmaster))
        # マスターデータを用意.
        # 報酬.
        prize = self.create_dummy(DummyType.PRIZE_MASTER, gold=100)
        # キャバクラシステム.
        cabaclubmaster = self.create_dummy(DummyType.CABA_CLUB_MASTER,
                                           customer_prizes=[[prize.id, 10000]],
                                           customer_prize_interval=100)
        # 店舗とイベント.
        stores = {}
        events = {}
        storeplayerdata = {}
        for ua_type in (Defines.CabaClubEventUAType.LIVEN_UP,
                        Defines.CabaClubEventUAType.TAKE_MEASURES):
            # イベント.
            events[ua_type] = self.create_dummy(
                DummyType.CABA_CLUB_EVENT_MASTER,
                seconds=Defines.CABARETCLUB_STORE_EVENT_INTERVAL,
                customer_up=150,
                proceeds_up=200,
                ua_type=ua_type,
                ua_value=40,
                ua_cost=100)
            # 店舗.
            stores[ua_type] = self.create_dummy(
                DummyType.CABA_CLUB_STORE_MASTER,
                days=7,
                cost=100,
                customer_interval=600,
                customer_max=99999999,
                cast_num_max=5,
                scoutman_num_max=10,
                scoutman_add_max=10,
                events=[[events[ua_type].id, 10000]])
            # 店舗情報.
            storeplayerdata[ua_type] = self.create_dummy(
                DummyType.CABA_CLUB_STORE_PLAYER_DATA,
                uid,
                stores[ua_type].id,
                ltime=now + datetime.timedelta(days=7),
                etime=now,
                utime=now)
        # 特別なマネー.
        scoredata = self.create_dummy(DummyType.CABA_CLUB_SCORE_PLAYER_DATA,
                                      uid,
                                      money=200)
        # 週間スコア情報.
        scoredata_weekly = self.create_dummy(
            DummyType.CABA_CLUB_SCORE_PLAYER_DATA_WEEKLY, uid, etime=etime)
        # 前の週の週間スコア情報.
        scoredata_weekly_prev = self.create_dummy(
            DummyType.CABA_CLUB_SCORE_PLAYER_DATA_WEEKLY,
            uid,
            etime=etime - datetime.timedelta(days=7),
            view_result=True)
        return self.CabaClubDummy(now, etime, cardlist, cabaclubmaster, stores,
                                  events, storeplayerdata, scoredata,
                                  scoredata_weekly, scoredata_weekly_prev)