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: don't apply daily standing cap twice (#4278)

```js AffiliationChanges: [ { Tag: 'LibrarySyndicate', Standing: 30, Title: 0 } ], DailyAffiliationLibrary: 30, ``` Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4278 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

2 个文件 +16 -34
Modified src/services/inventoryService.ts +4 -31
@@ -32,7 +32,7 @@ import type {
32 32 } from "../types/inventoryTypes/inventoryTypes.ts";
33 33 import { eInventorySlot, equipmentKeys, slotNames } from "../types/inventoryTypes/inventoryTypes.ts";
34 34 import type { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdateTypes.ts";
35 import type { IGoalsProgress, IKeyChainRequest, IMissionInventoryUpdateRequest } from "../types/requestTypes.ts";
35 import type { IGoalsProgress, IKeyChainRequest } from "../types/requestTypes.ts";
36 36 import { logger } from "../utils/logger.ts";
37 37 import {
38 38 convertInboxMessage,
@@ -1883,7 +1883,7 @@ export const addStanding = async (
1883 1883 syndicateTag: string,
1884 1884 gainedStanding: number,
1885 1885 affiliationMods: IAffiliationMods[] = [],
1886 isMedallion: boolean = false,
1886 applyDailyCap: boolean = false,
1887 1887 propagateAlignments: boolean = true
1888 1888 ): Promise<void> => {
1889 1889 let syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
@@ -1901,7 +1901,7 @@ export const addStanding = async (
1901 1901 gainedStanding = -71000 - syndicate.Standing;
1902 1902 }
1903 1903
1904 if (!isMedallion || syndicateMeta.medallionsCappedByDailyLimit) {
1904 if (!applyDailyCap || syndicateMeta.medallionsCappedByDailyLimit) {
1905 1905 if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
1906 1906 gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
1907 1907 }
@@ -1924,7 +1924,7 @@ export const addStanding = async (
1924 1924 tag,
1925 1925 gainedStanding * factor,
1926 1926 affiliationMods,
1927 isMedallion,
1927 applyDailyCap,
1928 1928 false
1929 1929 );
1930 1930 }
@@ -2846,33 +2846,6 @@ export const setBooster = (ItemType: string, expiryTimeSecs: number, inventory:
2846 2846 }
2847 2847 };
2848 2848
2849 export const updateSyndicate = async (
2850 inventory: TInventoryDatabaseDocument,
2851 buildLabel: string,
2852 syndicateUpdate: IMissionInventoryUpdateRequest["AffiliationChanges"]
2853 ): Promise<void> => {
2854 if (!syndicateUpdate) return;
2855
2856 for (const affiliation of syndicateUpdate) {
2857 const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag);
2858 const syndicateMeta = await getSyndicate(affiliation.Tag, buildLabel);
2859 if (syndicate !== undefined) {
2860 syndicate.Standing += affiliation.Standing;
2861 syndicate.Title = syndicate.Title === undefined ? affiliation.Title : syndicate.Title + affiliation.Title;
2862 } else {
2863 inventory.Affiliations.push({
2864 Standing: affiliation.Standing,
2865 Title: affiliation.Title,
2866 Tag: affiliation.Tag,
2867 FreeFavorsEarned: [],
2868 FreeFavorsUsed: []
2869 });
2870 }
2871
2872 updateStandingLimit(inventory, syndicateMeta!.dailyLimitBin, affiliation.Standing);
2873 }
2874 };
2875
2876 2849 /**
2877 2850 * @returns object with inventory keys of changes or empty object when no items were added
2878 2851 */
Modified src/services/missionInventoryUpdateService.ts +12 -3
@@ -54,8 +54,7 @@ import {
54 54 processGoalProgressUpdates,
55 55 updateCurrency,
56 56 updateEntratiVault,
57 updateIncentiveStates,
58 updateSyndicate
57 updateIncentiveStates
59 58 } from "./inventoryService.ts";
60 59 import { addQuestKey, updateQuestKey } from "./questService.ts";
61 60 import { Types } from "mongoose";
@@ -358,7 +357,17 @@ export const addMissionInventoryUpdates = async (
358 357 await updateQuestKey(inventory, value);
359 358 break;
360 359 case "AffiliationChanges":
361 await updateSyndicate(inventory, buildLabel, value);
360 for (const affiliation of value) {
361 await addStanding(
362 inventory,
363 buildLabel,
364 affiliation.Tag,
365 affiliation.Standing,
366 undefined,
367 false, // affiliation bin changes are handled by the client, no need to do it twice
368 false
369 );
370 }
362 371 break;
363 372 // Incarnon Challenges
364 373 case "EvolutionProgress": {