Files

208 lines
6.0 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 联盟成员列表
*
******************************************************************/
const FxSVC = require( "nx.fx.sv.expand" );
const BridgeWindow = require( "bridge.window" );
const TipsController = require( "tips_controller" );
const RoleController = require( "role_controller" );
const GuildConst = require( "guild_const" );
const GuildEvent = require( "guild_event" );
const GuildController = require( "guild_controller" );
// 工会职位
const GPT = GuildConst.PositionType;
cc.Class( {
extends: BridgeWindow,
properties: {
svcList: { default: null, type: FxSVC },
nodMemebers: { default: null, type: cc.Node },
nodAssistants: { default: null, type: cc.Node },
nodOps: { default: null, type: cc.Node },
isMgr: { default: false, displayName: "管理模式" },
},
// 显示
onEnable: function() {
this.ctrl = GuildController.getInstance();
this.model = this.ctrl.getModel();
nx.gui.setActive( this.nodOps, "impeach", false );
// 事件监听
this.bindGEvent( GuildEvent.UpdateMyMemberListEvent, this.onFreshList.bind( this ) );
this.bindGEvent( GuildEvent.UpdateAssistantNumEvent, this.onFreshAssistantCount.bind( this ) );
// 更新成员列表
this.ctrl.reqMemberList( ( _ret, _data ) => {
if( !_ret ) {
nx.tbox( _data );
return;
}
this.onFreshAssistantCount();
} );
},
// 关闭
onDisable: function() {
this.unbindGEvents();
},
// 成员更新
onFreshList: function( _type ) {
let list = this.model.getGuildMemberList();
this.svcList.rebuild( list );
// 弹劾操作检查
this.checkImpeach();
},
// 管理数量更新
onFreshAssistantCount: function() {
// 总人数
let info = this.model.getMyGuildInfo();
nx.gui.setString( this.nodMemebers, "cur", info.members_num );
nx.gui.setString( this.nodMemebers, "max", info.members_max );
// 副盟主
let key = Utils.getNorKey( GPT.Assistant, info.lev );
let cfg = game.configs.guild_data.data_post[ key ];
if( cfg ) {
let num = this.model.getAssistantSum();
nx.gui.setString( this.nodAssistants, "cur", num );
nx.gui.setString( this.nodAssistants, "max", cfg.num );
}
},
// 弹劾操作检查
checkImpeach: function() {
// 弹劾操作控制
let role = RoleController.getInstance().getRoleVo();
if( role.position == GPT.Leader ) {
nx.gui.setActive( this.nodOps, "impeach", false );
return;
}
// 盟主离线时间检查
let show = false;
let list = this.model.getGuildMemberList();
let time = game.configs.guild_data.data_const.impeach_offline_day2.val;
for( let i in list ) {
let member = list[ i ];
if( !member || member.post != GPT.Leader ) {
continue;
}
let dt = client.socket.getTime() - member.login_time;
if( dt >= 86400 * time ) {
show = true;
break;
}
}
nx.gui.setActive( this.nodOps, "impeach", show );
},
// 帮助
onTouchHelp: function() {
let TC = TipsController.getInstance();
let config = game.configs.guild_data.data_const.game_rule;
if( TC && config && nx.dt.strNEmpty( config.desc ) ) {
TC.showTextPanel( "tip", nx.text.getKey( config.desc ) );
}
},
// 弹劾
onTouchImpeach: function() {
let cost = gdata( "guild_data", "data_const", "impeach_gold" );
let id = cost.val[ 0 ][ 0 ];
let num = cost.val[ 0 ][ 1 ];
if( !nx.dt.numPositive( id, false ) ||
!nx.dt.numPositive( num, false ) ) {
nx.error( "无效弹劾消耗配置!" );
return;
}
let self = this;
let txt = nx.text.format( "GuildImpeachTip", id, num );
nx.mbox( txt, [ 'cancel', 'confirm' ], ( _key, _box ) => {
_box.close();
if( _key == 'confirm' ) {
self.ctrl.send13565( ( _ret, _data ) => {
if( !_ret ) {
nx.tbox( _data );
return;
}
self.checkImpeach();
} );
}
} );
},
// 退帮
onTouchQuit: function() {
// 解散帮派
let self = this;
let role = RoleController.getInstance().getRoleVo();
if( role.position == GPT.Leader ) {
let key = ( role.guild_quit_time == 0 ) ? "GuildDissolveAskFst" : "GuildDissolveAsk";
let msg = nx.text.format( key, role.gname );
nx.mbox( msg, [ 'cancel', 'confirm' ], ( _key, _box ) => {
_box.close();
if( _key == 'confirm' ) {
self.ctrl.reqDissolve( ( _ret, _data ) => {
if( !_ret ) {
nx.tbox( _data );
return;
}
nx.bridge.closePanel( "WndGuild" );
self.model.clearMyGuildInfo();
} );
}
} );
return;
}
// 普通退帮
let key = ( role.guild_quit_time == 0 ) ? "GuildQuitAskFst" : "GuildQuitAsk";
let msg = nx.text.format( key, role.gname );
nx.mbox( msg, [ 'cancel', 'confirm' ], ( _key, _box ) => {
_box.close();
if( _key == 'confirm' ) {
self.ctrl.reqQuit( ( _ret, _data ) => {
if( !_ret ) {
nx.tbox( _data );
return;
}
nx.bridge.closePanel( "WndGuild" );
self.model.clearMyGuildInfo();
} );
}
} );
},
} );