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

feat: initial protovyre/evolving cosmetics (#2566)

Basic handling of sending the challenge rewards to the inbox upon completion. Re #2485. Still missing handling for the Protovyre armor pieces which require killing sentients. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2566 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

3 个文件 +74 -11
Modified src/controllers/api/updateChallengeProgressController.ts +2 -1
@@ -10,6 +10,7 @@ import { logger } from "@/src/utils/logger";
10 10 export const updateChallengeProgressController: RequestHandler = async (req, res) => {
11 11 const challenges = getJSONfromString<IUpdateChallengeProgressRequest>(String(req.body));
12 12 const account = await getAccountForRequest(req);
13 logger.debug(`challenge report:`, challenges);
13 14
14 15 const inventory = await getInventory(
15 16 account._id.toString(),
@@ -17,7 +18,7 @@ export const updateChallengeProgressController: RequestHandler = async (req, res
17 18 );
18 19 let affiliationMods: IAffiliationMods[] = [];
19 20 if (challenges.ChallengeProgress) {
20 affiliationMods = addChallenges(
21 affiliationMods = await addChallenges(
21 22 account,
22 23 inventory,
23 24 challenges.ChallengeProgress,
Modified src/services/inventoryService.ts +71 -9
@@ -1904,25 +1904,87 @@ export const addLoreFragmentScans = (inventory: TInventoryDatabaseDocument, arr:
1904 1904 });
1905 1905 };
1906 1906
1907 export const addChallenges = (
1907 const challengeRewardsInboxMessages: Record<string, IMessageCreationTemplate> = {
1908 SentEvoEphemeraRankOne: {
1909 sub: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockAName",
1910 sndr: "/Lotus/Language/Bosses/Ordis",
1911 msg: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockADesc",
1912 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
1913 att: ["/Lotus/Upgrades/Skins/Effects/NarmerEvolvingEphemeraB"]
1914 },
1915 SentEvoEphemeraRankTwo: {
1916 sub: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockBName",
1917 sndr: "/Lotus/Language/Bosses/Ordis",
1918 msg: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockBDesc",
1919 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
1920 att: ["/Lotus/Upgrades/Skins/Effects/NarmerEvolvingEphemeraC"]
1921 },
1922 SentEvoSyandanaRankOne: {
1923 sub: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockAName",
1924 sndr: "/Lotus/Language/Bosses/Ordis",
1925 msg: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockADesc",
1926 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
1927 att: ["/Lotus/Upgrades/Skins/Scarves/NarmerEvolvingSyandanaBCape"]
1928 },
1929 SentEvoSyandanaRankTwo: {
1930 sub: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockBName",
1931 sndr: "/Lotus/Language/Bosses/Ordis",
1932 msg: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockBDesc",
1933 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
1934 att: ["/Lotus/Upgrades/Skins/Scarves/NarmerEvolvingSyandanaCCape"]
1935 },
1936 SentEvoSekharaRankOne: {
1937 sub: "/Lotus/Language/Inbox/EvolvingSekharaUnlockAName",
1938 sndr: "/Lotus/Language/Bosses/Ordis",
1939 msg: "/Lotus/Language/Inbox/EvolvingSekharaUnlockADesc",
1940 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
1941 att: ["/Lotus/Upgrades/Skins/Clan/ZarimanEvolvingSekharaBadgeItemB"]
1942 },
1943 SentEvoSekharaRankTwo: {
1944 sub: "/Lotus/Language/Inbox/EvolvingSekharaUnlockBName",
1945 sndr: "/Lotus/Language/Bosses/Ordis",
1946 msg: "/Lotus/Language/Inbox/EvolvingSekharaUnlockBDesc",
1947 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
1948 att: ["/Lotus/Upgrades/Skins/Clan/ZarimanEvolvingSekharaBadgeItemC"]
1949 }
1950 };
1951
1952 export const addChallenges = async (
1908 1953 account: TAccountDocument,
1909 1954 inventory: TInventoryDatabaseDocument,
1910 1955 ChallengeProgress: IChallengeProgress[],
1911 1956 SeasonChallengeCompletions: ISeasonChallenge[] | undefined
1912 ): IAffiliationMods[] => {
1913 ChallengeProgress.forEach(({ Name, Progress }) => {
1914 const itemIndex = inventory.ChallengeProgress.findIndex(i => i.Name === Name);
1915
1916 if (itemIndex !== -1) {
1917 inventory.ChallengeProgress[itemIndex].Progress = Progress;
1957 ): Promise<IAffiliationMods[]> => {
1958 for (const { Name, Progress, Completed } of ChallengeProgress) {
1959 let dbChallenge = inventory.ChallengeProgress.find(x => x.Name == Name);
1960 if (dbChallenge) {
1961 dbChallenge.Progress = Progress;
1918 1962 } else {
1919 inventory.ChallengeProgress.push({ Name, Progress });
1963 dbChallenge = { Name, Progress };
1964 inventory.ChallengeProgress.push(dbChallenge);
1920 1965 }
1921 1966
1922 1967 if (Name.startsWith("Calendar")) {
1923 1968 addString(getCalendarProgress(inventory).SeasonProgress.ActivatedChallenges, Name);
1924 1969 }
1925 });
1970
1971 if ((Completed?.length ?? 0) > (dbChallenge.Completed?.length ?? 0)) {
1972 dbChallenge.Completed ??= [];
1973 for (const completion of Completed!) {
1974 if (dbChallenge.Completed.indexOf(completion) == -1) {
1975 if (completion == "challengeRewards") {
1976 if (Name in challengeRewardsInboxMessages) {
1977 await createMessage(account._id, [challengeRewardsInboxMessages[Name]]);
1978 dbChallenge.Completed.push(completion);
1979 // Would love to somehow let the client know about inbox or inventory changes, but there doesn't seem to anything for updateChallengeProgress.
1980 continue;
1981 }
1982 }
1983 logger.warn(`ignoring unknown challenge completion`, { challenge: Name, completion });
1984 }
1985 }
1986 }
1987 }
1926 1988
1927 1989 const affiliationMods: IAffiliationMods[] = [];
1928 1990 if (SeasonChallengeCompletions) {
Modified src/services/missionInventoryUpdateService.ts +1 -1
@@ -292,7 +292,7 @@ export const addMissionInventoryUpdates = async (
292 292 addRecipes(inventory, value);
293 293 break;
294 294 case "ChallengeProgress":
295 addChallenges(account, inventory, value, inventoryUpdates.SeasonChallengeCompletions);
295 await addChallenges(account, inventory, value, inventoryUpdates.SeasonChallengeCompletions);
296 296 break;
297 297 case "FusionTreasures":
298 298 addFusionTreasures(inventory, value);