def _get_carddata(self, cardmaster, skillmaster=None): thumb = CardUtil.makeThumbnailUrlIcon(cardmaster) thumb_middle = CardUtil.makeThumbnailUrlMiddle(cardmaster) icon = self.makeAppLinkUrlImg( Defines.CharacterType.ICONS[cardmaster.ctype]) rare = { 'str': Defines.Rarity.NAMES.get(cardmaster.rare), 'color': Defines.Rarity.COLORS.get(cardmaster.rare, '#ffffff') } if isinstance(skillmaster, SkillMaster): skillname = skillmaster.name skilltext = skillmaster.text else: skillname = None skilltext = None return self._dataformat(name=cardmaster.name, thumb=thumb, thumb_middle=thumb_middle, kind=cardmaster.ckind, iconUrl=icon, rare=rare, skillname=skillname, skilltext=skilltext, basepower=cardmaster.basepower, cost=cardmaster.cost)
def create(power, power_default, cardlist, skilllist, damage, hppre, hppost, hpmax, critical, specialcard_idlist=None, friendcard=None, sppowup=None, weakpowup=None): ins = BossBattleAnimParam() # 勝利フラグ. ins.winFlag = hppost < 1 # 接客力とか. ins.power = power ins.power_default = power_default ins.specialcard_powup = sppowup ins.weak_powup = weakpowup # ボス. ins.bossHpPre = hppre ins.bossHpPost = hppost ins.bossHpMax = hpmax ins.bossDamage = damage # カード. leader = cardlist[0] ins.leader = { 'id': leader.id, 'data': CardUtil.makeThumbnailUrlMiddle(leader.master), } for cardset in cardlist[1:]: ins.memberlist.append({ 'id': cardset.id, 'data': CardUtil.makeThumbnailUrlIcon(cardset.master), }) if friendcard: ins.memberlist.append({ 'id': friendcard.id, 'data': CardUtil.makeThumbnailUrlIcon(friendcard.master), 'friend': True, }) # スキル. ins.skilllist = skilllist[:] ins.specialcard_idlist = specialcard_idlist or [] return ins
def create(p_sale, e_sale, p_cardsetList, e_cardsetList, p_skillinfolist, e_skillinfolist, feverFlag): ins = BattleAnimParam() # 売上. ins.pSale = p_sale ins.eSale = e_sale # カード. for ins_cardlist, cardsetlist in ((ins.pCard, p_cardsetList), (ins.eCard, e_cardsetList)): for cardset in cardsetlist: ins_cardlist.append({ 'id': cardset.id, 'data': CardUtil.makeThumbnailUrlMiddle(cardset.master), }) # スキル. ins.pSkill = p_skillinfolist[:] ins.eSkill = e_skillinfolist[:] # フィーバー. ins.feverFlag = feverFlag return ins
def process(self): args = self.getUrlArgs('/transferreturncomplete/') mid = args.getInt(0) num = args.getInt(1) or 0 model_mgr = self.getModelMgr() cardmaster = None if mid: cardmaster = BackendApi.get_cardmasters( [mid], arg_model_mgr=model_mgr, using=settings.DB_READONLY).get(mid) if cardmaster is None or not CardUtil.checkStockableMaster( cardmaster, raise_on_error=False): raise CabaretError(u'不正な遷移です.', CabaretError.Code.ILLEGAL_ARGS) # アルバムへのリンク. self.html_param['url_albumdetail'] = self.makeAppLinkUrl( UrlMaker.albumdetail(cardmaster.album)) # カード情報. self.html_param['cardmaster'] = Objects.cardmaster(self, cardmaster) # 呼び戻した数. self.html_param['cardnum'] = num self.writeAppHtml('card/transferreturncomplete')
def process(self): v_player = self.getViewerPlayer() model_mgr = self.getModelMgr() args = self.getUrlArgs('/transferreturn/') try: num = int(self.request.get(Defines.URLQUERY_NUMBER, None)) mid = args.getInt(0) confirmkey = urllib.unquote(args.get(1) or '') except: raise CabaretError(u'不正なアクセスです.', CabaretError.Code.ILLEGAL_ARGS) cardmaster = BackendApi.get_cardmasters( [mid], model_mgr, using=settings.DB_READONLY).get(mid) if cardmaster is None or not CardUtil.checkStockableMaster( cardmaster, raise_on_error=True): raise CabaretError(u'不正なアクセスです', CabaretError.Code.ILLEGAL_ARGS) try: wrote_model_mgr = db_util.run_in_transaction( Handler.tr_write, v_player.id, cardmaster, num, confirmkey) wrote_model_mgr.write_end() except CabaretError, err: if err.code == CabaretError.Code.ALREADY_RECEIVED: pass elif err.code in (CabaretError.Code.OVER_LIMIT, CabaretError.Code.NOT_ENOUGH): # 枠がいっぱいまたはストックが足りない. url = UrlMaker.albumdetail(cardmaster.album) url = OSAUtil.addQuery(url, Defines.URLQUERY_ERROR, err.code) self.appRedirect(self.makeAppLinkUrlRedirect(url)) return else: raise
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)
def load(self, apphandler): """表示用に必要な情報をロード. """ key = 'GreetLog:fromid:%s' % self.id key_comment = 'GreetLogComment:fromid:%s' % self.id def cb(ret_data, *args, **kwargs): try: person = ret_data[key].get() self.params['dmmid'] = person.id self.params['username'] = person.nickname except: self.params['dmmid'] = '' self.params['username'] = u'****' self.params['url'] = apphandler.makeAppLinkUrl( UrlMaker.profile(self.fromid)) # Personとか欲しいはず. request = self.makePersonApiRequest(apphandler) apphandler.addAppApiRequest(key, request, cb) # サムネ. model_mgr = apphandler.getModelMgr() deck = model_mgr.get_model(Deck, self.fromid, using=settings.DB_READONLY) leader = model_mgr.get_model(Card, deck.leader, using=settings.DB_READONLY) master = model_mgr.get_model(CardMaster, leader.mid, using=settings.DB_READONLY) self.params['thumbUrl'] = apphandler.makeAppLinkUrlImg( CardUtil.makeThumbnailUrlIcon(master)) if self.commenttextid != '': def cb_comment(ret_data, *args, **kwargs): try: result = ret_data[key_comment].get() if len(result) == 1: status = result[0].status data = result[0].data self.params['comment'] = data else: self.params['comment'] = u'' except: self.params['comment'] = u'********' data = InspectionGetRequestData() data.textId = self.commenttextid request = apphandler.osa_util.makeApiRequest( ApiNames.InspectionGet, data) apphandler.addAppApiRequest(key_comment, request, cb_comment) else: self.params['comment'] = u''
def proc_EVOL00_ANIM(self, basecard, materialcard): """ハメ管理合成アニメーション. """ model_mgr = self.getModelMgr() params = { 'card1': self.makeAppLinkUrlImg( CardUtil.makeThumbnailUrlMiddle(basecard.master)), 'card2': self.makeAppLinkUrlImg( CardUtil.makeThumbnailUrlMiddle(materialcard.master)), 'startText': Defines.EffectTextFormat.EVOLUTION_STARTTEXT, 'backUrl': self.makeAppLinkUrl(self.makeUrlNext()), } basecard_post, _ = BackendApi.tutorial_evolution( model_mgr, basecard, materialcard, using=settings.DB_READONLY) params['mixCard'] = self.makeAppLinkUrlImg( CardUtil.makeThumbnailUrlMiddle(basecard_post.master)) params['endText'] = Defines.EffectTextFormat.EVOLUTION_ENDTEXT % ( basecard_post.master.name, basecard_post.master.hklevel - 1, basecard_post.card.takeover) params[ 'endText2'] = Defines.EffectTextFormat.EVOLUTION_ENDTEXT2 % basecard_post.master.maxlevel params['endText3'] = Defines.EffectTextFormat.EVOLUTION_ENDTEXT3_MOVIE v_player = self.getViewerPlayer(True) mid = basecard_post.master.id if self.is_pc: memoriesmaster = BackendApi.get_tutorial_pcmemories( model_mgr, v_player.ptype, using=settings.DB_READONLY) else: memoriesmaster = BackendApi.get_tutorial_memories( model_mgr, v_player.ptype, using=settings.DB_READONLY) card_acquisition = CardAcquisition.makeInstance( CardAcquisition.makeID(basecard_post.card.uid, mid)) obj_memories = Objects.memoriesmaster(self, memoriesmaster, card_acquisition) params['miniCard1'] = obj_memories['thumbUrl'] self.appRedirectToEffect('gousei/effect.html', params)
def _get_card(self, model_mgr, tradeshopitemmaster): carddict = BackendApi.get_cardmasters([tradeshopitemmaster.itemid], model_mgr, using=settings.DB_READONLY) card = carddict.get(tradeshopitemmaster.itemid) thumb = CardUtil.makeThumbnailUrlIcon(card) icon = self.makeAppLinkUrlImg(Defines.CharacterType.ICONS[card.ctype]) rare = { 'str': Defines.Rarity.NAMES.get(card.rare), 'color': Defines.Rarity.COLORS.get(card.rare, '#ffffff') } next_url = UrlMaker.tradeshopyesno(tradeshopitemmaster.id) return self._dataformat(tradeshopitemmaster, card.name, thumb, kind=card.ckind, iconUrl=icon, rare=rare, next_url=next_url)
def procCard(self, filter_json, page): """カード画像確認. """ PAGE_CONTENT_NUM = 50 offset = page * PAGE_CONTENT_NUM nummax = CardMasterView.count(filters=filter_json, using=settings.DB_READONLY) pagemax = int((nummax + PAGE_CONTENT_NUM - 1) / PAGE_CONTENT_NUM) titles = ( u'ID', u'キャスト', u'thumbの値', u'Card_thumb_52_52.png', u'Card_thumb_60_75.png', u'Card_thumb_110_138.png', u'Card_thumb_320_400.png', u'Card_thumb_320_314.png', u'Card_thumb_70_88.png', ) cardmasterlist = CardMasterView.fetchValues(filters=filter_json, order_by='id', limit=PAGE_CONTENT_NUM, offset=offset, using=settings.DB_READONLY) datalist = [] for cardmaster in cardmasterlist: row = [ cardmaster.id, cardmaster.name, cardmaster.thumb, (self.makeAppImgUrl(CardUtil.makeThumbnailUrlIcon(cardmaster)), 52, 52), (self.makeAppImgUrl( CardUtil.makeThumbnailUrlSmall(cardmaster)), 60, 75), (self.makeAppImgUrl( CardUtil.makeThumbnailUrlMiddle(cardmaster)), 110, 138), (self.makeAppImgUrl( CardUtil.makeThumbnailUrlLarge(cardmaster)), 320, 400), (self.makeAppImgUrl( CardUtil.makeThumbnailUrlBustup(cardmaster)), 320, 314), ] if cardmaster.rare in Defines.Rarity.EVOLUTION_ABLES: row.append((self.makeAppImgUrl( CardUtil.makeThumbnailUrlMemory(cardmaster)), 70, 88)) else: row.append('') datalist.append(row) self.putData(titles, datalist) url = OSAUtil.addQuery(UrlMaker.view_images(), '_target', 'Card') url = OSAUtil.addQuery(url, '_filter', urllib.quote(self.html_param['_filter'], '')) self.putPagenationData(url, page, pagemax)
def itemthumbnail_rect_middle(self): if self.__imaster and self.present.itype in (Defines.ItemType.CARD, Defines.ItemType.ITEM): if self.present.itype == Defines.ItemType.CARD: return CardUtil.makeThumbnailUrlIcon(self.__imaster) else: return ItemUtil.makeThumbnailUrlMiddle(self.__imaster) elif self.__imaster and self.present.itype == Defines.ItemType.EVENT_GACHATICKET: return ItemUtil.makeThumbnailUrlMiddleByDBString( self.__imaster.ticketthumb) elif self.__imaster and self.present.itype == Defines.ItemType.SCOUTEVENT_TANZAKU: return self.__imaster.tanzakuthumb elif self.present.itype == Defines.ItemType.ADDITIONAL_GACHATICKET: return ItemUtil.makeThumbnailUrlMiddleByDBString( Defines.GachaConsumeType.GachaTicketType.THUMBNAIL[ self.present.ivalue]) else: return ItemUtil.makeThumbnailUrlMiddleByType(self.present.itype)
def process(self): model_mgr = self.getModelMgr() uid = self.getViewerPlayer().id args = self.getUrlArgs('/battleeventbattlepiecepresent/') eventid = args.getInt(0) rarity = args.getInt(1) piecenumber = args.getInt(2) is_complete = args.getInt(3) if is_complete: piecemaster_list = BackendApi.get_battleevent_piecemaster( model_mgr, eventid, using=settings.DB_READONLY) piece_dir = BackendApi.get_battleevent_piecemaster_instance( rarity, piecemaster_list).name codename = BattleEventMaster.getByKey(eventid).codename piece_path = 'event/btevent/%s/%s/piece_complete.png' % (codename, piece_dir) effectpath = 'btevent/piece_complete/effect.html' mid = BackendApi.get_userdata_piece_complete_prize_cardid( uid, eventid, rarity) master = BackendApi.get_cardmasters([mid]).get(mid) url = UrlMaker.battleevent_battleresult(eventid, rarity, piecenumber) params = { 'backUrl': self.makeAppLinkUrl(url), 'pre': self.url_static_img, 'card': CardUtil.makeThumbnailUrlLarge(master), 'piece': piece_path, 'bg': 'event/btevent/%s/bg_piececomplete.png' % codename } self.appRedirectToEffect(effectpath, params) else: url = UrlMaker.battleevent_battleresult(eventid, rarity, piecenumber) self.appRedirect(self.makeAppLinkUrlRedirect(url))
def handle(self, *args, **options): print '================================' print 'aggregate_deckmember' print '================================' # 出力先. path = OSAUtil.get_now().strftime(args[0]) # 書き込むデータをここに溜め込む. writer = Command.Writer(path) # 対象を更新. LoginTimeCloneSet.update() # アクティブユーザだと判定される日数. now = OSAUtil.get_now() border_date = now - datetime.timedelta(days=Defines.ACTIVE_DAYS) LIMIT = 300 model_mgr = ModelRequestMgr() cardmasters = dict([(master.id, master) for master in model_mgr.get_mastermodel_all(CardMaster, fetch_deleted=True, using=backup_db)]) cardsortmasters = dict([(master.id, master) for master in model_mgr.get_mastermodel_all(CardSortMaster, fetch_deleted=True, using=backup_db)]) # ヘッダ列. title = [u'ユーザID'] for _ in xrange(Defines.DECK_CARD_NUM_MAX): title.extend([u'name', u'rare', u'hklevel', u'level', u'power']) for rare in Defines.Rarity.LIST: title.append(Defines.Rarity.NAMES[rare]) writer.add(','.join(title)) del title offset = 0 while True: uidlist = LoginTimeCloneSet.fetchByRange(border_date, now, LIMIT, offset) # デッキ取得. decklist = Deck.getByKey(uidlist, using=backup_db) for deck in decklist: row = [] raremap = {} # カード取得. cardidlist = deck.to_array() cards = dict([(card.id, card) for card in Card.getByKey(cardidlist, using=backup_db)]) # ユーザID. row.append(str(deck.id)) for cardid in cardidlist: card = cards.get(cardid) master = None sortmaster = None if card: master = cardmasters.get(card.mid) sortmaster = cardsortmasters.get(card.mid) if card is None or master is None or sortmaster is None: name = u'不明' rare = u'不明' hklevel = u'不明' level = u'不明' power = u'不明' else: # カード名. name = str(master.name) # レア度. rare = str(sortmaster.rare) # ハメ管理度. hklevel = str(sortmaster.hklevel) # レベル. level = str(card.level) # 接客力. power = str(CardUtil.calcPower(master.gtype, master.basepower, master.maxpower, card.level, master.maxlevel, card.takeover)) raremap[sortmaster.rare] = raremap.get(sortmaster.rare, 0) + 1 row.extend([name, rare, hklevel, level, power]) for _ in xrange(Defines.DECK_CARD_NUM_MAX - len(cardidlist)): row.extend(['', '', '', '', '']) for rare in Defines.Rarity.LIST: row.append(str(raremap.get(rare, 0))) line = ','.join(row) writer.add(line) offset += LIMIT if len(uidlist) < LIMIT: break writer.output(overwrite=False) print '================================' print 'all done..'
def process(self): v_player = self.getViewerPlayer() model_mgr = self.getModelMgr() try: cardidlist = [] for i in xrange(Defines.BOX_PAGE_CONTENT_NUM): str_cardid = self.request.get( '%s%s' % (Defines.URLQUERY_CARD, i), None) if str_cardid and str_cardid.isdigit(): cardidlist.append(int(str_cardid)) str_cardidlist = self.request.get(Defines.URLQUERY_CARD, None) if str_cardidlist: cardidlist.extend([ int(str_cardid) for str_cardid in str_cardidlist.split(',') ]) if len(cardidlist) == 0: raise except: self.__writeError( CabaretError(u'不正なアクセスです', CabaretError.Code.ILLEGAL_ARGS)) return cardidlist = list(set(cardidlist)) cardlist = BackendApi.get_cards(cardidlist, model_mgr, using=settings.DB_READONLY) if len(cardlist) != len(cardidlist): self.__writeError( CabaretError(u'キャストが見つかりませんでした', CabaretError.Code.NOT_DATA)) return deck = BackendApi.get_deck(v_player.id, model_mgr, using=settings.DB_READONLY) raid_deck = BackendApi.get_raid_deck(v_player.id, model_mgr, using=settings.DB_READONLY) cardobjlist = [] # 成長したキャストを含んでいるか. include_growth = False # ハメ管理度が上がっているキャストを選んでいるか. include_hkincr_already = False url_base = UrlMaker.transferyesno() str_idlist = [] albumidlist = [] for cardset in cardlist: str_idlist.append(str(cardset.id)) albumidlist.append(cardset.master.album) # 現在のストック数. cur_stocknum_models = BackendApi.get_cardstocks( model_mgr, v_player.id, list(set(albumidlist)), using=settings.DB_READONLY) stocknums = {} def getStockNum(album): model = cur_stocknum_models.get(album) num = model.num if model else 0 return num + stocknums.get(album, 0) for cardset in cardlist: if not CardUtil.checkStockable( v_player.id, deck, cardset, raise_on_error=False) or raid_deck.is_member(cardset.id): self.__writeError( CabaretError(u'異動できないキャストが含まれています', CabaretError.Code.ILLEGAL_ARGS)) return elif Defines.ALBUM_STOCK_NUM_MAX <= getStockNum( cardset.master.album): # 何かチェックが漏れてここに来た. self.__writeError( CabaretError(u'異動上限を超えます', CabaretError.Code.OVER_LIMIT)) return album = cardset.master.album stocknums[album] = stocknums.get(album, 0) + 1 obj_card = Objects.card(self, cardset) tmp = str_idlist[:] tmp.remove(str(cardset.id)) if 0 < len(tmp): url = OSAUtil.addQuery(url_base, Defines.URLQUERY_CARD, ','.join(tmp)) else: url = UrlMaker.transfer() obj_card['url_remove'] = self.makeAppLinkUrl(url) cardobjlist.append(obj_card) include_growth = include_growth or 0 < cardset.card.exp include_hkincr_already = include_hkincr_already or 1 < cardset.master.hklevel self.html_param['cardlist'] = cardobjlist self.html_param['flag_include_growth'] = include_growth self.html_param['flag_include_hkincr_already'] = include_hkincr_already url = UrlMaker.transferdo(v_player.req_confirmkey) url = OSAUtil.addQuery(url, Defines.URLQUERY_CARD, ','.join(str_idlist)) self.html_param['url_transferdo'] = self.makeAppLinkUrl(url) self.writeAppHtml('card/transferyesno')
def process(self): args = self.getUrlArgs('/albumdetail/') try: albumid = int(args.get(0, None)) hklevel = int(self.request.get(Defines.URLQUERY_HKEVEL) or 1) except: raise CabaretError(u'リクエストが正しくありません', CabaretError.Code.ILLEGAL_ARGS) model_mgr = self.getModelMgr() # プレイヤー情報. v_player = self.getViewerPlayer() if not BackendApi.check_album_viewable( model_mgr, v_player.id, albumid, using=settings.DB_READONLY): if settings_sub.IS_LOCAL: raise CabaretError(u'閲覧できません') self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.album())) return # カード詳細情報取得. cardmasteridlist = BackendApi.get_albumcardmasteridlist( model_mgr, albumid, using=settings.DB_READONLY) if not cardmasteridlist: if settings_sub.IS_LOCAL: raise CabaretError(u'閲覧できません') self.appRedirect(self.makeAppLinkUrlRedirect(UrlMaker.album())) return cardmaster_dict = BackendApi.get_cardmasters( cardmasteridlist, model_mgr, using=settings.DB_READONLY) cardmasteridlist.sort() obj_card_list = [] obj_card = None cur_cardmaster = None if 1 < len(cardmasteridlist): urlbase = UrlMaker.albumdetail(albumid) cardacquisitions = BackendApi.get_cardacquisitions( model_mgr, v_player.id, cardmasteridlist, using=settings.DB_READONLY) for cardmasterid in cardmasteridlist: if not cardacquisitions.get(cardmasterid): continue cardmaster = cardmaster_dict[cardmasterid] obj = Objects.cardmaster(self, cardmaster) obj['url'] = self.makeAppLinkUrl( OSAUtil.addQuery(urlbase, Defines.URLQUERY_HKEVEL, cardmaster.hklevel)) if obj_card is None or cardmaster.hklevel == hklevel: obj_card = obj cur_cardmaster = cardmaster obj_card_list.append(obj) self.html_param['cardmasterlist'] = obj_card_list self.html_param['cardmaster'] = obj_card first_cardmaster = cardmaster_dict[cardmasteridlist[0]] if cur_cardmaster is None: cardmasterid = first_cardmaster.id cur_cardmaster = first_cardmaster self.html_param['card'] = BackendApi.make_album_detail( self, v_player.id, cur_cardmaster, using=settings.DB_READONLY) # 思い出アルバムリストを取得. memories_list = [] movie_list = [] pcmovie_list = [] voice_list = [] for obj_memories in BackendApi.get_album_memories_list( self, v_player.id, albumid, using=settings.DB_READONLY): if obj_memories['contenttype'] == Defines.MemoryContentType.MOVIE: movie_list.append(obj_memories) elif obj_memories[ 'contenttype'] == Defines.MemoryContentType.MOVIE_PC: pcmovie_list.append(obj_memories) elif obj_memories[ 'contenttype'] == Defines.MemoryContentType.VOICE: voice_list.append(obj_memories) else: memories_list.append(obj_memories) # 異動数. if first_cardmaster and CardUtil.checkStockableMaster( first_cardmaster, raise_on_error=False): stocknum_model = BackendApi.get_cardstock( model_mgr, v_player.id, first_cardmaster.album, using=settings.DB_READONLY) stocknum = stocknum_model.num if stocknum_model else 0 self.html_param['stocknum'] = stocknum url = UrlMaker.transferreturn(first_cardmaster.id, v_player.req_confirmkey) self.html_param['url_transferreturn'] = self.makeAppLinkUrl(url) cardnum = BackendApi.get_cardnum(v_player.id, model_mgr, using=settings.DB_READONLY) self.html_param['cardnum'] = cardnum self.html_param['cardlimit'] = v_player.cardlimit self.html_param['memories_list'] = memories_list self.html_param['movie_list'] = movie_list self.html_param['pcmovie_list'] = pcmovie_list self.html_param['voice_list'] = voice_list # カード詳細情報. self.writeAppHtml('album/detail')
def process(self): v_player = self.getViewerPlayer() model_mgr = self.getModelMgr() try: cardidlist = [] for i in xrange(Defines.BOX_PAGE_CONTENT_NUM): str_cardid = self.request.get('%s%s' % (Defines.URLQUERY_CARD, i), None) if str_cardid and str_cardid.isdigit(): cardidlist.append(int(str_cardid)) str_cardidlist = self.request.get(Defines.URLQUERY_CARD, None) if str_cardidlist: cardidlist.extend([int(str_cardid) for str_cardid in str_cardidlist.split(',')]) if len(cardidlist) == 0: raise except: if settings_sub.IS_LOCAL: raise CabaretError(u'不正なアクセスです', CabaretError.Code.ILLEGAL_ARGS) url = UrlMaker.sell() self.appRedirect(self.makeAppLinkUrlRedirect(url)) return cardidlist = list(set(cardidlist)) cardlist = BackendApi.get_cards(cardidlist, model_mgr, using=settings.DB_READONLY) if len(cardlist) != len(cardidlist): raise CabaretError(u'キャストが見つかりませんでした', CabaretError.Code.NOT_DATA) deck = BackendApi.get_deck(v_player.id, model_mgr, using=settings.DB_READONLY) cardobjlist = [] sellprice_total = 0 sellprice_treasure_total = 0 # レアカードを含んでいるか. include_rare = False # ハメ管理度が上がっているカードを選んでいるか. include_hkincr_already = False url_base = UrlMaker.sellyesno() str_idlist = [str(cardset.id) for cardset in cardlist] for cardset in cardlist: is_rare, hkincr_already = CardUtil.checkSellable(v_player.id, deck, cardset) sellprice_total += cardset.sellprice sellprice_treasure_total += cardset.sellprice_treasure obj_card = Objects.card(self, cardset) tmp = str_idlist[:] tmp.remove(str(cardset.id)) if 0 < len(tmp): url = OSAUtil.addQuery(url_base, Defines.URLQUERY_CARD, ','.join(tmp)) else: url = UrlMaker.sell() obj_card['url_remove'] = self.makeAppLinkUrl(url) cardobjlist.append(obj_card) include_rare = include_rare or is_rare include_hkincr_already = include_hkincr_already or hkincr_already self.html_param['cardlist'] = cardobjlist self.html_param['sellprice'] = sellprice_total self.html_param['sellprice_treasure'] = sellprice_treasure_total if 0 < sellprice_total: self.html_param['gold_pre'] = v_player.gold self.html_param['gold_post'] = min(v_player.gold + sellprice_total, Defines.VALUE_MAX) if 0 < sellprice_treasure_total: self.html_param['treasure_pre'] = v_player.cabaretking self.html_param['treasure_post'] = min(v_player.cabaretking + sellprice_treasure_total, Defines.VALUE_MAX) self.html_param['flag_include_rare'] = include_rare self.html_param['flag_include_hkincr_already'] = include_hkincr_already url = UrlMaker.selldo() url = OSAUtil.addQuery(url, Defines.URLQUERY_CARD, ','.join(str_idlist)) self.html_param['url_selldo'] = self.makeAppLinkUrl(url) self.writeAppHtml('card/sellyesno')
def process(self): v_player = self.getViewerPlayer() args = self.getUrlArgs('/carddetail/') strcardid = args.get(0, None) model_mgr = self.getModelMgr() cardset = None if strcardid and strcardid.isdigit(): cardid = int(strcardid) cardlist = BackendApi.get_cards([cardid], model_mgr, using=settings.DB_READONLY) if cardlist: cardset = cardlist[0] if cardset is None or cardset.card.uid != v_player.id: raise CabaretError(u'閲覧できないキャストです', CabaretError.Code.ILLEGAL_ARGS) if self.getFromPageName() == Defines.FromPages.CARDBOX: url = UrlMaker.cardbox() args = self.getFromPageArgs() if args and len(args) == 3: ctype, sortby, page = args url = OSAUtil.addQuery(url, Defines.URLQUERY_CTYPE, ctype) url = OSAUtil.addQuery(url, Defines.URLQUERY_SORTBY, sortby) url = OSAUtil.addQuery(url, Defines.URLQUERY_PAGE, page) self.html_param['url_back'] = self.makeAppLinkUrl( url, add_frompage=False) elif self.getFromPageName() == Defines.FromPages.DECK_RAID: url = UrlMaker.deck_raid() self.html_param['url_back'] = self.makeAppLinkUrl( url, add_frompage=False) elif self.getFromPageName() == Defines.FromPages.DECK_NORMAL: url = UrlMaker.deck() self.html_param['url_back'] = self.makeAppLinkUrl( url, add_frompage=False) deck = BackendApi.get_deck(v_player.id, model_mgr, using=settings.DB_READONLY) raid_deck = BackendApi.get_raid_deck(v_player.id, model_mgr, using=settings.DB_READONLY) cardidlist = [] cardidlist.extend(deck.to_array()) cardidlist.extend(raid_deck.to_array()) self.html_param['card'] = Objects.card(self, cardset, deck=cardidlist) is_stockable = False is_stock_overlimit = False if CardUtil.checkStockable(v_player.id, deck, cardset, raise_on_error=False): stocknum_model = BackendApi.get_cardstock( model_mgr, v_player.id, cardset.master.album, using=settings.DB_READONLY) num = stocknum_model.num if stocknum_model else 0 is_stock_overlimit = Defines.ALBUM_STOCK_NUM_MAX <= num is_stockable = True self.html_param['is_stockable'] = is_stockable self.html_param['is_stock_overlimit'] = is_stock_overlimit self.writeAppHtml('card/carddetail')
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)
def process(self): v_player = self.getViewerPlayer() model_mgr = self.getModelMgr() # 合成結果. compositiondata = BackendApi.get_compositiondata( model_mgr, v_player.id, using=settings.DB_READONLY) # ベースカード. basecardset = BackendApi.get_cards([compositiondata.result_baseid], model_mgr, using=settings.DB_READONLY) if not basecardset or basecardset[0].card.mid != compositiondata.mid: if settings_sub.IS_LOCAL: raise CabaretError(u'教育したキャストが見つかりません.') url = UrlMaker.composition() self.appRedirect(self.makeAppLinkUrlRedirect(url)) return basecardset = basecardset[0] self.html_param['basecard_post'] = Objects.card(self, basecardset) compositiondata.set_to_card(basecardset.card) self.html_param['basecard_pre'] = Objects.card(self, basecardset) # 素材カード. materialcardsetlist = BackendApi.get_cards( compositiondata.result_materialidlist, model_mgr, using=settings.DB_READONLY, deleted=True) self.html_param['cardlist'] = [ Objects.card(self, cardset) for cardset in materialcardsetlist ] # 経験値とレベル. self.html_param['exp'] = compositiondata.result_exp self.html_param['levelup'] = compositiondata.result_lvup # お金. self.html_param['cost'] = compositiondata.result_cost_gold # スキル. self.html_param['skilllevelup'] = compositiondata.result_skilllvup # 成功 or 大成功. self.html_param[ 'is_great_success'] = compositiondata.result_flag_great_success # 上昇値. level_pre = compositiondata.result_lvpre level_add = compositiondata.result_lvup power_add = 0 if 0 < level_add: basemaster = basecardset.master pow_pre = CardUtil.calcPower(basemaster.gtype, basemaster.basepower, basemaster.maxpower, level_pre, basemaster.maxlevel, basecardset.card.takeover) pow_post = CardUtil.calcPower(basemaster.gtype, basemaster.basepower, basemaster.maxpower, level_pre + level_add, basemaster.maxlevel, basecardset.card.takeover) power_add = pow_post - pow_pre self.html_param['power_add'] = power_add self.html_param['level_add'] = level_add self.html_param['skilllevel_add'] = compositiondata.result_skilllvup # 続けて合成のURL. url = UrlMaker.compositionmaterial(basecardset.id) self.html_param['url_continue'] = self.makeAppLinkUrl(url) self.writeAppHtml('composition/complete')
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)