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: provide correct dragon quest rewards for pre-U19 clients (#3742)

Copied from old Packages.bin export. Hopefully got it all right. Closes #3741 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3742 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

4 个文件 +70 -15
Modified src/controllers/api/giveKeyChainTriggeredItemsController.ts +4 -4
@@ -3,15 +3,15 @@ import { getJSONfromString } from "../../helpers/stringHelpers.ts";
3 3 import { getInventory } from "../../services/inventoryService.ts";
4 4 import { giveKeyChainItem } from "../../services/questService.ts";
5 5 import type { IKeyChainRequest } from "../../types/requestTypes.ts";
6 import { getAccountIdForRequest } from "../../services/loginService.ts";
6 import { getAccountForRequest } from "../../services/loginService.ts";
7 7
8 8 export const giveKeyChainTriggeredItemsController: RequestHandler = async (req, res) => {
9 const accountId = await getAccountIdForRequest(req);
9 const account = await getAccountForRequest(req);
10 10 const keyChainInfo = getJSONfromString<IKeyChainRequest>((req.body as string).toString());
11 11
12 const inventory = await getInventory(accountId);
12 const inventory = await getInventory(account._id);
13 13 const questKey = inventory.QuestKeys.find(qk => qk.ItemType === keyChainInfo.KeyChain)!;
14 const inventoryChanges = await giveKeyChainItem(inventory, keyChainInfo, questKey);
14 const inventoryChanges = await giveKeyChainItem(inventory, keyChainInfo, questKey, account.BuildLabel);
15 15 await inventory.save();
16 16
17 17 res.send(inventoryChanges);
Modified src/services/inventoryService.ts +3 -2
@@ -2651,9 +2651,10 @@ export const updateSyndicate = (
2651 2651 */
2652 2652 export const addKeyChainItems = async (
2653 2653 inventory: TInventoryDatabaseDocument,
2654 keyChainData: IKeyChainRequest
2654 keyChainData: IKeyChainRequest,
2655 buildLabel: string | undefined
2655 2656 ): Promise<IInventoryChanges> => {
2656 const keyChainItems = getKeyChainItems(keyChainData);
2657 const keyChainItems = getKeyChainItems(keyChainData, buildLabel);
2657 2658
2658 2659 logger.debug(
2659 2660 `adding key chain items ${keyChainItems.join()} for ${keyChainData.KeyChain} at stage ${keyChainData.ChainStage}`
Modified src/services/itemDataService.ts +57 -3
@@ -1154,8 +1154,11 @@ export const getNormalizedString = (key: string, dict: Record<string, string>):
1154 1154 return getString(key, dict).split("‘").join("'").split("’").join("'").split("\r\n").join(" ");
1155 1155 };
1156 1156
1157 export const getKeyChainItems = ({ KeyChain, ChainStage }: IKeyChainRequest): string[] => {
1158 const chainStages = ExportKeys[KeyChain].chainStages;
1157 export const getKeyChainItems = (
1158 { KeyChain, ChainStage }: IKeyChainRequest,
1159 buildLabel: string | undefined
1160 ): string[] => {
1161 const chainStages = getKey(KeyChain, buildLabel)?.chainStages;
1159 1162 if (!chainStages) {
1160 1163 throw new Error(`KeyChain ${KeyChain} does not contain chain stages`);
1161 1164 }
@@ -1194,6 +1197,25 @@ export const getLevelKeyRewards = (
1194 1197 if (buildLabel && version_compare(buildLabel, gameToBuildVersion["40.0.0"]) < 0) {
1195 1198 if (levelKey in vorsPrizePreU40Rewards) {
1196 1199 levelKeyRewards2 = vorsPrizePreU40Rewards[levelKey as keyof typeof vorsPrizePreU40Rewards] as TReward[];
1200 } else {
1201 // Before U19 (Hotfix: Specters of the Rail 0.12, 2016-07-20), The New Strange gave Chroma component blueprints more directly.
1202 if (buildLabel && version_compare(buildLabel, "2016.07.20.00.00") < 0) {
1203 if (levelKey == "/Lotus/Types/Keys/DragonQuest/DragonQuestMissionTwo") {
1204 levelKeyRewards2 = [
1205 {
1206 rewardType: "RT_STORE_ITEM",
1207 itemType: "/Lotus/StoreItems/Types/Recipes/WarframeRecipes/ChromaHelmetBlueprint"
1208 }
1209 ];
1210 } else if (levelKey == "/Lotus/Types/Keys/DragonQuest/DragonQuestMissionThree") {
1211 levelKeyRewards2 = [
1212 {
1213 rewardType: "RT_STORE_ITEM",
1214 itemType: "/Lotus/StoreItems/Types/Recipes/WarframeRecipes/ChromaSystemsBlueprint"
1215 }
1216 ];
1217 }
1218 }
1197 1219 }
1198 1220 }
1199 1221
@@ -1458,7 +1480,7 @@ export const getBoosterPack = (uniqueName: string, buildLabel: string = ""): IBo
1458 1480 return ExportBoosterPacks[uniqueName];
1459 1481 };
1460 1482
1461 export const getKey = (uniqueName: string): IKey | undefined => {
1483 export const getKey = (uniqueName: string, buildLabel?: string): IKey | undefined => {
1462 1484 if (
1463 1485 uniqueName == "/Lotus/Types/Keys/RaidKeys/Raid01Stage01KeyItem" ||
1464 1486 uniqueName == "/Lotus/Types/Keys/RaidKeys/Raid01Stage01NightmareKeyItem"
@@ -1603,6 +1625,38 @@ export const getKey = (uniqueName: string): IKey | undefined => {
1603 1625 maxEnemyLevel: 35
1604 1626 }
1605 1627 };
1628 } else if (uniqueName == "/Lotus/Types/Keys/DragonQuest/DragonQuestKeyChain") {
1629 // Before U19 (Hotfix: Specters of the Rail 0.12, 2016-07-20), The New Strange gave Chroma component blueprints more directly.
1630 if (buildLabel && version_compare(buildLabel, "2016.07.20.00.00") < 0) {
1631 const latestData = ExportKeys["/Lotus/Types/Keys/DragonQuest/DragonQuestKeyChain"];
1632 return {
1633 ...latestData,
1634 chainStages: latestData.chainStages!.map(chainStage => {
1635 if ("itemsToGiveWhenTriggered" in chainStage && chainStage.itemsToGiveWhenTriggered.length == 1) {
1636 if (
1637 chainStage.itemsToGiveWhenTriggered[0] ==
1638 "/Lotus/StoreItems/Types/Recipes/WarframeRecipes/ChromaBeaconABlueprint"
1639 ) {
1640 return {
1641 itemsToGiveWhenTriggered: [
1642 "/Lotus/StoreItems/Types/Recipes/WarframeRecipes/ChromaChassisBlueprint"
1643 ]
1644 };
1645 } else if (
1646 chainStage.itemsToGiveWhenTriggered[0] ==
1647 "/Lotus/StoreItems/Types/Recipes/WarframeRecipes/ChromaBeaconBBlueprint" ||
1648 chainStage.itemsToGiveWhenTriggered[0] ==
1649 "/Lotus/StoreItems/Types/Recipes/WarframeRecipes/ChromaBeaconCBlueprint"
1650 ) {
1651 return {
1652 itemsToGiveWhenTriggered: []
1653 };
1654 }
1655 }
1656 return chainStage;
1657 })
1658 };
1659 }
1606 1660 }
1607 1661
1608 1662 return ExportKeys[uniqueName];
Modified src/services/questService.ts +6 -6
@@ -10,7 +10,7 @@ import {
10 10 addPowerSuit,
11 11 setupKahlSyndicate
12 12 } from "./inventoryService.ts";
13 import { fromStoreItem, getKeyChainMessage, getLevelKeyRewards } from "./itemDataService.ts";
13 import { fromStoreItem, getKey, getKeyChainMessage, getLevelKeyRewards } from "./itemDataService.ts";
14 14 import type { IQuestKeyClient, IQuestKeyDatabase, IQuestStage } from "../types/inventoryTypes/inventoryTypes.ts";
15 15 import { logger } from "../utils/logger.ts";
16 16 import { ExportKeys, ExportRecipes } from "warframe-public-export-plus";
@@ -363,12 +363,13 @@ const handleQuestCompletion = async (
363 363 export const giveKeyChainItem = async (
364 364 inventory: TInventoryDatabaseDocument,
365 365 keyChainInfo: IKeyChainRequest,
366 questKey: IQuestKeyDatabase
366 questKey: IQuestKeyDatabase,
367 buildLabel: string | undefined
367 368 ): Promise<IInventoryChanges> => {
368 369 let inventoryChanges: IInventoryChanges = {};
369 370
370 371 if (!questKey.Progress?.[keyChainInfo.ChainStage]?.i) {
371 inventoryChanges = await addKeyChainItems(inventory, keyChainInfo);
372 inventoryChanges = await addKeyChainItems(inventory, keyChainInfo, buildLabel);
372 373
373 374 if (isEmptyObject(inventoryChanges)) {
374 375 logger.warn("inventory changes was empty after getting keychain items: should not happen");
@@ -422,8 +423,7 @@ export const giveKeyChainMissionReward = async (
422 423 keyChainInfo: IKeyChainRequest,
423 424 buildLabel: string | undefined
424 425 ): Promise<void> => {
425 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
426 const chainStages = ExportKeys[keyChainInfo.KeyChain]?.chainStages;
426 const chainStages = getKey(keyChainInfo.KeyChain, buildLabel)?.chainStages;
427 427
428 428 if (chainStages) {
429 429 const missionName = chainStages[keyChainInfo.ChainStage].key;
@@ -472,7 +472,7 @@ export const giveKeyChainStageTriggered = async (
472 472
473 473 if (chainStages && questKey) {
474 474 if (chainStages[keyChainInfo.ChainStage].itemsToGiveWhenTriggered.length > 0) {
475 await giveKeyChainItem(inventory, keyChainInfo, questKey);
475 await giveKeyChainItem(inventory, keyChainInfo, questKey, undefined);
476 476 }
477 477
478 478 if (chainStages[keyChainInfo.ChainStage].messageToSendWhenTriggered) {