1132 lines
34 KiB
JavaScript
1132 lines
34 KiB
JavaScript
/*-----------------------------------------------------+
|
|
* 角色控制模块
|
|
* @author whjing2012@163.com
|
|
+-----------------------------------------------------*/
|
|
|
|
const BridgeController = require( "bridge.controller" );
|
|
const RoleEvent = require( "role_event" );
|
|
const RoleConst = require( "role_const" );
|
|
const TimeTool = require( "timetool" );
|
|
const RoleModel = require( "role_model" );
|
|
const FFSDK = require( "ff_sdk" );
|
|
const HeroController = require( "hero_controller" );
|
|
const FID = require( "bridge.function.ids" );
|
|
|
|
|
|
const RoleController = cc.Class( {
|
|
|
|
extends: BridgeController,
|
|
|
|
ctor: function() {
|
|
},
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
|
|
this.model = new RoleModel();
|
|
this.model.initConfig();
|
|
|
|
this.is_re_connect = false;
|
|
this.apk_data = null;
|
|
|
|
this.openServer = {};
|
|
// SDK_.get_apk_url(function(_data){
|
|
// cc.log(_data)
|
|
// this.apk_data = _data;
|
|
// }.bind(this))
|
|
},
|
|
|
|
getModel: function() {
|
|
return this.model;
|
|
},
|
|
|
|
getRoleVo: function() {
|
|
|
|
if( !this.model ) {
|
|
nx.error( "ROLE:尚未初始化角色!" );
|
|
return null;
|
|
}
|
|
return this.model.getRoleVo();
|
|
},
|
|
|
|
// 注册监听事件
|
|
registerEvents: function() {
|
|
|
|
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
this.RegisterProtocal( 10301, this.on10301 ); // 角色基本信息
|
|
this.RegisterProtocal( 10302, this.on10302 ); // 资产信息
|
|
this.RegisterProtocal( 10315, this.on10315 ); // 查看角色信息
|
|
this.RegisterProtocal( 10306, this.on10306 ); // 战力变更推送
|
|
|
|
this.RegisterProtocal( 10318, this.on10318 ); // 允许切磋状态
|
|
this.RegisterProtocal( 10325, this.on10325 ); // 头像列表信息
|
|
this.RegisterProtocal( 10327, this.on10327 ); // 头像变更
|
|
this.RegisterProtocal( 10345, this.on10345 ); // 形象信息
|
|
this.RegisterProtocal( 10346, this.on10346 ); // 形象使用
|
|
this.RegisterProtocal( 10347, this.on10347 ); // 形象激活
|
|
|
|
this.RegisterProtocal( 10342, this.on10342 ); // 强制改名
|
|
this.RegisterProtocal( 10343, this.on10343 ); // 角色改名
|
|
this.RegisterProtocal( 10344, this.on10344 ); //升级推送
|
|
|
|
this.RegisterProtocal( 10317, this.on10317 ); // 形象激活
|
|
this.RegisterProtocal( 10319, this.on10319 ); //周冠軍賽被點贊次數
|
|
|
|
this.RegisterProtocal( 10316, this.on10316 ); // 膜拜角色
|
|
// this.RegisterProtocal(12741, this.on12741); // 能用提示信息
|
|
this.RegisterProtocal( 12745, this.on12745 ); // 道具不足通用协议
|
|
|
|
this.RegisterProtocal( 10906, this.on10906 ); // 开服天数
|
|
|
|
this.RegisterProtocal( 10994, this.on10994 ); // 服务端通知整点更新
|
|
this.RegisterProtocal( 10945, this.on10945 ); // 媒体卡兑换
|
|
|
|
this.RegisterProtocal( 21500, this.on21500 ); // 头像框获取
|
|
this.RegisterProtocal( 21501, this.on21501 ); // 使用头像框
|
|
this.RegisterProtocal( 21502, this.on21502 ); // 更新头像框
|
|
this.RegisterProtocal( 21503, this.on21503 ); // 激活头像框
|
|
|
|
this.RegisterProtocal( 23300, this.on23300 ); // 称号信息
|
|
this.RegisterProtocal( 23301, this.on23301 ); // 使用称号
|
|
this.RegisterProtocal( 23302, this.on23302 ); // 更新称号数据
|
|
this.RegisterProtocal( 23303, this.on23303 ); // 激活称号
|
|
|
|
this.RegisterProtocal( 24500, this.on24500 ); // 当前特权情况
|
|
|
|
this.RegisterProtocal( 10350, this.handle10350 ) //-- 获取活动资产id
|
|
this.RegisterProtocal( 10351, this.handle10351 ) //-- 推送活动资产id
|
|
|
|
//聊天框专项
|
|
this.RegisterProtocal( 12700, this.handle12700 )//聊天框列表
|
|
this.RegisterProtocal( 12701, this.handle12701 )//使用聊天框
|
|
this.RegisterProtocal( 12702, this.handle12702 )//更新聊天框列表
|
|
this.RegisterProtocal( 12703, this.handle12703 )//使用聊天框
|
|
// this.RegisterProtocal( 12704, this.handle12704 )
|
|
|
|
this.RegisterProtocal( 12770, this.handle12770 ) // -- 发送举报协议
|
|
this.RegisterProtocal( 12771, this.handle12771 ) //-- 获取举报协议信息
|
|
this.RegisterProtocal( 12772, this.handle12772 ) //-- 有參數的提示語
|
|
|
|
this.RegisterProtocal( 10905, this.handle10905 ) //-- 世界等级
|
|
this.RegisterProtocal( 10962, this.handle10962 ) //-- 綁定獎勵
|
|
|
|
|
|
let self = this;
|
|
self.RegisterProtocal( 25805, this.handle25805 ) // 設置徽章使用
|
|
self.RegisterProtocal( 25806, this.handle25806 ) // 請求所有徽章
|
|
self.RegisterProtocal( 25807, this.handle25807 ) // 激活徽章推送
|
|
|
|
|
|
self.RegisterProtocal( 25815, this.handle25815 ) // 徽章分享
|
|
// self.RegisterProtocal(25816, this.handle25816) // 查看徽章分享
|
|
|
|
self.RegisterProtocal( 25817, this.handle25817 ) // 歷練任務 成就分享
|
|
// self.RegisterProtocal(25818, this.handle25818) // 查看成就分享
|
|
|
|
self.RegisterProtocal( 25819, this.handle25819 ) // 榮譽分享 榮譽等級
|
|
// self.RegisterProtocal(25820, this.handle25820) // 查看榮譽分享" 榮譽等級
|
|
|
|
//成长之路
|
|
// this.RegisterProtocal(25830, this.handle25830); //查看成长之路
|
|
// this.RegisterProtocal(25831, this.handle25831); //成长之路分享
|
|
// this.RegisterProtocal(25832, this.handle25832); //查看成长之路分享
|
|
|
|
// 桌面主题
|
|
this.RegisterProtocal( 10335, this.on10335 ); // 拥有主题信息
|
|
this.RegisterProtocal( 10336, this.on10336 ); // 更换主题
|
|
|
|
this.RegisterProtocal( 10380, this.on10380 ); // 获取开服相关信息
|
|
},
|
|
|
|
reqBaseFromServer: function( _cb ) {
|
|
|
|
this.SendProtocal( 10380,{}, _cb );
|
|
this.SendProtocal( 10905,{} );
|
|
},
|
|
|
|
setReconnect: function( status ) {
|
|
console.log( "...........断线状态", status )
|
|
this.is_re_connect = status
|
|
},
|
|
|
|
//判断别人srv_id是不是与自己是不是同服
|
|
isTheSameSvr: function( srv_id ) {
|
|
var is_same = this.model.isTheSame( srv_id );
|
|
if( srv_id && is_same ) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
},
|
|
|
|
// 角色基本信息
|
|
on10301: function( _data ) {
|
|
|
|
// cc.log( _data );
|
|
|
|
// 埋点更新
|
|
if( _data && nx.mTrace ) {
|
|
nx.mTrace.setRole( _data.srv_id || "", _data.rid || 0 );
|
|
}
|
|
|
|
// SDK
|
|
if( _data && FFSDK.getInstance().isEnableSDK() ) {
|
|
FFSDK.getInstance().reportServerID( _data.srv_id );
|
|
FFSDK.getInstance().reportRoleID( _data.rid );
|
|
}
|
|
|
|
if( !this.init_role ) {
|
|
this.init_role = true;
|
|
//先实例化
|
|
this.model.initRoleBaseData( _data );
|
|
// 这里会有很多信息需要请求
|
|
this.requestOpenSrvDay(); // 开服天数
|
|
// if(PLATFORM_TYPR == "SH_SDK"){
|
|
// SDK.roleUpLevel(this.getRoleVo().lev);
|
|
// }
|
|
|
|
// 资产预加载
|
|
// if (_data.lev <= 5) {
|
|
// game.addGuideRes();
|
|
// if (_data.sex == 2) {
|
|
// game.addRenameRes();
|
|
// }
|
|
// }
|
|
|
|
// 章节资产预加载
|
|
// game.addChapterRes(_data.chapter_id);
|
|
|
|
let sys_func_id = 1;
|
|
|
|
if( _data.lev < 10 ) {
|
|
window.hide_loading = true;
|
|
} else {
|
|
sys_func_id = 2;
|
|
}
|
|
|
|
gcore.GlobalEvent.fire( EventId.EVT_ROLE_CREATE_SUCCESS );
|
|
|
|
|
|
} else {
|
|
this.model.initRoleBaseData( _data );
|
|
let sfg = game.configs.source_data.data_source_data[FID.Equips];
|
|
let eqm = nx.bridge.checkConditions( sfg.lev_limit );
|
|
if( nx.dt.objEmpty( eqm ) ){
|
|
HeroController.getInstance().getModel().dealReformEqm();
|
|
}
|
|
|
|
}
|
|
// 断线重连抛出事件
|
|
if( this.is_re_connect ) {
|
|
gcore.GlobalEvent.fire( EventId.EVT_RE_LINK_GAME )
|
|
this.is_re_connect = false
|
|
}
|
|
},
|
|
|
|
// 角色资产信息
|
|
on10302: function( _data ) {
|
|
this.model.initRoleAssetsData( _data );
|
|
},
|
|
|
|
//查看角色信息
|
|
requestRoleInfo: function( rid, srv_id, setting ) {
|
|
if( rid == 0 || !srv_id )
|
|
return
|
|
var protocal = {};
|
|
protocal.rid = rid;
|
|
protocal.srv_id = srv_id;
|
|
this.setting_10315 = setting;
|
|
this.SendProtocal( 10315, protocal );
|
|
},
|
|
|
|
//查看角色信息
|
|
on10315: function( _data ) {
|
|
let self = this;
|
|
if( self.setting_10315 ) {
|
|
let form_type = self.setting_10315.form_type
|
|
if( !form_type ) return;
|
|
let setting = {}
|
|
setting.role_type = RoleConst.role_type.eOther;
|
|
setting.other_data = _data;
|
|
|
|
if( form_type == RoleConst.Other_Form_Type.eHonorLevelTips ) {
|
|
setting.index = RoleConst.Tab_type.eHonorWall;
|
|
}
|
|
// elseif form_type == RoleConst.Other_Form_Type.eGrowthWayShare then
|
|
// local share_id = self.setting_10315.share_id or 0
|
|
// setting.index = RoleConst.Tab_type.eGrowthWay
|
|
// setting.growth_way_share_id = share_id
|
|
// elseif form_type == RoleConst.Other_Form_Type.eMessageBoardInfo then
|
|
// setting.index = RoleConst.Tab_type.eMessageBoard
|
|
// setting.bbs_id = self.setting_10315.bbs_id
|
|
// end
|
|
self.openRolePersonalSpacePanel( true, setting )
|
|
} else {
|
|
gcore.GlobalEvent.fire( RoleEvent.DISPATCH_PLAYER_VO_EVENT, _data );
|
|
}
|
|
},
|
|
|
|
// 膜拜
|
|
sender10316: function( rid, srv_id, index, type ) {
|
|
if( !rid ) return;
|
|
index = index || 0;
|
|
type = type || 0;
|
|
var protocal = {}
|
|
protocal.type = type;
|
|
protocal.rid = rid;
|
|
protocal.srv_id = srv_id;
|
|
protocal.idx = index;
|
|
this.SendProtocal( 10316, protocal )
|
|
},
|
|
|
|
on10316: function( _data ) {
|
|
nx.tbox( _data.msg );
|
|
if( _data.code == 1 ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.WorshipOtherRole, _data );
|
|
}
|
|
},
|
|
|
|
// 更新切磋状态
|
|
send10318: function( auto_pk ) {
|
|
this.SendProtocal( 10318, { auto_pk: auto_pk } );
|
|
},
|
|
|
|
// 更新切磋状态结果
|
|
on10318: function( _data ) {
|
|
nx.tbox( _data.msg );
|
|
if( _data.code == 1 ) {
|
|
this.model.setRoleAttribute( "auto_pk", _data.auto_pk );
|
|
}
|
|
},
|
|
|
|
// 请求头像列表信息
|
|
send10325: function( _cb ) {
|
|
this.SendProtocal( 10325, {}, _cb );
|
|
},
|
|
|
|
on10325: function( _data ) {
|
|
// 失败判定
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
this.model.setRoleAttribute( "face_list", _data.face_list );
|
|
},
|
|
|
|
// 头像变更
|
|
send10327: function( face_id, _cb ) {
|
|
this.SendProtocal( 10327, { face_id: face_id }, _cb );
|
|
},
|
|
|
|
on10327: function( _data ) {
|
|
|
|
// 失败判定
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
this.model.setRoleAttribute( "face_id", _data.face_id );
|
|
},
|
|
|
|
// 通用提示信息
|
|
on12741: function( _data ) {
|
|
// nx.tbox(_data.msg);
|
|
},
|
|
|
|
// 道具不足通用提示
|
|
on12745: function( _data ) {
|
|
|
|
var item_config = Utils.getItemConfig( _data.bid );
|
|
if( !item_config ) {
|
|
return;
|
|
}
|
|
|
|
if( _data.bid == game.configs.item_data.data_assets_label2id.gold ||
|
|
_data.bid == game.configs.item_data.data_assets_label2id.hero_exp ) {
|
|
// if( IS_SHOW_CHARGE == false ) {
|
|
// nx.tbox( "lab_role_controller_tip_1" );
|
|
// } else {
|
|
// var fun = function() {
|
|
// require( "vip_controller" ).getInstance().openVipMainWindow( true, VIPTABCONST.CHARGE );
|
|
// }.bind( this );
|
|
// var str = cc.js.formatStr( nx.text.getKey( 'lab_role_controller_tip_2' ), item_config.name );
|
|
//
|
|
// }
|
|
} else if( _data.bid == game.configs.item_data.data_assets_label2id.energy ) {
|
|
nx.tbox( "lab_role_controller_tip_3" );
|
|
} else {
|
|
var config = Utils.getItemConfig( _data.bid );
|
|
if( config ) {
|
|
var BackpackController = require( "backpack_controller" );
|
|
let ifg = gdata( "item_data", "data_unit1", config.id );
|
|
if( ifg ) {
|
|
nx.tbox( nx.text.format( nx.text.getKey( "lab_hero_break_window_tip1" ), ifg.name ) );
|
|
}
|
|
// BackpackController.getInstance().openTipsSource( true, config.id );
|
|
}
|
|
}
|
|
},
|
|
|
|
on10994: function( _data ) {
|
|
if( _data.type == 6 || _data.type == 18 ) {
|
|
|
|
} else if( _data.type == 0 ) {
|
|
this.requestOpenSrvDay();
|
|
require( "startower.mod" ).getInstance().reqTowerInitData();
|
|
}
|
|
},
|
|
|
|
// 改名
|
|
changeRoleName: function( name, sex, _cb ) {
|
|
this.SendProtocal( 10343, { name: name, sex: sex }, _cb );
|
|
},
|
|
|
|
// 改名结果
|
|
on10343: function( _data ) {
|
|
|
|
if( _data.code != 1 ) {
|
|
return;
|
|
}
|
|
|
|
this.model.setRoleAttribute( "name", _data.name );
|
|
this.model.setRoleAttribute( "sex", _data.sex );
|
|
this.model.setRoleAttribute( "is_first_rename", _data.is_first_rename );
|
|
|
|
// SDK
|
|
if( FFSDK.getInstance().isEnableSDK() &&
|
|
nx.dt.strNEmpty( _data.name ) ) {
|
|
FFSDK.getInstance().reportRoleName( _data.name );
|
|
}
|
|
},
|
|
|
|
// 升级推送
|
|
on10344: function( _data ) {
|
|
|
|
nx.bridge.createPanel( "PopupLevelUp", _data );
|
|
|
|
// SDK
|
|
if( FFSDK.getInstance().isEnableSDK() &&
|
|
nx.dt.numPositive( _data.lev, false ) ) {
|
|
FFSDK.getInstance().reportRoleLevel( _data.lev );
|
|
}
|
|
},
|
|
|
|
on10380: function( _data ){
|
|
this.openServer = _data;
|
|
},
|
|
|
|
// 媒体卡领取
|
|
sender10945: function( card_id ) {
|
|
this.SendProtocal( 10945, { card_id: card_id } );
|
|
},
|
|
|
|
on10945: function( _data ) {
|
|
nx.tbox( _data.msg );
|
|
},
|
|
|
|
// 头像框获取
|
|
send21500: function( _cb ) {
|
|
this.SendProtocal( 21500, {}, _cb );
|
|
},
|
|
|
|
on21500: function( _data ) {
|
|
|
|
// 失败判定
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
|
|
gcore.GlobalEvent.fire( RoleEvent.GetFaceList, _data );
|
|
},
|
|
|
|
// 使用头像框
|
|
send21501: function( base_id, _cb ) {
|
|
this.SendProtocal( 21501, { base_id: base_id }, _cb );
|
|
},
|
|
|
|
on21501: function( _data ) {
|
|
|
|
// 失败判定
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
// 更新头像框
|
|
on21502: function( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.GetFaceList, _data );
|
|
},
|
|
|
|
// 激活头像框
|
|
send21503: function( base_id, _cb ) {
|
|
this.SendProtocal( 21503, { base_id }, _cb );
|
|
},
|
|
|
|
on21503: function( _data ) {
|
|
|
|
// 失败判定
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
|
|
gcore.GlobalEvent.fire( RoleEvent.GetFaceList, _data );
|
|
},
|
|
|
|
// 称号列表信息
|
|
send23300: function( _cb ) {
|
|
this.SendProtocal( 23300, {}, _cb );
|
|
},
|
|
|
|
on23300: function( _data ) {
|
|
this.model.setRoleAttribute( "title_id", _data.base_id );
|
|
this.model.setRoleAttribute( "title_list", _data.honor );
|
|
gcore.GlobalEvent.fire( RoleEvent.GetTitleList, _data );
|
|
},
|
|
|
|
// 使用称号
|
|
send23301: function( base_id, _cb ) {
|
|
this.SendProtocal( 23301, { base_id: base_id }, _cb );
|
|
},
|
|
|
|
on23301: function( _data ) {
|
|
this.model.setRoleAttribute( "title_id", _data.base_id );
|
|
gcore.GlobalEvent.fire( RoleEvent.UseTitle, _data.base_id );
|
|
},
|
|
|
|
// 更新称号
|
|
on23302: function( _data ) {
|
|
this.model.setRoleAttribute( "title_list", _data.honor );
|
|
gcore.GlobalEvent.fire( RoleEvent.UpdateTitleList, _data );
|
|
},
|
|
|
|
// 激活称号
|
|
send23303: function( base_id, _cb ) {
|
|
this.SendProtocal( 23303, { base_id: base_id }, _cb );
|
|
},
|
|
|
|
on23303: function( _data ) {
|
|
this.model.setRoleAttribute( "title_list", _data.honor );
|
|
gcore.GlobalEvent.fire( RoleEvent.UpdateTitleList, _data );
|
|
},
|
|
|
|
// -- 取名界面是否正在顯示
|
|
checkRoleSetNameViewIsOpen() {
|
|
if( this.role_setname_new ) {
|
|
return true
|
|
}
|
|
return false
|
|
},
|
|
|
|
// 打开更改装饰界面
|
|
openRoleDecorateView: function( status, index, setting ) {
|
|
if( status ) {
|
|
if( !this.role_decorate_view ) {
|
|
var RoleDecorateWindow = require( "role_decorate_window" );
|
|
this.role_decorate_view = new RoleDecorateWindow();
|
|
}
|
|
this.role_decorate_view.open( index, setting );
|
|
} else {
|
|
if( this.role_decorate_view ) {
|
|
this.role_decorate_view.close();
|
|
this.role_decorate_view = null;
|
|
}
|
|
}
|
|
},
|
|
|
|
//判断一个人是否是自己
|
|
checkIsSelf: function( srv_id, rid ) {
|
|
var role_vo = this.getRoleVo();
|
|
if( role_vo == null )
|
|
return false
|
|
else
|
|
return role_vo.srv_id == srv_id && role_vo.rid == rid
|
|
},
|
|
|
|
// 当前特权情况
|
|
on24500: function( _data ) {
|
|
this.model.setPrivilegeData( _data.list )
|
|
},
|
|
|
|
// 请求开服天数
|
|
requestOpenSrvDay: function() {
|
|
this.SendProtocal( 10906, {} );
|
|
},
|
|
|
|
// 开服天数返回
|
|
on10906: function( _data ) {
|
|
this.model.setOpenSrvDay( _data.open_day );
|
|
},
|
|
|
|
// 强制改名
|
|
on10342: function() {
|
|
console.log( "开始注册姓名" )
|
|
this.need_set_name = true;
|
|
},
|
|
|
|
// 点赞数量
|
|
on10317: function() {
|
|
|
|
},
|
|
|
|
requestCrossChamWorshipNum() {
|
|
this.SendProtocal( 10319, {} )
|
|
},
|
|
|
|
on10319( _data ) {
|
|
let role_vo = this.model.getRoleVo()
|
|
if( role_vo != null ) {
|
|
role_vo.cross_cham_worship = _data.worship
|
|
gcore.GlobalEvent.fire( RoleEvent.UpdateCrossChamWorshipEvent, _data.worship )
|
|
}
|
|
},
|
|
|
|
getRandomName( sex ) {
|
|
sex = sex || 1
|
|
let randomName = ""
|
|
for( let i in game.configs.random_name_data.data_list ) {
|
|
let config = game.configs.random_name_data.data_list[ i ] || {}
|
|
// -- 取出所有符合性别要求的名称
|
|
let temp_data = []
|
|
for( let k = 0; k < config.length; ++k ) {
|
|
let v = config[ k ]
|
|
if( v && ( v.sex == sex || v.sex == 0 ) ) {
|
|
temp_data.push( v )
|
|
}
|
|
}
|
|
let random_data = temp_data[ ~~( Math.random() * temp_data.length ) ] || []
|
|
randomName = randomName + ( random_data.name || "" )
|
|
}
|
|
return randomName
|
|
},
|
|
|
|
// --[[活动资产推送]] --登陆的时候推送
|
|
handle10350( _data ) {
|
|
this.model.initRoleActionAssetsData( _data.holiday_assets, false )
|
|
},
|
|
handle10351( _data ) {
|
|
this.model.initRoleActionAssetsData( _data.holiday_assets, true )
|
|
},
|
|
|
|
// --打开举报界面
|
|
openRoleReportedPanel( status, rid, srv_id, play_name ) {
|
|
var self = this
|
|
if( status == true ) {
|
|
if( self.role_reported_panel == null ) {
|
|
let RoleReportedWindow = require( "role_reported_window" )
|
|
self.role_reported_panel = new RoleReportedWindow()
|
|
}
|
|
self.role_reported_panel.open( { rid: rid, srv_id: srv_id, play_name: play_name } )
|
|
} else {
|
|
if( self.role_reported_panel != null ) {
|
|
self.role_reported_panel.close()
|
|
self.role_reported_panel = null
|
|
}
|
|
}
|
|
},
|
|
|
|
//----------------------------------聊天框
|
|
// -- [[ 聊天框列表 ]]
|
|
sender12700( _cb ) {
|
|
this.SendProtocal( 12700, {}, _cb )
|
|
},
|
|
|
|
// -- [[ 聊天框列表 ]]
|
|
handle12700( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.GetBubbleList, _data )
|
|
},
|
|
|
|
// -- [[ 使用聊天框 ]]
|
|
sender12701( base_id, _cb ) {
|
|
let protocal = {}
|
|
protocal.base_id = base_id
|
|
this.SendProtocal( 12701, protocal, _cb )
|
|
},
|
|
|
|
// -- [[ 使用聊天框 ]]
|
|
handle12701( _data ) {
|
|
|
|
let role = this.getRoleVo();
|
|
if( role && _data && _data.base_id > 0 ) {
|
|
role.setBubble( _data.base_id );
|
|
}
|
|
|
|
gcore.GlobalEvent.fire( RoleEvent.UseBubbleItem, _data )
|
|
},
|
|
|
|
// -- [[ 更新聊天框列表 ]]
|
|
handle12702( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.GetBubbleList, _data )
|
|
},
|
|
|
|
// -- [[ 激活聊天框 ]]
|
|
sender12703( base_id, _cb ) {
|
|
let protocal = {}
|
|
protocal.base_id = base_id
|
|
this.SendProtocal( 12703, protocal, _cb )
|
|
},
|
|
|
|
// -- [[ 激活聊天框 ]]
|
|
handle12703( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.GetBubbleList, _data )
|
|
},
|
|
|
|
// -----------------------------------------------举报功能协议和打开方法-------------------------
|
|
send12770( rid, srv_id, _type, msg, history, _cb ) {
|
|
let protocal = {}
|
|
protocal.rid = rid
|
|
protocal.srv_id = srv_id
|
|
protocal.type = _type || 1
|
|
protocal.msg = msg || ""
|
|
protocal.history = history || []
|
|
this.SendProtocal( 12770, protocal, _cb )
|
|
},
|
|
send12771( rid, srv_id ) {
|
|
let protocal = {}
|
|
protocal.rid = rid
|
|
protocal.srv_id = srv_id
|
|
this.SendProtocal( 12771, protocal )
|
|
},
|
|
handle12770( _data ) {
|
|
nx.tbox( _data.msg )
|
|
},
|
|
handle12771( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.ROLE_REPORTED_EVENT, _data )
|
|
},
|
|
|
|
handle12772( _data ) {
|
|
if( _data ) {
|
|
var time = _data.end_time - client.socket.getTime();
|
|
nx.tbox( cc.js.formatStr( _data.msg, TimeTool.getTimeFormatDayIIIIII( time ) ) )
|
|
}
|
|
},
|
|
|
|
checkRoleSetNameViewIsOpen: function() {
|
|
if( this.role_setname_new )
|
|
return true
|
|
return false
|
|
},
|
|
|
|
on10306: function( _data ) {
|
|
|
|
let role = this.getRoleVo();
|
|
if( !role ) {
|
|
return;
|
|
}
|
|
|
|
let from = role.power;
|
|
if( nx.dt.numPositive( _data.power, false ) ) {
|
|
let add = _data.power - from;
|
|
nx.bridge.vset( "BPChanged", [ add, from ] );
|
|
}
|
|
|
|
role.setPower( _data.power );
|
|
role.setMaxPower( _data.max_power );
|
|
|
|
},
|
|
|
|
|
|
getApkData: function() {
|
|
if( this.apk_data ) {
|
|
return this.apk_data
|
|
}
|
|
},
|
|
handle10905( _data ) {
|
|
this.model.setWorldLev( _data.world_lev )
|
|
},
|
|
|
|
|
|
reqGetBindReward: function( _account, _cb ){
|
|
|
|
let info = { };
|
|
if( nx.dt.strNEmpty( _account ) ){
|
|
info = {
|
|
account: _account,
|
|
}
|
|
}else{
|
|
info = { };
|
|
}
|
|
// info = ? info.account = _account : info;
|
|
this.SendProtocal( 10962, info, _cb );
|
|
},
|
|
|
|
handle10962 : function( _data ){
|
|
|
|
},
|
|
|
|
//榮譽牆
|
|
//設置徽章使用
|
|
send25805( pos, id ) {
|
|
let protocal = {}
|
|
protocal.pos = pos
|
|
protocal.id = id
|
|
this.SendProtocal( 25805, protocal )
|
|
},
|
|
|
|
handle25805( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.ROLE_UPDATE_HONOR_WALL_EVENT, _data )
|
|
},
|
|
|
|
//請求所有徽章
|
|
send25806( rid, srv_id ) {
|
|
let protocal = {}
|
|
protocal.rid = rid
|
|
protocal.srv_id = srv_id
|
|
this.SendProtocal( 25806, protocal )
|
|
},
|
|
|
|
handle25806( _data ) {
|
|
gcore.GlobalEvent.fire( RoleEvent.ROLE_GET_HONOR_WALL_EVENT, _data )
|
|
},
|
|
|
|
// 激活徽章推送???????????????
|
|
handle25807( _data ) {
|
|
if( _data && _data.id ) {
|
|
this.openRoleHonorUnlockPanel( true, _data )
|
|
}
|
|
},
|
|
|
|
//分享協議
|
|
//徽章分享 --
|
|
send25815( id, channel ) {
|
|
let protocal = {}
|
|
protocal.id = id
|
|
protocal.channel = channel
|
|
this.SendProtocal( 25815, protocal )
|
|
},
|
|
|
|
handle25815( _data ) {
|
|
nx.tbox( _data.msg )
|
|
},
|
|
|
|
// 查看徽章分享
|
|
//@role_data 是 10315的協議信息
|
|
// send25816(share_id, srv_id, role_data){
|
|
// if (this.dic_share_info_25816 == null ){
|
|
// this.dic_share_info_25816 = {}
|
|
// }
|
|
// this.dic_share_info_25816[share_id] = role_data
|
|
|
|
// let protocal = {}
|
|
// protocal.share_id = share_id
|
|
// protocal.srv_id = srv_id
|
|
// this.SendProtocal(25816, protocal)
|
|
// },
|
|
|
|
// handle25816(_data){
|
|
// if (this.dic_share_info_25816 && this.dic_share_info_25816[_data.share_id]) {
|
|
// let setting = {}
|
|
// setting.id = _data.id
|
|
// setting.show_type = RoleConst.role_type.eOther
|
|
// setting.have_name = this.dic_share_info_25816[_data.share_id].name
|
|
// setting.have_time = _data.finish_time
|
|
// TipsController.getInstance().openHonorIconTips(true, setting)
|
|
// this.dic_share_info_25816[_data.share_id] = null
|
|
// }
|
|
// },
|
|
|
|
//歷練任務 成就分享
|
|
send25817( id, channel ) {
|
|
let protocal = {}
|
|
protocal.id = id
|
|
protocal.channel = channel
|
|
this.SendProtocal( 25817, protocal )
|
|
},
|
|
|
|
handle25817( _data ) {
|
|
nx.tbox( _data.msg )
|
|
},
|
|
|
|
// 查看成就分享
|
|
//@role_data 是 10315的協議信息
|
|
// send25818(share_id, srv_id, role_data){
|
|
// if (this.dic_share_info_25818 == null) {
|
|
// this.dic_share_info_25818 = {}
|
|
// }
|
|
// this.dic_share_info_25818[share_id] = role_data
|
|
|
|
// let protocal = {}
|
|
// protocal.share_id = share_id
|
|
// protocal.srv_id = srv_id
|
|
// this.SendProtocal(25818, protocal)
|
|
// },
|
|
|
|
// handle25818(_data){
|
|
// if( this.dic_share_info_25818[_data.share_id] ){
|
|
// let setting = {}
|
|
// setting.id = _data.id
|
|
// setting.have_name = this.dic_share_info_25818[_data.share_id].name
|
|
// setting.finish_time = _data.finish_time
|
|
// TipsController.getInstance().openTaskExpTips(true, setting)
|
|
// this.dic_share_info_25818[_data.share_id] = null;
|
|
// }
|
|
// },
|
|
|
|
//榮譽分享 榮譽等級
|
|
send25819( channel ) {
|
|
let protocal = {}
|
|
protocal.channel = channel
|
|
this.SendProtocal( 25819, protocal )
|
|
},
|
|
|
|
handle25819( _data ) {
|
|
nx.tbox( _data.msg )
|
|
},
|
|
|
|
// 查看榮譽分享" 榮譽等級
|
|
//@role_data 是 10315的協議信息
|
|
// send25820(share_id, srv_id, role_data){
|
|
|
|
// if (this.dic_share_info_25820 == null) {
|
|
// this.dic_share_info_25820 = {}
|
|
// }
|
|
// this.dic_share_info_25820[share_id] = role_data
|
|
|
|
// let protocal = {}
|
|
// protocal.share_id = share_id
|
|
// protocal.srv_id = srv_id
|
|
// this.SendProtocal(25820, protocal)
|
|
// },
|
|
|
|
// handle25820(_data){
|
|
// if (this.dic_share_info_25820[_data.share_id]) {
|
|
// let setting = {}
|
|
// setting.point = _data.point
|
|
// setting.num = _data.num
|
|
// setting.role_data = this.dic_share_info_25820[_data.share_id]
|
|
// TipsController.getInstance().openHonorLevelTips(true, setting)
|
|
// this.dic_share_info_25820[_data.share_id] = null
|
|
// }
|
|
// },
|
|
|
|
//成长之路---------
|
|
send25830: function( start, num ) {
|
|
let protocal = {};
|
|
protocal.start = start;
|
|
protocal.num = num;
|
|
this.SendProtocal( 25830, protocal );
|
|
},
|
|
|
|
handle25830: function( _data ) {
|
|
cc.log( "25830", _data );
|
|
//num等于1是计算红点用途
|
|
if( _data.num == 1 ) {
|
|
// _data.is_redpoint = this.model.checkGrowthWayRedPoint(_data);
|
|
}
|
|
// this.model.setGrowthWayData(_data);
|
|
},
|
|
|
|
//成长之路分享
|
|
send25831: function( channel ) {
|
|
let protocal = {};
|
|
protocal.channel = channel;
|
|
this.SendProtocal( 25831, protocal );
|
|
},
|
|
|
|
handle25831: function( _data ) {
|
|
cc.log( "25831", _data );
|
|
},
|
|
|
|
//查看成长之路分享
|
|
send25832: function( rid, srv_id, start, num ) {
|
|
let protocal = {};
|
|
protocal.rid = rid;
|
|
protocal.srv_id = srv_id;
|
|
protocal.start = start;
|
|
protocal.num = num;
|
|
this.SendProtocal( 25832, protocal );
|
|
},
|
|
|
|
handle25832: function( _data ) {
|
|
cc.log( "25832", _data );
|
|
},
|
|
|
|
//打開新的角色面板 個人空間
|
|
openRolePersonalSpacePanel: function( status, params ) {
|
|
let setting = params || {}
|
|
let role_type = setting.role_type || RoleConst.role_type.eMySelf;
|
|
|
|
|
|
if( role_type == RoleConst.role_type.eOther ) {
|
|
//由於會出現嵌套打開同一個ui界面..這裡相當於初始化兩個
|
|
this.openOtherRolePersonalSpacePanel( status, setting )
|
|
} else {
|
|
if( status ) {
|
|
if( this.role_personal_space_panel ) {
|
|
this.role_personal_space_panel.close()
|
|
this.role_personal_space_panel = null;
|
|
}
|
|
if( this.role_personal_space_panel == null ) {
|
|
var RolePersonalSpacePanel = require( "role_personal_space_panel" )
|
|
this.role_personal_space_panel = new RolePersonalSpacePanel();
|
|
}
|
|
this.role_personal_space_panel.open( setting )
|
|
} else {
|
|
if( this.role_personal_space_panel != null ) {
|
|
this.role_personal_space_panel.close()
|
|
this.role_personal_space_panel = null;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
openOtherRolePersonalSpacePanel: function( status, setting ) {
|
|
let self = this;
|
|
if( status ) {
|
|
if( self.role_other_personal_space_panel != null ) {
|
|
self.role_other_personal_space_panel.close()
|
|
self.role_other_personal_space_panel = null;
|
|
}
|
|
|
|
if( self.role_other_personal_space_panel == null ) {
|
|
var RolePersonalSpacePanel = require( "role_personal_space_panel" )
|
|
self.role_other_personal_space_panel = new RolePersonalSpacePanel();
|
|
}
|
|
self.role_other_personal_space_panel.open( setting )
|
|
} else {
|
|
if( self.role_other_personal_space_panel != null ) {
|
|
self.role_other_personal_space_panel.close()
|
|
self.role_other_personal_space_panel = null;
|
|
}
|
|
}
|
|
},
|
|
|
|
// --打開展示隊伍界面
|
|
openRoleHeroShowFormPanel: function( status, setting ) {
|
|
if( status ) {
|
|
if( this.role_hero_show_form_panel == null ) {
|
|
var RoleHeroShowFormPanel = require( "role_hero_show_form_panel" );
|
|
this.role_hero_show_form_panel = new RoleHeroShowFormPanel();
|
|
}
|
|
this.role_hero_show_form_panel.open( setting );
|
|
} else {
|
|
if( this.role_hero_show_form_panel != null ) {
|
|
this.role_hero_show_form_panel.close()
|
|
this.role_hero_show_form_panel = null;
|
|
}
|
|
}
|
|
},
|
|
|
|
// --打開兑换码
|
|
openCommonExchangeAlertPanel: function( status ) {
|
|
if( status ) {
|
|
if( this.common_exchange_alert == null ) {
|
|
var CommonExchangeAlert = require( "common_exchange_alert" );
|
|
this.common_exchange_alert = new CommonExchangeAlert();
|
|
}
|
|
this.common_exchange_alert.open();
|
|
} else {
|
|
if( this.common_exchange_alert != null ) {
|
|
this.common_exchange_alert.close()
|
|
this.common_exchange_alert = null;
|
|
}
|
|
}
|
|
},
|
|
|
|
//角色是否第一次创建
|
|
isfirstRole: function() {
|
|
let role_vo = this.getRoleVo();
|
|
if( role_vo && role_vo.sex == 2 ) return true
|
|
return false
|
|
},
|
|
|
|
// ========================================================
|
|
// 形象相关
|
|
// ========================================================
|
|
|
|
// 形象信息请求
|
|
fetchFigureData: function( _cb ) {
|
|
this.SendProtocal( 10345, {}, _cb );
|
|
},
|
|
|
|
on10345: function( _data ) {
|
|
// TODO...
|
|
},
|
|
|
|
// 形象使用
|
|
reqUseFigure: function( id, _cb ) {
|
|
this.SendProtocal( 10346, { id: id }, _cb );
|
|
},
|
|
|
|
on10346: function( _data ) {
|
|
// TODO...
|
|
gcore.GlobalEvent.fire( RoleEvent.UpdateModel, _data );
|
|
},
|
|
|
|
// 形象激活
|
|
send10347: function( id ) {
|
|
this.SendProtocal( 10347, { id: id } )
|
|
},
|
|
|
|
on10347: function( _data ) {
|
|
// TODO...
|
|
},
|
|
|
|
// ========================================================
|
|
// 桌面相关
|
|
// ========================================================
|
|
|
|
// 拥有主题信息
|
|
reqThemeData: function( _cb ) {
|
|
this.SendProtocal( 10335, {}, _cb );
|
|
},
|
|
|
|
// 拥有主题信息
|
|
on10335: function( _data ) { },
|
|
|
|
// 更换主题
|
|
reqSwapTheme: function( _id, _cb ) {
|
|
this.SendProtocal( 10336, { id: _id }, _cb );
|
|
},
|
|
|
|
// 更换主题
|
|
on10336: function( _data ) { },
|
|
|
|
dealOpenServer: function(){
|
|
|
|
let cfg = game.configs.activity_advertisement_data.data_const;
|
|
let reg_time = this.openServer.reg_time + cfg.partner_time.val;
|
|
let left = reg_time - Math.floor( cc.sys.now() / 1000 ) > 0;
|
|
|
|
let openday = this.getRoleVo().open_day;
|
|
let canshow = 0;
|
|
let acts = nx.bridge.acts;
|
|
if( acts ){
|
|
if( acts.queryThemeBySource( FID.ActAppoint8 ) ){
|
|
canshow++;
|
|
}
|
|
if( acts.queryThemeBySource( FID.ActTrain7 ) ){
|
|
canshow++;
|
|
}
|
|
|
|
if( acts.queryThemeBySource( FID.ActGrowthRush ) ){
|
|
canshow++;
|
|
}
|
|
if( acts.queryThemeBySource( FID.ActsHundreds ) ){
|
|
canshow++;
|
|
}
|
|
if( acts.queryThemeBySource( FID.ActOptional ) ){
|
|
canshow++;
|
|
}
|
|
}
|
|
|
|
let getlist = nx.bridge.vget( "SpecialPass" );
|
|
|
|
let count = 0;
|
|
let dfg = game.configs.dungeon_data.data_drama_reward;
|
|
for (let r in dfg ) {
|
|
let item = dfg[r];
|
|
let ginfo = getlist[item.id];
|
|
if( !ginfo ){
|
|
count++;
|
|
}
|
|
}
|
|
|
|
return left || canshow > 0 || count != 0;
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
module.exports = RoleController; |