返回提交历史
Modified
src/controllers/api/unlockShipFeatureController.ts
+15
-6
Modified
src/services/inventoryService.ts
+17
-3
Modified
src/services/personalRoomsService.ts
+11
-11
Modified
src/services/questService.ts
+3
-1
Modified
src/types/purchaseTypes.ts
+3
-1
Modified
src/types/requestTypes.ts
+0
-5
XFEstudio/SpaceNinjaServer
feat: complete Rising Tide with buying railjack (#2922)
Closes #2754 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2922 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
98a46e51
代码差异
6 个文件
+49
-27
@@ -1,11 +1,20 @@
1
1
import type { RequestHandler } from "express";
2
import { updateShipFeature } from "../../services/personalRoomsService.ts";
3
import type { IUnlockShipFeatureRequest } from "../../types/requestTypes.ts";
4
import { parseString } from "../../helpers/general.ts";
2
import { getAccountIdForRequest } from "../../services/loginService.ts";
3
import { getInventory } from "../../services/inventoryService.ts";
4
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
5
import { unlockShipFeature } from "../../services/personalRoomsService.ts";
5
6
6
7
export const unlockShipFeatureController: RequestHandler = async (req, res) => {
7
const accountId = parseString(req.query.accountId);
8
const shipFeatureRequest = JSON.parse((req.body as string).toString()) as IUnlockShipFeatureRequest;
9
await updateShipFeature(accountId, shipFeatureRequest.Feature);
8
const accountId = await getAccountIdForRequest(req);
9
const inventory = await getInventory(accountId, "MiscItems accountOwnerId");
10
const request = getJSONfromString<IUnlockShipFeatureRequest>(String(req.body));
11
12
await unlockShipFeature(inventory, request.Feature);
13
await inventory.save();
10
14
res.send([]);
11
15
};
16
interface IUnlockShipFeatureRequest {
17
Feature: string;
18
KeyChain: string;
19
ChainStage: number;
20
}
@@ -388,7 +388,7 @@ export const addItem = async (
388
388
};
389
389
} else if (ExportResources[typeName].productCategory == "CrewShips") {
390
390
return {
391
...addCrewShip(inventory, typeName),
391
...(await addCrewShip(inventory, typeName)),
392
392
// fix to unlock railjack modding, item bellow supposed to be obtained from archwing quest
393
393
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
394
394
...(!inventory.CrewShipHarnesses?.length
@@ -1543,17 +1543,31 @@ export const addCrewShipSalvagedWeaponSkin = (
1543
1543
return inventoryChanges;
1544
1544
};
1545
1545
1546
const addCrewShip = (
1546
const addCrewShip = async (
1547
1547
inventory: TInventoryDatabaseDocument,
1548
1548
typeName: string,
1549
1549
inventoryChanges: IInventoryChanges = {}
1550
): IInventoryChanges => {
1550
): Promise<IInventoryChanges> => {
1551
1551
if (inventory.CrewShips.length != 0) {
1552
1552
logger.warn("refusing to add CrewShip because account already has one");
1553
1553
} else {
1554
1554
const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
1555
1555
inventoryChanges.CrewShips ??= [];
1556
1556
inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
1557
const railjackQuest = inventory.QuestKeys.find(
1558
qk => qk.ItemType === "/Lotus/Types/Keys/RailJackBuildQuest/RailjackBuildQuestKeyChain"
1559
);
1560
if (!railjackQuest || !railjackQuest.Completed) {
1561
const questChanges = await completeQuest(
1562
inventory,
1563
"/Lotus/Types/Keys/RailJackBuildQuest/RailjackBuildQuestKeyChain",
1564
false
1565
);
1566
if (questChanges) {
1567
inventoryChanges.QuestKeys ??= [];
1568
inventoryChanges.QuestKeys.push(questChanges);
1569
}
1570
}
1557
1571
}
1558
1572
return inventoryChanges;
1559
1573
};
@@ -1,7 +1,9 @@
1
1
import { PersonalRooms } from "../models/personalRoomsModel.ts";
2
import { addItem, getInventory } from "./inventoryService.ts";
2
import { addItem } from "./inventoryService.ts";
3
3
import type { IGardeningDatabase, TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes.ts";
4
4
import { getRandomElement } from "./rngService.ts";
5
import type { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel.ts";
6
import { logger } from "../utils/logger.ts";
5
7
6
8
export const getPersonalRooms = async (
7
9
accountId: string,
@@ -15,19 +17,17 @@ export const getPersonalRooms = async (
15
17
return personalRooms;
16
18
};
17
19
18
export const updateShipFeature = async (accountId: string, shipFeature: string): Promise<void> => {
19
const personalRooms = await getPersonalRooms(accountId);
20
export const unlockShipFeature = async (inventory: TInventoryDatabaseDocument, shipFeature: string): Promise<void> => {
21
const personalRooms = await getPersonalRooms(inventory.accountOwnerId.toString());
20
22
21
23
if (personalRooms.Ship.Features.includes(shipFeature)) {
22
throw new Error(`ship feature ${shipFeature} already unlocked`);
24
logger.warn(`ship feature ${shipFeature} already unlocked`);
25
} else {
26
personalRooms.Ship.Features.push(shipFeature);
27
await personalRooms.save();
23
28
}
24
25
personalRooms.Ship.Features.push(shipFeature);
26
await personalRooms.save();
27
28
const inventory = await getInventory(accountId);
29
await addItem(inventory, shipFeature, -1);
30
await inventory.save();
29
const miscItem = inventory.MiscItems.find(x => x.ItemType === shipFeature);
30
if (miscItem && miscItem.ItemCount > 0) await addItem(inventory, shipFeature, miscItem.ItemCount * -1);
31
31
};
32
32
33
33
export const createGarden = (): IGardeningDatabase => {
@@ -120,7 +120,7 @@ export const completeQuest = async (
120
120
inventory: TInventoryDatabaseDocument,
121
121
questKey: string,
122
122
sendMessages: boolean = false
123
): Promise<void> => {
123
): Promise<void | IQuestKeyClient> => {
124
124
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
125
125
const chainStages = ExportKeys[questKey]?.chainStages;
126
126
@@ -176,6 +176,8 @@ export const completeQuest = async (
176
176
existingQuestKey.CompletionDate = new Date();
177
177
await handleQuestCompletion(inventory, questKey, undefined, run > 0);
178
178
}
179
180
return existingQuestKey.toJSON<IQuestKeyClient>();
179
181
};
180
182
181
183
const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
@@ -9,7 +9,8 @@ import type {
9
9
TEquipmentKey,
10
10
ICrewMemberClient,
11
11
IKubrowPetPrintClient,
12
IUpgradeClient
12
IUpgradeClient,
13
IQuestKeyClient
13
14
} from "./inventoryTypes/inventoryTypes.ts";
14
15
15
16
export enum PurchaseSource {
@@ -83,6 +84,7 @@ export type IInventoryChanges = {
83
84
CrewMembers?: ICrewMemberClient[];
84
85
KubrowPetPrints?: IKubrowPetPrintClient[];
85
86
Upgrades?: IUpgradeClient[]; // TOVERIFY
87
QuestKeys?: IQuestKeyClient[];
86
88
} & Record<
87
89
Exclude<
88
90
string,
@@ -234,11 +234,6 @@ export interface IUpgradeOperation {
234
234
PolarizeValue: ArtifactPolarity;
235
235
PolarityRemap: IPolarity[];
236
236
}
237
export interface IUnlockShipFeatureRequest {
238
Feature: string;
239
KeyChain: string;
240
ChainStage: number;
241
}
242
237
243
238
export interface IVoidTearParticipantInfo {
244
239
AccountId: string;