const BridgeWindow = require( "bridge.window" ); const Mod = require( "pvprank.mod" ); const RoleController = require( "role_controller" ); const ElitematchEvent = require( "elitematch_event" ); const NXTogle = require( "nx.fx.togs" ); const FID = require( "bridge.function.ids" ); const HeroController = require( "hero_controller" ); const PartnerConst = require( "partner_const" ); const HeroConst = require( "hero_const" ); const TipsController = require( "tips_controller" ); cc.Class({ extends: BridgeWindow, properties: { nodChallengeTime: { default: null, type : cc.Node, displayName: "挑戰次數顯示" }, nodReachReward : { default: null, type : cc.Node, displayName: "達成獎勵" }, nodMenu : { default: null, type : NXTogle, displayName: "賽制選擇" }, nodOp: { default: null, type : cc.Node, displayName: "挑戰按鈕" }, nodOpDiff: { default: null, type : cc.Node, displayName: "區別顯示" }, nodMain: { default: null, type : cc.Node, displayName: "段位等信息顯示" }, nodMatchInfo : { default: null, type : cc.Node, displayName: "段位賽賽程等信息顯示" }, nodTask : { default: null, type : cc.Node, displayName: "段位賽任務相關" }, }, onLoad: function(){ this.mod = Mod.getInstance(); if( !this.mod ){ this.delayClose(); return; } if( this.delNod ){ this.delNod.stop(); } this.cfg = this.mod.getCfg(); this.awardnum = 0; this.nodMenu.posTog = this.onTogMenu.bind( this ); this.first = 0; // 视图监听 this.vbind( [ [ "rankMatch", this.freshInfo.bind( this ) ], [ "rankOrder", this.freshTip.bind( this ) ], [ "PvpRankTask", this.freshTask.bind( this ) ] ] ); this.bindGEvent( ElitematchEvent.Elite_buy_count_Event, this.freshChallengeTime.bind( this ) ); this.bindGEvent( ElitematchEvent.Get_Elite_Enemy_Info_Event, this.freshMatch.bind( this ) ); this.bindGEvent( ElitematchEvent.Elite_Receive_Reward_Event, this.onfreshGet.bind( this ) ); this.bindGEvent( ElitematchEvent.Elite_Start_Time_Event, this.onfreshState.bind( this ) ); this.mod.sender24900(); this.mod.sender24905(); }, freshTask : function( _data ){ /**** {"win_num":0,"all_num":1,"list": [{"id":6,"award_status":0}, {"id":5,"award_status":0}, {"id":4,"award_status":0}, {"id":3,"award_status":0}, {"id":2,"award_status":0}, {"id":1,"award_status":1}]}*/ let finish = 0; let count = 0; if( _data ){ if( nx.dt.arrNEmpty( _data.list ) ){ let list = _data.list; list.forEach( _item =>{ if( _item.award_status == 2 ){ finish++; } } ) count = list.length; } } let prog = count != 0 ? nx.text.format( "PvpRScore", finish, count ) : ""; nx.gui.setString( this.nodTask, "ico/prog", prog ); nx.gui.setActive( this.nodTask, "ico/finish", count == finish ); }, freshTip: function( _order ){ if( !_order ){ return; } let cfg = game.configs.arena_elite_war_order_data[_order.period]; /**當前的戰令數據{"period":2,"cur_day":2,"end_time":1714665600,"lev":2,"rmb_status":0,"win_count":6,"list":[]}**/ let list = _order.list; let countd = 0; if( nx.dt.arrNEmpty( list ) ){ for (let i = 0; i < list.length; i++) { let canget = list[i]; if( !canget ){ nx.gui.setActive( nod, "ffocus", false ); nx.gui.setActive( nod, "pfocus", false ); } if( canget.award_status == 0 || ( canget.rmb_award_status == 0 && _order.rmb_status == 1 ) ) { countd ++; } } }else{ for (let o in cfg ) { let ofg = cfg[o]; _order.win_count >= ofg.win_count || ( _order.win_count >= ofg.win_count && _order.rmb_status == 1 ) ? countd ++ : count; } } nx.gui.setActive( this, "panel/rt/order/tip", countd > 0 ); }, freshInfo : function( _data ){ if( nx.dt.objEmpty( _data ) || !_data ){ return; } let info = _data; this.infoo = info; let self = this; if( !info ){ return; } if( info.is_king == 0 || info.state != 3 ){ this.nodMenu.togTo( 0 ); this.onTogMenu( 0 ); }else{ this.nodMenu.togTo( 1 ); this.onTogMenu( 1 ); } this.daybuycount = info.day_buy_count; let time = info.day_combat_count; let buytime = info.day_buy_count; this.maxbuytime = info.day_max_buy_count; this.win = info.rank; this.period = info.period; let cfg = gdata( this.cfg[0], "data_elite_level" ); this.cffg = cfg; this.onfreshGet( info ); let cfggg = cfg[ info.lev ]; let ncfggg = cfg[ info.lev + 1 ]; nx.gui.setString( this.nodMain, "rank/lev/txt", cfggg.name ); let path = this.mod.dealUI( info.lev ); nx.gui.setSpriteFrame( this.nodMain, "rank/ico", path ); let prog = nx.gui.find( this.nodMain, "rank/prog" ); let delprog = nx.gui.find( this.nodMain, "rank/progdel" ); let bar = nx.gui.find( prog, "bar" ); let total = cfggg.need_exp; let percent = info.score > 0 ? ( info.score ) / total : 0; if( !cfg[ info.lev + 1 ] ){ percent = 1; } let progcmp = nx.gui.getComponent( prog, "", cc.ProgressBar ); let progcmpsmall = nx.gui.getComponent( delprog, "", cc.ProgressBar ); let promote = info.promoted_info; if( progcmp ){ let del = percent - progcmp.progress; // delprog.position = cc.Vec2( ( cfggg.init_exp / total ) * progcmp.totalLength, delprog.position.y ); // this.scheduleOnce( ()=>{ // progcmp.progress += del; // } ) // let doAnimin = function(){ // this.deltween = cc.tween( delprog ) // .to( 0.1, { position: cc.v2( ( cfggg.init_exp / total ) * progcmp.totalLength, delprog.position.y ) } ) // .delay( 0.1 ) // .start(); // } progcmp.progress = percent; // if( percent > 0 ){ // this.delNod = cc.tween( bar ) // .delay( 0.3 ) // .to( 0.2, { width: percent * progcmp.totalLength } ) // .call( ()=>{ // doAnimin(); // } ) // .delay( 0.1 ) // .call( ()=>{ // progcmp.progress = percent; // } ) // .delay( 0.6 ) // .start(); // }else{ // progcmp.progress = percent; // } let desc = cfg[ info.lev + 1 ] ? nx.text.format( "PvpRNext", cfg[ info.lev + 1 ].name ) : nx.text.getKey( "PvpRMax" ); // let tip = nx.gui.setString( this.nodMain, "rank/next/desc", desc ); nx.gui.setString( this.nodMain, "rank/next/nowprog", parseInt( percent * total ) + "/" + total ); nx.gui.setActive( this.nodMain, "rank/next/nowprog", cfg[ info.lev + 1 ] ); } if( progcmpsmall ){ progcmpsmall.progress = ( cfggg.init_exp / total ); } nx.gui.setActive( delprog, "delshow", cfggg.init_exp > 0 && cfg[ info.lev + 1 ] ); nx.gui.setString( this.nodChallengeTime.children[1], "txt", time ); // ( this.maxbuytime - buytime ) + "/" + this.maxbuytime nx.gui.setString( this.nodChallengeTime.children[3], "txt", nx.text.getKey( "PvpRankBuyNolimit" ) ); nx.gui.setActive( this.nodMain, "rank/next", nx.dt.arrEmpty( info.promoted_info ) ); nx.gui.setActive( this.nodMain, "rank/promote", nx.dt.arrNEmpty( info.promoted_info ) ); nx.gui.setActive( this.nodMain, "rank/prog", nx.dt.arrEmpty( info.promoted_info ) ); nx.gui.setActive( this.nodMain, "rank/progdel", nx.dt.arrEmpty( info.promoted_info ) ); // nx.gui.gocChildren( this.nodMain, "rank/promote/need", promote.length ); if( nx.dt.arrNEmpty( promote ) ){ let ninfo = promote.shift(); let needcount = ninfo.count; let desc = nx.text.format( "PvpRankLevPromote", ninfo.flag, needcount ); nx.gui.setString( this.nodMain, "rank/promote/desc", desc ); } let zfg = game.configs.arena_elite_data.data_zone[info.zone_id]; let start_date = nx.bridge.time.toLocalString( info.start_time,true, false ); let end_date = nx.bridge.time.toLocalString( info.end_time, true, false ); let statetime = nx.bridge.time.toNeedTime( info.end_time ); let racetip = nx.text.getKey( "PvpRMatchState" + info.state ); let kingstarttime = nx.bridge.time.toNeedSeconds( info.state_time ); let nexttip = this.infoo.state != 3 ? nx.text.format( "PvpRMatchRaceTip", kingstarttime, nx.text.getKey( "PvpRMatchState" + ( info.state + 1 ) ) ) : "" ; let kingstate = info.king == 1 ? nx.text.getKey( "PvpRMatchState5" ) :nx.text.format( "PvpRMatchState4", kingstarttime ); let timedesc = nx.text.format( "PvpRMatchTime", this.period, zfg.name, start_date, end_date ); let racedesc = nx.text.format( "PvpRMatchRace", racetip, nexttip, statetime ); // 賽程時間 nx.gui.setString( this.nodMatchInfo, "times/txt", timedesc ); // 比賽數據 nx.gui.setString( this.nodMatchInfo, "race/txt", racedesc ); // 自己的段位數據 nx.gui.setString( this.nodMatchInfo, "self/txt", info.is_king != 0 ? nx.text.getKey( "PvpRMatchSelf" ) : nx.text.getKey( "PvpRMatchSelfN" ) ); let rankinfo = info.rank == 0 ? nx.text.getKey( "PvpRankNoInfo" ) : info.rank; // 自己的排名數據 nx.gui.setString( this.nodMatchInfo, "rank/txt", nx.text.format( "PvpRMatchSelfRank", rankinfo ) ); }, onfreshGet: function( _data ){ if( !_data ){ return; } this.awardnum = 0; let info = _data; let next = 0; if( info.lev_reward ){ for (let i = 0; i < info.lev_reward.length; i++) { let infos = info.lev_reward[i]; if( infos.flag == 1 ){ this.awardnum = infos.lev; next = infos.lev; break; }else if( infos.flag == 0 ){ next = infos.lev; break; }else{ this.awardnum = -1; } } } let last = next == 0 ? this.cffg[ 22 ] : this.cffg[ next ]; let award = last.award; nx.gui.setString( this.nodReachReward, "desc", nx.text.format( "PvpRank", last.name ) ); let cmp = nx.gui.getComponent( this.nodReachReward, "rewards", "cmp.common.itemlayout" ); if( cmp ){ cmp.rebuild( award ); } nx.gui.setActive( this.nodReachReward, "get", this.awardnum > 0 ); nx.gui.setActive( this.nodReachReward, "cannot", this.awardnum == 0 ); nx.gui.setActive( this.nodReachReward, "max", this.awardnum == -1 ); }, onfreshState: function( _state ){ if( _state ){ let state = _state.state; // let cmp = } }, onTouchGet: function(){ this.mod.sender24915( this.awardnum ); }, freshChallengeTime : function( _info ){ let info = _info; if( !info ){ return; } this.daybuycount = info.day_buy_count; let time = info.day_combat_count; nx.gui.setString( this.nodChallengeTime.children[1], "txt", time ); nx.gui.setString( this.nodChallengeTime.children[3], "txt", nx.text.getKey( "PvpRankBuyNolimit" ) ); }, freshMatch: function( _data ){ let combat = _data.day_combat_count; nx.gui.setString( this.nodChallengeTime.children[1], "txt", combat ); if( _data.is_match == 0 ){ nx.bridge.createPanel( "WndEliteRankMatch", { type : this.gametype, mod : this.mod, state : this.infoo, } ); } // let rankstatus = _data }, onTouchBuy: function(){ let self = this; let bfg = gdata( this.cfg[0], "data_elite_buy" )[this.daybuycount + 1]; if( ( this.daybuycount + 1 ) > this.maxbuytime ){ nx.tbox( "MonoBuyNoTime" ); return; } let role = RoleController.getInstance().getRoleVo(); let cost = bfg.cost; if( role.vip < bfg.need_vip ){ nx.tbox( nx.text.format( "VIPBuyItemTip", bfg.need_vip ) ); return; } let tips = nx.text.format( "PvpBuyRankTime", cost[0][0], cost[0][1] ); nx.mbox( tips, ['cancel','confirm'], ( _key, _box ) =>{ _box.close(); if( _key == "confirm" ) { // this.reqSummon( _args.type, _times, _args ); self.mod.sender24904(); } } ) }, onTogMenu: function( _idx ){ let index = parseInt( _idx ); this.onSetBtn( index ); }, onSetBtn: function( _type ){ // let desc = _type == 0 ? nx.text.getKey( "PvpRankType23" ) : nx.text.getKey( "PvpRankType24" ); this.gametype = _type + 1 ; let opdesc = nx.text.getKey( "RankMatchingBtn" ); let count = 0; if( this.infoo.state != 3 && this.gametype == 2 ){ opdesc = nx.text.getKey( "PvpRMatchState0" ) ; count++; } if( this.infoo.state == 3 && this.gametype == 1 && this.infoo.is_king != 0 ){ opdesc = nx.text.getKey( "PvpRMatchState0" ) ; count++; } if( this.infoo.state == 3 && this.gametype == 2 && this.infoo.is_king == 0 ){ opdesc = nx.text.getKey( "PvpRankOpTip" ) ; count++; } nx.gui.setString( this.nodOp, "txt", nx.text.getKey( "RankMatchingBtn" ) ); nx.gui.setString( this.nodOpDiff, "txt", opdesc ); nx.gui.setActive( this.nodOp, "", count == 0 ); nx.gui.setActive( this.nodOpDiff, "", count != 0 ); nx.gui.setActive( this.nodMain, "rank", _type == 0 || ( this.infoo.state == 3 && ( _type == 1 || _type == 0 ) ) ); nx.gui.setActive( this.nodMain, "noopen", _type == 1 && this.infoo.is_king == 0 ); if( this.infoo ){ let kingdesc = this.infoo.state != 3 ? nx.text.getKey( "PvpRankNoOpen" ) : this.infoo.is_king == 0 ? nx.text.getKey( "PvpRankNoMatch" ) : "" ; nx.gui.setString( this.nodMain, "noopen", kingdesc ); } }, onTouchExchange: function(){ nx.bridge.jumper.jump2Window( FID.EliteShop ); }, onTouchChallenge: function(){ this.mod.sender24901(); }, onTouchNoOpen: function(){ if( this.infoo.state != 3 ){ nx.tbox( "PvpRankNoOpen" ); return; } if( ( this.infoo.is_king == 0 && this.gametype != 1 ) || ( this.infoo.state == 3 && this.infoo.is_king == 0 && this.gametype != 1 ) ){ nx.tbox( "PvpRankNoMatch" ); return; } if( ( this.infoo.state == 3 && this.infoo.is_king != 0 && this.gametype == 1 ) ){ nx.tbox( "PvpRankKingMatch" ); return; } }, onTouchTop: function(){ let self = this; nx.bridge.createPanel( "WndEliteRankTop", { cb : ()=>{ self.mod.sender24911( self.period, 1, 6, self.infoo.zone_id ); }, period : self.period, mod : self.mod, zone : self.infoo.zone_id, } ); }, onTouchOrder: function(){ let self = this; this.mod.sender24952(); nx.bridge.createPanel( "WndEliteRankOrder", { period : this.period, mod : this.mod, } ); }, onTouchForm: function(){ let type = this.infoo.is_king != 0 && this.infoo.state == 3 ? 4 : 3; HeroController.getInstance().openFormGoFightPanel( true, PartnerConst.Fun_Form.EliteMatch, { need_hide_top : true, state: type }, HeroConst.FormShowType.eFormSave ); }, onTouchRankReward: function(){ let awards = []; let fawards = []; let lasts = []; let cfgs = gdata( this.cfg[0], "data_elite_rank_reward" ); let fcfgs = gdata( this.cfg[0], "data_elite_level" ); // for (let i in cfgs ) { // let info = cfgs[i]; // info.items = info.show_award; // awards.push( info ); // } for (let f in fcfgs ) { let reward = fcfgs[f]; let first = {}; let reww = { items : reward.award_client, name : nx.text.format( "PvpLevReachTip", reward.name ), lev : reward.id, path : this.mod.dealUI( reward.id ), } if( reww ){ lasts.push( reww ); } if( nx.dt.arrNEmpty( reward.lev_award ) ){ first.items = reward.lev_award; first.name = nx.text.format( "FirstReachTip", reward.name ); first.lev = reward.id; first.path = this.mod.dealUI( reward.id ); fawards.push( first ); // lasts.push( award_client ) } } nx.bridge.createPanel( "WndEliteRankReward", { ops: [ "", "", "", "FirstReach", "PvpLevAward" ], cb: () => { // ArenaController.getInstance().sender20221(); }, dfg: fawards, sfg: lasts, show: "FirstReach", len : 5, } ); }, onTouchRecords: function(){ nx.bridge.createPanel( "WndEliteRankRecords", { type : this.gametype, mod : this.mod, } ); }, onTouchAchieve: function(){ let cfgs = gdata( this.cfg[0], "data_elite_level" ); let arean = gdata( this.cfg[0], "data_zone" ); nx.bridge.createPanel( "WndEliteRankAchieve", { period : this.period, cfg : cfgs, arean : arean, mod : this.mod, } ); }, onTouchRankInfo: function(){ let TC = TipsController.getInstance(); let explain = gdata( this.cfg[0], "data_explain2" )[1]; let explain2 = gdata( this.cfg[0], "data_explain2" )[2]; let desc = explain.desc + "\n\n" + explain2.title + "\n" + explain2.desc; TC.showTextPanel( explain.title, desc ); }, onTouchRankTask: function(){ this.mod.reqTaskStatus(); nx.bridge.createPanel( "WndEliteRankTask" ); }, onTouchPlotNoFun: function( _nod ){ nx.gui.setActive( _nod, "", false ); }, onTouchHelp: function(){ let TC = TipsController.getInstance(); let explain = ""; let cfg = gdata( this.cfg[0], "data_explain" ); for (let i in cfg ) { let item = cfg[i]; explain += item.title + "\n\n" + item.desc + "\n\n"; } // let explain = gdata( this.cfg[0], "data_explain2" )[1]; // let explain2 = gdata( this.cfg[0], "data_explain2" )[2]; // let desc = explain.desc + "\n\n" + explain2.title + "\n" + explain2.desc; TC.showTextPanel( nx.text.getKey( "ActHelpTitle" ), explain ); }, });