|
|
|
|
@ -86,10 +86,24 @@ export class GemDataManager extends Singleton { |
|
|
|
|
if (free <= 0) continue; |
|
|
|
|
list.push({ gemId, count: free }); |
|
|
|
|
} |
|
|
|
|
list.sort((a, b) => this._compareBag(a, b)); |
|
|
|
|
list.sort((a, b) => this.compareBagEntry(a, b)); |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 仓库条目比较:Weapon.sort 升序,同值 id 升序。 |
|
|
|
|
* @param a 条目 A |
|
|
|
|
* @param b 条目 B |
|
|
|
|
*/ |
|
|
|
|
compareBagEntry(a: IGemBagEntry, b: IGemBagEntry): number { |
|
|
|
|
const ca = this.getGem(a.gemId); |
|
|
|
|
const cb = this.getGem(b.gemId); |
|
|
|
|
const sa = Math.floor(Number(ca?.sort) || 0); |
|
|
|
|
const sb = Math.floor(Number(cb?.sort) || 0); |
|
|
|
|
if (sa !== sb) return sa - sb; |
|
|
|
|
return a.gemId - b.gemId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 五行 4 槽宝石 id(长度固定 4,空为 0) */ |
|
|
|
|
getElementSlots(element: number): number[] { |
|
|
|
|
const e = Math.floor(Number(element) || 0); |
|
|
|
|
@ -373,16 +387,6 @@ export class GemDataManager extends Singleton { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 仓库排序:品质降序,id 升序 */ |
|
|
|
|
private _compareBag(a: IGemBagEntry, b: IGemBagEntry): number { |
|
|
|
|
const ca = this.getGem(a.gemId); |
|
|
|
|
const cb = this.getGem(b.gemId); |
|
|
|
|
const qa = Math.floor(Number(ca?.quality) || 0); |
|
|
|
|
const qb = Math.floor(Number(cb?.quality) || 0); |
|
|
|
|
if (qa !== qb) return qb - qa; |
|
|
|
|
return a.gemId - b.gemId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 卸掉非法镶嵌 */ |
|
|
|
|
private _stripIllegalWears(): void { |
|
|
|
|
let dirty = false; |
|
|
|
|
|