XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

fix: properly track xp for modular items (#2460)

Closes #2454 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2460 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

e18b8e09
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +24 -2
Modified src/services/inventoryService.ts +24 -2
@@ -1635,6 +1635,15 @@ export const addEmailItem = async (
1635 1635 return inventoryChanges;
1636 1636 };
1637 1637
1638 const xpEarningParts: readonly string[] = [
1639 "LWPT_BLADE",
1640 "LWPT_GUN_BARREL",
1641 "LWPT_AMP_OCULUS",
1642 "LWPT_MOA_HEAD",
1643 "LWPT_ZANUKA_HEAD",
1644 "LWPT_HB_DECK"
1645 ];
1646
1638 1647 export const applyClientEquipmentUpdates = (
1639 1648 inventory: TInventoryDatabaseDocument,
1640 1649 gearArray: IEquipmentClient[],
@@ -1653,13 +1662,26 @@ export const applyClientEquipmentUpdates = (
1653 1662 item.XP ??= 0;
1654 1663 item.XP += XP;
1655 1664
1656 const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType);
1665 let xpItemType = item.ItemType;
1666 if (item.ModularParts) {
1667 for (const part of item.ModularParts) {
1668 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1669 const partType = ExportWeapons[part]?.partType;
1670 if (partType !== undefined && xpEarningParts.indexOf(partType) != -1) {
1671 xpItemType = part;
1672 break;
1673 }
1674 }
1675 logger.debug(`adding xp to ${xpItemType} for modular item ${fromOid(ItemId)} (${item.ItemType})`);
1676 }
1677
1678 const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == xpItemType);
1657 1679 if (xpinfoIndex !== -1) {
1658 1680 const xpinfo = inventory.XPInfo[xpinfoIndex];
1659 1681 xpinfo.XP += XP;
1660 1682 } else {
1661 1683 inventory.XPInfo.push({
1662 ItemType: item.ItemType,
1684 ItemType: xpItemType,
1663 1685 XP: XP
1664 1686 });
1665 1687 }