返回提交历史
Modified
src/controllers/api/giveQuestKey.ts
+1
-1
Modified
src/controllers/api/inventoryController.ts
+1
-0
Modified
src/controllers/api/joinSessionController.ts
+6
-5
Modified
src/managers/sessionManager.ts
+2
-3
Modified
src/models/inventoryModels/loadoutModel.ts
+13
-1
Modified
src/models/shipModel.ts
+9
-1
Modified
src/models/statsModel.ts
+2
-2
Modified
src/services/loadoutService.ts
+2
-2
Modified
src/services/missionInventoryUpdateService.ts
+17
-4
Modified
src/services/personalRoomsService.ts
+3
-2
Modified
src/services/purchaseService.ts
+7
-4
Modified
src/services/questService.ts
+5
-2
Modified
src/services/shipService.ts
+3
-16
Modified
src/services/statsService.ts
+4
-8
Modified
src/types/personalRoomsTypes.ts
+13
-1
Modified
src/types/session.ts
+23
-23
XFEstudio/XFESpaceNinjaServer
chore: fix various eslint issues (#1176)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1176
2891e2fe
代码差异
16 个文件
+111
-75
@@ -38,7 +38,7 @@ export interface IQuestKeyReward {
38
38
Duration: number;
39
39
CouponSku: number;
40
40
Syndicate: string;
41
Milestones: any[];
41
//Milestones: any[];
42
42
ChooseSetIndex: number;
43
43
NewSystemReward: boolean;
44
44
_id: IOid;
@@ -261,6 +261,7 @@ const resourceGetParent = (resourceName: string): string | undefined => {
261
261
if (resourceName in ExportResources) {
262
262
return ExportResources[resourceName].parentName;
263
263
}
264
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
264
265
return ExportVirtuals[resourceName]?.parentName;
265
266
};
266
267
@@ -2,12 +2,13 @@ import { RequestHandler } from "express";
2
2
import { getSessionByID } from "@/src/managers/sessionManager";
3
3
import { logger } from "@/src/utils/logger";
4
4
5
const joinSessionController: RequestHandler = (_req, res) => {
6
const reqBody = JSON.parse(String(_req.body));
5
export const joinSessionController: RequestHandler = (req, res) => {
6
const reqBody = JSON.parse(String(req.body)) as IJoinSessionRequest;
7
7
logger.debug(`JoinSession Request`, { reqBody });
8
const req = JSON.parse(String(_req.body));
9
const session = getSessionByID(req.sessionIds[0] as string);
8
const session = getSessionByID(reqBody.sessionIds[0]);
10
9
res.json({ rewardSeed: session?.rewardSeed, sessionId: { $oid: session?.sessionId } });
11
10
};
12
11
13
export { joinSessionController };
12
interface IJoinSessionRequest {
13
sessionIds: string[];
14
}
@@ -44,7 +44,7 @@ function getSessionByID(sessionId: string): ISession | undefined {
44
44
return sessions.find(session => session.sessionId === sessionId);
45
45
}
46
46
47
function getSession(sessionIdOrRequest: string | IFindSessionRequest): any[] {
47
function getSession(sessionIdOrRequest: string | IFindSessionRequest): { createdBy: string; id: string }[] {
48
48
if (typeof sessionIdOrRequest === "string") {
49
49
const session = sessions.find(session => session.sessionId === sessionIdOrRequest);
50
50
if (session) {
@@ -107,8 +107,7 @@ function updateSession(sessionId: string, sessionData: string): boolean {
107
107
const session = sessions.find(session => session.sessionId === sessionId);
108
108
if (!session) return false;
109
109
try {
110
const updatedData = JSON.parse(sessionData);
111
Object.assign(session, updatedData);
110
Object.assign(session, JSON.parse(sessionData));
112
111
return true;
113
112
} catch (error) {
114
113
console.error("Invalid JSON string for session update.");
@@ -1,7 +1,7 @@
1
1
import { IOid } from "@/src/types/commonTypes";
2
2
import { IEquipmentSelection } from "@/src/types/inventoryTypes/commonInventoryTypes";
3
3
import { ILoadoutConfigDatabase, ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
4
import { Model, Schema, Types, model } from "mongoose";
4
import { Document, Model, Schema, Types, model } from "mongoose";
5
5
6
6
const oidSchema = new Schema<IOid>(
7
7
{
@@ -97,3 +97,15 @@ type loadoutDocumentProps = {
97
97
type loadoutModelType = Model<ILoadoutDatabase, {}, loadoutDocumentProps>;
98
98
99
99
export const Loadout = model<ILoadoutDatabase, loadoutModelType>("Loadout", loadoutSchema);
100
101
// eslint-disable-next-line @typescript-eslint/ban-types
102
export type TLoadoutDatabaseDocument = Document<unknown, {}, ILoadoutDatabase> &
103
Omit<
104
ILoadoutDatabase & {
105
_id: Types.ObjectId;
106
} & {
107
__v: number;
108
},
109
keyof loadoutDocumentProps
110
> &
111
loadoutDocumentProps;
@@ -1,4 +1,4 @@
1
import { Schema, model } from "mongoose";
1
import { Document, Schema, Types, model } from "mongoose";
2
2
import { IShipDatabase } from "../types/shipTypes";
3
3
import { toOid } from "@/src/helpers/inventoryHelpers";
4
4
import { colorSchema } from "@/src/models/inventoryModels/inventoryModel";
@@ -47,3 +47,11 @@ shipSchema.set("toObject", {
47
47
});
48
48
49
49
export const Ship = model("Ships", shipSchema);
50
51
// eslint-disable-next-line @typescript-eslint/ban-types
52
export type TShipDatabaseDocument = Document<unknown, {}, IShipDatabase> &
53
IShipDatabase & {
54
_id: Types.ObjectId;
55
} & {
56
__v: number;
57
};
@@ -4,7 +4,7 @@ import { IEnemy, IMission, IScan, ITutorial, IAbility, IWeapon, IStatsDatabase,
4
4
const abilitySchema = new Schema<IAbility>(
5
5
{
6
6
type: { type: String, required: true },
7
used: Number
7
used: { type: Number, required: true }
8
8
},
9
9
{ _id: false }
10
10
);
@@ -32,7 +32,7 @@ const missionSchema = new Schema<IMission>(
32
32
const scanSchema = new Schema<IScan>(
33
33
{
34
34
type: { type: String, required: true },
35
scans: Number
35
scans: { type: Number, required: true }
36
36
},
37
37
{ _id: false }
38
38
);
@@ -1,6 +1,6 @@
1
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
1
import { Loadout, TLoadoutDatabaseDocument } from "@/src/models/inventoryModels/loadoutModel";
2
2
3
export const getLoadout = async (accountId: string) => {
3
export const getLoadout = async (accountId: string): Promise<TLoadoutDatabaseDocument> => {
4
4
const loadout = await Loadout.findOne({ loadoutOwnerId: accountId });
5
5
6
6
if (!loadout) {
@@ -313,6 +313,12 @@ export const addMissionInventoryUpdates = async (
313
313
return inventoryChanges;
314
314
};
315
315
316
interface AddMissionRewardsReturnType {
317
MissionRewards: IMissionReward[];
318
inventoryChanges?: IInventoryChanges;
319
credits?: IMissionCredits;
320
}
321
316
322
//TODO: return type of partial missioninventoryupdate response
317
323
export const addMissionRewards = async (
318
324
inventory: TInventoryDatabaseDocument,
@@ -324,7 +330,7 @@ export const addMissionRewards = async (
324
330
VoidTearParticipantsCurrWave: voidTearWave,
325
331
StrippedItems: strippedItems
326
332
}: IMissionInventoryUpdateRequest
327
) => {
333
): Promise<AddMissionRewardsReturnType> => {
328
334
if (!rewardInfo) {
329
335
//TODO: if there is a case where you can have credits collected during a mission but no rewardInfo, add credits needs to be handled earlier
330
336
logger.debug(`Mission ${missions!.Tag} did not have Reward Info `);
@@ -435,6 +441,13 @@ export const addMissionRewards = async (
435
441
return { inventoryChanges, MissionRewards, credits };
436
442
};
437
443
444
interface IMissionCredits {
445
MissionCredits: number[];
446
CreditBonus: number[];
447
TotalCredits: number[];
448
DailyMissionBonus?: boolean;
449
}
450
438
451
//creditBonus is not entirely accurate.
439
452
//TODO: consider ActiveBoosters
440
453
export const addCredits = (
@@ -444,11 +457,11 @@ export const addCredits = (
444
457
missionCompletionCredits,
445
458
rngRewardCredits
446
459
}: { missionDropCredits: number; missionCompletionCredits: number; rngRewardCredits: number }
447
) => {
460
): IMissionCredits => {
448
461
const hasDailyCreditBonus = true;
449
462
const totalCredits = missionDropCredits + missionCompletionCredits + rngRewardCredits;
450
463
451
const finalCredits = {
464
const finalCredits: IMissionCredits = {
452
465
MissionCredits: [missionDropCredits, missionDropCredits],
453
466
CreditBonus: [missionCompletionCredits, missionCompletionCredits],
454
467
TotalCredits: [totalCredits, totalCredits]
@@ -471,7 +484,7 @@ export const addFixedLevelRewards = (
471
484
rewards: IMissionRewardExternal,
472
485
inventory: TInventoryDatabaseDocument,
473
486
MissionRewards: IMissionReward[]
474
) => {
487
): number => {
475
488
let missionBonusCredits = 0;
476
489
if (rewards.credits) {
477
490
missionBonusCredits += rewards.credits;
@@ -1,7 +1,8 @@
1
1
import { PersonalRooms } from "@/src/models/personalRoomsModel";
2
2
import { addItem, getInventory } from "@/src/services/inventoryService";
3
import { TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes";
3
4
4
export const getPersonalRooms = async (accountId: string) => {
5
export const getPersonalRooms = async (accountId: string): Promise<TPersonalRoomsDatabaseDocument> => {
5
6
const personalRooms = await PersonalRooms.findOne({ personalRoomsOwnerId: accountId });
6
7
7
8
if (!personalRooms) {
@@ -10,7 +11,7 @@ export const getPersonalRooms = async (accountId: string) => {
10
11
return personalRooms;
11
12
};
12
13
13
export const updateShipFeature = async (accountId: string, shipFeature: string) => {
14
export const updateShipFeature = async (accountId: string, shipFeature: string): Promise<void> => {
14
15
const personalRooms = await getPersonalRooms(accountId);
15
16
16
17
if (personalRooms.Ship.Features.includes(shipFeature)) {
@@ -108,8 +108,11 @@ export const handlePurchase = async (
108
108
];
109
109
}
110
110
purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier;
111
} else if (!ExportVendors[purchaseRequest.PurchaseParams.SourceId!]) {
112
throw new Error(`unknown vendor: ${purchaseRequest.PurchaseParams.SourceId!}`);
111
} else {
112
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
113
if (!ExportVendors[purchaseRequest.PurchaseParams.SourceId!]) {
114
throw new Error(`unknown vendor: ${purchaseRequest.PurchaseParams.SourceId!}`);
115
}
113
116
}
114
117
}
115
118
@@ -120,8 +123,6 @@ export const handlePurchase = async (
120
123
);
121
124
combineInventoryChanges(purchaseResponse.InventoryChanges, inventoryChanges);
122
125
123
if (!purchaseResponse) throw new Error("purchase response was undefined");
124
125
126
const currencyChanges = updateCurrency(
126
127
inventory,
127
128
purchaseRequest.PurchaseParams.ExpectedPrice,
@@ -149,6 +150,7 @@ export const handlePurchase = async (
149
150
];
150
151
} else {
151
152
const syndicate = ExportSyndicates[syndicateTag];
153
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
152
154
if (syndicate) {
153
155
const favour = syndicate.favours.find(
154
156
x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem
@@ -360,6 +362,7 @@ const handleBoosterPackPurchase = async (
360
362
quantity: number
361
363
): Promise<IPurchaseResponse> => {
362
364
const pack = ExportBoosterPacks[typeName];
365
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
363
366
if (!pack) {
364
367
throw new Error(`unknown booster pack: ${typeName}`);
365
368
}
@@ -93,7 +93,10 @@ export const updateQuestStage = (
93
93
Object.assign(questStage, questStageUpdate);
94
94
};
95
95
96
export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase) => {
96
export const addQuestKey = (
97
inventory: TInventoryDatabaseDocument,
98
questKey: IQuestKeyDatabase
99
): IQuestKeyClient | undefined => {
97
100
if (inventory.QuestKeys.some(q => q.ItemType === questKey.ItemType)) {
98
101
logger.warn(`Quest key ${questKey.ItemType} already exists. It will not be added`);
99
102
return;
@@ -115,7 +118,7 @@ export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQu
115
118
return inventory.QuestKeys[index - 1].toJSON<IQuestKeyClient>();
116
119
};
117
120
118
export const completeQuest = async (inventory: TInventoryDatabaseDocument, questKey: string) => {
121
export const completeQuest = async (inventory: TInventoryDatabaseDocument, questKey: string): Promise<void> => {
119
122
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
120
123
const chainStages = ExportKeys[questKey]?.chainStages;
121
124