mirror of
https://github.com/motajs/template.git
synced 2026-10-17 11:40:16 +08:00
feat: 与空装备对比
This commit is contained in:
parent
751f206829
commit
ea7a404cc6
@ -261,12 +261,8 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
|||||||
): Readonly<Partial<THero>> {
|
): Readonly<Partial<THero>> {
|
||||||
const stateA = this.store.get(equipA);
|
const stateA = this.store.get(equipA);
|
||||||
const stateB = this.store.get(equipB);
|
const stateB = this.store.get(equipB);
|
||||||
if (!stateA) {
|
if (!stateA && !stateB) {
|
||||||
logger.warn(146, equipA.toString());
|
logger.warn(195, equipA.toString(), equipB.toString());
|
||||||
return {} as Partial<THero>;
|
|
||||||
}
|
|
||||||
if (!stateB) {
|
|
||||||
logger.warn(146, equipB.toString());
|
|
||||||
return {} as Partial<THero>;
|
return {} as Partial<THero>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +292,7 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
|||||||
const attrB: Partial<THero> = {};
|
const attrB: Partial<THero> = {};
|
||||||
const keys = new Set<SelectKey<THero, number>>();
|
const keys = new Set<SelectKey<THero, number>>();
|
||||||
|
|
||||||
const modifiersA = [...stateA.getModifiers()];
|
const modifiersA = stateA ? [...stateA.getModifiers()] : [];
|
||||||
const addedA: typeof modifiersA = [];
|
const addedA: typeof modifiersA = [];
|
||||||
for (const [name, modifier] of modifiersA) {
|
for (const [name, modifier] of modifiersA) {
|
||||||
const copy = modifier.clone();
|
const copy = modifier.clone();
|
||||||
@ -304,7 +300,7 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
|||||||
clone.addModifier(name, copy);
|
clone.addModifier(name, copy);
|
||||||
addedA.push([name, copy]);
|
addedA.push([name, copy]);
|
||||||
}
|
}
|
||||||
for (const [name] of stateA.getModifiers()) {
|
for (const [name] of modifiersA) {
|
||||||
attrA[name] = clone.getFinalAttribute(name);
|
attrA[name] = clone.getFinalAttribute(name);
|
||||||
keys.add(name);
|
keys.add(name);
|
||||||
}
|
}
|
||||||
@ -313,12 +309,13 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
|||||||
clone.deleteModifier(name, copy);
|
clone.deleteModifier(name, copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [name, modifier] of stateB.getModifiers()) {
|
const modifiersB = stateB ? [...stateB.getModifiers()] : [];
|
||||||
|
for (const [name, modifier] of modifiersB) {
|
||||||
const copy = modifier.clone();
|
const copy = modifier.clone();
|
||||||
// @ts-expect-error 泛型无法推导
|
// @ts-expect-error 泛型无法推导
|
||||||
clone.addModifier(name, copy);
|
clone.addModifier(name, copy);
|
||||||
}
|
}
|
||||||
for (const [name] of stateB.getModifiers()) {
|
for (const [name] of modifiersB) {
|
||||||
attrB[name] = clone.getFinalAttribute(name);
|
attrB[name] = clone.getFinalAttribute(name);
|
||||||
keys.add(name);
|
keys.add(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -865,8 +865,8 @@ export interface IHeroEquipment<THero>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 比较两个装备在指定槽位的表现,输出装备 A 时的属性减装备 B 时的属性
|
* 比较两个装备在指定槽位的表现,输出装备 A 时的属性减装备 B 时的属性
|
||||||
* @param equipA 要比较的装备 A 的 uid
|
* @param equipA 要比较的装备 A 的 uid,填写 -1 表示无装备
|
||||||
* @param equipB 要比较的装备 B 的 uid
|
* @param equipB 要比较的装备 B 的 uid,填写 -1 表示无装备
|
||||||
* @param slot 要比较的装备槽索引
|
* @param slot 要比较的装备槽索引
|
||||||
*/
|
*/
|
||||||
compareEquip(
|
compareEquip(
|
||||||
|
|||||||
@ -278,6 +278,7 @@
|
|||||||
"192": "A FaceGroup.Dir8 face handler registration is expected.",
|
"192": "A FaceGroup.Dir8 face handler registration is expected.",
|
||||||
"193": "Cannot load item state since no item id registration for item num $1.",
|
"193": "Cannot load item state since no item id registration for item num $1.",
|
||||||
"194": "Expected passive replay command executed during the last active replay command executing, but a passive command $1 was got after active replay command $2 executing. Replay will continue and ignore this issue.",
|
"194": "Expected passive replay command executed during the last active replay command executing, but a passive command $1 was got after active replay command $2 executing. Replay will continue and ignore this issue.",
|
||||||
|
"195": "Cannot compare equipments since both equipments not exists. Equip A: $1, Equip B: $2.",
|
||||||
"1001": "Event(setBlock): Unknown tile '$1' when setting block."
|
"1001": "Event(setBlock): Unknown tile '$1' when setting block."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user