fix: properly track xp for modular items (#2460)
Closes #2454 Reviewed-on: #2460 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
0d8044b87c
commit
e18b8e09ea
@ -1635,6 +1635,15 @@ export const addEmailItem = async (
|
|||||||
return inventoryChanges;
|
return inventoryChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const xpEarningParts: readonly string[] = [
|
||||||
|
"LWPT_BLADE",
|
||||||
|
"LWPT_GUN_BARREL",
|
||||||
|
"LWPT_AMP_OCULUS",
|
||||||
|
"LWPT_MOA_HEAD",
|
||||||
|
"LWPT_ZANUKA_HEAD",
|
||||||
|
"LWPT_HB_DECK"
|
||||||
|
];
|
||||||
|
|
||||||
export const applyClientEquipmentUpdates = (
|
export const applyClientEquipmentUpdates = (
|
||||||
inventory: TInventoryDatabaseDocument,
|
inventory: TInventoryDatabaseDocument,
|
||||||
gearArray: IEquipmentClient[],
|
gearArray: IEquipmentClient[],
|
||||||
@ -1653,13 +1662,26 @@ export const applyClientEquipmentUpdates = (
|
|||||||
item.XP ??= 0;
|
item.XP ??= 0;
|
||||||
item.XP += XP;
|
item.XP += XP;
|
||||||
|
|
||||||
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType);
|
let xpItemType = item.ItemType;
|
||||||
|
if (item.ModularParts) {
|
||||||
|
for (const part of item.ModularParts) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
const partType = ExportWeapons[part]?.partType;
|
||||||
|
if (partType !== undefined && xpEarningParts.indexOf(partType) != -1) {
|
||||||
|
xpItemType = part;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.debug(`adding xp to ${xpItemType} for modular item ${fromOid(ItemId)} (${item.ItemType})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == xpItemType);
|
||||||
if (xpinfoIndex !== -1) {
|
if (xpinfoIndex !== -1) {
|
||||||
const xpinfo = inventory.XPInfo[xpinfoIndex];
|
const xpinfo = inventory.XPInfo[xpinfoIndex];
|
||||||
xpinfo.XP += XP;
|
xpinfo.XP += XP;
|
||||||
} else {
|
} else {
|
||||||
inventory.XPInfo.push({
|
inventory.XPInfo.push({
|
||||||
ItemType: item.ItemType,
|
ItemType: xpItemType,
|
||||||
XP: XP
|
XP: XP
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user