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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

chore: rewrite challenge rewards logic to avoid hardcoded data (#3193)

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

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

代码差异

3 个文件 +22 -111
Modified package-lock.json +4 -4
@@ -18,7 +18,7 @@
18 18 "morgan": "^1.10.0",
19 19 "ncp": "^2.0.0",
20 20 "undici": "^7.10.0",
21 "warframe-public-export-plus": "^0.5.97",
21 "warframe-public-export-plus": "^0.5.98",
22 22 "warframe-riven-info": "^0.1.2",
23 23 "winston": "^3.17.0",
24 24 "winston-daily-rotate-file": "^5.0.0",
@@ -6033,9 +6033,9 @@
6033 6033 }
6034 6034 },
6035 6035 "node_modules/warframe-public-export-plus": {
6036 "version": "0.5.97",
6037 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.97.tgz",
6038 "integrity": "sha512-Xe07uNXT7Pci0yDIdREHuJBx+uTspf/qmPNh0oprjSlyFlib4HjrKm2iSNnw9q4NUqxzv42SwumMD8hCsAOnng=="
6036 "version": "0.5.98",
6037 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.98.tgz",
6038 "integrity": "sha512-BGJHwqq4KXG2qnTdKuxTK4zhHBqpbtFODT4DDt3SyYT1zrawHaVbM7r/mKw3YItPKmrfNTU0r4lxdkrWu7SB/Q=="
6039 6039 },
6040 6040 "node_modules/warframe-riven-info": {
6041 6041 "version": "0.1.2",
Modified package.json +1 -1
@@ -35,7 +35,7 @@
35 35 "morgan": "^1.10.0",
36 36 "ncp": "^2.0.0",
37 37 "undici": "^7.10.0",
38 "warframe-public-export-plus": "^0.5.97",
38 "warframe-public-export-plus": "^0.5.98",
39 39 "warframe-riven-info": "^0.1.2",
40 40 "winston": "^3.17.0",
41 41 "winston-daily-rotate-file": "^5.0.0",
Modified src/services/inventoryService.ts +17 -106
@@ -2277,100 +2277,10 @@ export const addLoreFragmentScans = (inventory: TInventoryDatabaseDocument, arr:
2277 2277 });
2278 2278 };
2279 2279
2280 const challengeRewardsInboxMessages: Record<string, IMessageCreationTemplate> = {
2281 SentEvoEphemeraRankOne: {
2282 sub: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockAName",
2283 sndr: "/Lotus/Language/Bosses/Ordis",
2284 msg: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockADesc",
2285 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2286 att: ["/Lotus/Upgrades/Skins/Effects/NarmerEvolvingEphemeraB"]
2287 },
2288 SentEvoEphemeraRankTwo: {
2289 sub: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockBName",
2290 sndr: "/Lotus/Language/Bosses/Ordis",
2291 msg: "/Lotus/Language/Inbox/EvolvingEphemeraUnlockBDesc",
2292 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2293 att: ["/Lotus/Upgrades/Skins/Effects/NarmerEvolvingEphemeraC"]
2294 },
2295 SentEvoSyandanaRankOne: {
2296 sub: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockAName",
2297 sndr: "/Lotus/Language/Bosses/Ordis",
2298 msg: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockADesc",
2299 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2300 att: ["/Lotus/Upgrades/Skins/Scarves/NarmerEvolvingSyandanaBCape"]
2301 },
2302 SentEvoSyandanaRankTwo: {
2303 sub: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockBName",
2304 sndr: "/Lotus/Language/Bosses/Ordis",
2305 msg: "/Lotus/Language/Inbox/EvolvingSyandanaUnlockBDesc",
2306 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2307 att: ["/Lotus/Upgrades/Skins/Scarves/NarmerEvolvingSyandanaCCape"]
2308 },
2309 SentEvoSekharaRankOne: {
2310 sub: "/Lotus/Language/Inbox/EvolvingSekharaUnlockAName",
2311 sndr: "/Lotus/Language/Bosses/Ordis",
2312 msg: "/Lotus/Language/Inbox/EvolvingSekharaUnlockADesc",
2313 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2314 att: ["/Lotus/Upgrades/Skins/Clan/ZarimanEvolvingSekharaBadgeItemB"]
2315 },
2316 SentEvoSekharaRankTwo: {
2317 sub: "/Lotus/Language/Inbox/EvolvingSekharaUnlockBName",
2318 sndr: "/Lotus/Language/Bosses/Ordis",
2319 msg: "/Lotus/Language/Inbox/EvolvingSekharaUnlockBDesc",
2320 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2321 att: ["/Lotus/Upgrades/Skins/Clan/ZarimanEvolvingSekharaBadgeItemC"]
2322 },
2323 // In theory, the following should only give what is owned, but based on the limited information I can find, DE may have simply taken the easy way: https://www.reddit.com/r/Warframe/comments/rzlnku/receiving_all_protovyre_armor_evolution_but_only/
2324 SentEvoArmorRankOne: {
2325 sub: "/Lotus/Language/Inbox/EvolvingArmorUnlockAName",
2326 sndr: "/Lotus/Language/Bosses/Ordis",
2327 msg: "/Lotus/Language/Inbox/EvolvingArmorUnlockADesc",
2328 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2329 att: [
2330 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2A",
2331 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2C",
2332 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2L"
2333 ]
2334 },
2335 SentEvoArmorRankTwo: {
2336 sub: "/Lotus/Language/Inbox/EvolvingArmorUnlockBName",
2337 sndr: "/Lotus/Language/Bosses/Ordis",
2338 msg: "/Lotus/Language/Inbox/EvolvingArmorUnlockBDesc",
2339 icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
2340 att: [
2341 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor3A",
2342 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor3C",
2343 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor3L"
2344 ]
2345 }
2346 };
2347
2348 /*const evolvingWeaponSkins: Record<string, { challenge: keyof typeof challengeRewardsInboxMessages; reward: string }> = {
2349 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor1A": {
2350 challenge: "SentEvoArmorRankOne",
2351 reward: "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2A"
2352 },
2353 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor1C": {
2354 challenge: "SentEvoArmorRankOne",
2355 reward: "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2C"
2356 },
2357 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor1L": {
2358 challenge: "SentEvoArmorRankOne",
2359 reward: "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2L"
2360 },
2361 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2A": {
2362 challenge: "SentEvoArmorRankTwo",
2363 reward: "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor3A"
2364 },
2365 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2C": {
2366 challenge: "SentEvoArmorRankTwo",
2367 reward: "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor3C"
2368 },
2369 "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor2L": {
2370 challenge: "SentEvoArmorRankTwo",
2371 reward: "/Lotus/Upgrades/Skins/Armor/SentEvoArmor/SentEvoArmor3L"
2372 }
2373 };*/
2280 const challengeNameToPath: Record<string, string> = {};
2281 for (const path of Object.keys(ExportChallenges)) {
2282 challengeNameToPath[path.split("/").pop()!] = path;
2283 }
2374 2284
2375 2285 export const addChallenges = async (
2376 2286 account: TAccountDocument,
@@ -2398,23 +2308,24 @@ export const addChallenges = async (
2398 2308 if (dbChallenge.Completed.indexOf(completion) == -1) {
2399 2309 dbChallenge.Completed.push(completion);
2400 2310 if (completion == "challengeRewards") {
2401 if (Name in challengeRewardsInboxMessages) {
2402 logger.debug(`did a challenge for evolving armour, sending inbox message`);
2403 await createMessage(account._id, [challengeRewardsInboxMessages[Name]]);
2311 const path = challengeNameToPath[Name];
2312 const meta = ExportChallenges[path];
2313 if (meta.message) {
2314 logger.debug(`${Name} completed, sending inbox message`);
2315 await createMessage(account._id, [convertInboxMessage(meta.message)]);
2404 2316 continue;
2405 2317 }
2406 if (`/Lotus/Types/Challenges/Titles/${Name}` in ExportChallenges) {
2407 if (ExportChallenges[`/Lotus/Types/Challenges/Titles/${Name}`].countedRewards) {
2408 const titleType = fromStoreItem(
2409 ExportChallenges[`/Lotus/Types/Challenges/Titles/${Name}`].countedRewards![0]
2410 .StoreItem
2318 if (meta.countedRewards) {
2319 logger.debug(`${Name} completed, giving rewards:`, meta.countedRewards);
2320 for (const cr of meta.countedRewards) {
2321 combineInventoryChanges(
2322 inventoryChanges,
2323 await addItem(inventory, fromStoreItem(cr.StoreItem), cr.ItemCount)
2411 2324 );
2412 logger.debug(`${Name} completed, giving ${titleType}`);
2413 addCustomization(inventory, titleType, inventoryChanges);
2414 continue;
2415 2325 }
2326 continue;
2416 2327 }
2417 logger.warn(`ignoring unknown challenge completion`, { challenge: Name, completion });
2328 logger.warn(`ignoring unknown challenge completion`, { name: Name, path, completion, meta });
2418 2329 dbChallenge.Progress = 0;
2419 2330 dbChallenge.Completed = [];
2420 2331 }