Files
fc/dev/project/assets/Scripts/mod/partner/cmps/basic/cmp.partner.equip.select.wnd.js
T

105 lines
3.0 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 礼包选择界面
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const FxSVC = require( "nx.fx.sv.expand" );
const BackPackConst = require( "backpack_const" );
const BackPackController = require( "backpack_controller" );
const BBC = BackPackConst.Bag_Code;
const BIT = BackPackConst.item_type;
const BITT = BackPackConst.item_sub_type;
cc.Class( {
extends: BridgeWindow,
properties: {
svcList: {
default: null,
type: FxSVC,
},
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
this.etype = _params.etype.type;
this.partner = _params.etype.partner_id;
this.cb = _params.cb;
const BC = BackPackController.getInstance();
const model = BC.getModel();
let wcfg = game.configs.weapon_data.data_get_skill;
// 统计该类型装备列表
let eqms = [];
let list = {};
if( this.etype == BIT.ARTIFACTCHIPS ) {
list = model.getAllBackPackArray( BITT.SPECIAL ) || {};
}else if( this.etype == BIT.GOD_EARRING || this.etype == BIT.GOD_RING ||
this.etype == BIT.GOD_NECKLACE || this.etype == BIT.GOD_BANGLE ){
list = model.getAllBackPackArray( BITT.HOLYEQUIPMENT ) || {};
}else {
list = model.getBagItemList( BBC.EQUIPS ) || {};
}
// 统计匹配项
for( let i in list ) {
let eqm = list[ i ];
if( eqm && eqm.config && eqm.config.type == this.etype ) {
if( eqm.config.type == BIT.Exclusive ){
if( wcfg[eqm.base_id].partner_id == this.partner ){
eqms.push( eqm );
}
}else{
eqms.push( eqm );
}
}
}
// 排序
let empty = nx.dt.arrEmpty( eqms );
if( !empty ) {
if( this.etype == BIT.ARTIFACTCHIPS ) {
eqms.sort( ( objA, objB ) => {
if( objA.enchant != objB.enchant ) {
return objB.enchant - objA.enchant;
} else if( objA.config && objB.config ) {
return objB.config.quality - objA.config.quality;
} else {
return -1;
}
} );
}
else {
eqms.sort( Utils.tableUpperSorter( [ "all_score" ] ) );
}
}
// 刷新
nx.gui.setActive( this.svcList, "empty", empty );
this.svcList.rebuild( eqms );
this.svcList.binder = this;
},
// 选中装备
onEquip: function( _item ) {
if( _item && nx.dt.numPositive( _item.id, false ) ) {
nx.dt.fnInvoke( this.cb, _item.id, this );
}
},
} );