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

fix: correct format for WeeklyGuildVaultBonusInfo (#4329)

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

3f51c4f3
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

6 个文件 +52 -50
Modified src/controllers/api/guildVaultBonusRewardsController.ts +41 -41
@@ -2,7 +2,7 @@ import type { RequestHandler } from "express";
2 2 import { logger } from "../../utils/logger.ts";
3 3 import { getRandomElement } from "../../services/rngService.ts";
4 4 import type { ITypeCount } from "../../types/commonTypes.ts";
5 import type { IWeekGuildVaultBonusReward } from "../../types/inventoryTypes/inventoryTypes.ts";
5 import type { IWeekGuildVaultBonusReward, IWeeklyGuildVaultBonus } from "../../types/inventoryTypes/inventoryTypes.ts";
6 6 import { getAccountIdForRequest } from "../../services/loginService.ts";
7 7 import { getInventory2 } from "../../services/inventoryService.ts";
8 8
@@ -12,48 +12,48 @@ export const guildVaultBonusRewardsController: RequestHandler = async (req, res)
12 12 const payload = JSON.parse(String(req.body)) as IRollGuildVaultBonusRequest;
13 13
14 14 const inventory = await getInventory2(accountId, "WeeklyGuildVaultBonusInfo");
15 if (inventory.WeeklyGuildVaultBonusInfo?.WeekCount != payload.WeekCount) {
16 const tierAReward = getRandomElement(tierARewards)!;
17 const tierBReward = getRandomElement(tierBRewards)!;
18 const tierCReward = getRandomElement(tierCRewards)!;
19 const tierDReward = getRandomElement(tierDRewards)!;
20 inventory.WeeklyGuildVaultBonusInfo = {
21 Progress: 0,
22 WeekCount: payload.WeekCount,
23 BonusRegion: "/Lotus/Language/Locations/Earth", // TODO: Is this the correct format? What planets are eligible? Does the server need to handle anything for this "bonus"?
24 Rewards: [
25 {
26 RewardClaimed: false,
27 PointThreshold: 500,
28 ItemCount: tierAReward.ItemCount,
29 Reward: tierAReward.ItemType
30 },
31 {
32 RewardClaimed: false,
33 PointThreshold: 1000,
34 ItemCount: tierBReward.ItemCount,
35 Reward: tierBReward.ItemType
36 },
37 {
38 RewardClaimed: false,
39 PointThreshold: 1500,
40 ItemCount: tierCReward.ItemCount,
41 Reward: tierCReward.ItemType
42 },
43 {
44 RewardClaimed: false,
45 PointThreshold: 2000,
46 ItemCount: tierDReward.ItemCount,
47 Reward: tierDReward.ItemType
48 }
49 ]
50 };
51 await inventory.save();
52 }
15 const tierAReward = getRandomElement(tierARewards)!;
16 const tierBReward = getRandomElement(tierBRewards)!;
17 const tierCReward = getRandomElement(tierCRewards)!;
18 const tierDReward = getRandomElement(tierDRewards)!;
19 const weeklyBonus: IWeeklyGuildVaultBonus = {
20 Progress: 0,
21 WeekCount: payload.WeekCount,
22 BonusRegion: "/Lotus/Language/Locations/Earth", // TODO: What planets are eligible? Does the server need to handle anything for this "bonus"?
23 Rewards: [
24 {
25 RewardClaimed: false,
26 PointThreshold: 500,
27 ItemCount: tierAReward.ItemCount,
28 Reward: tierAReward.ItemType
29 },
30 {
31 RewardClaimed: false,
32 PointThreshold: 1000,
33 ItemCount: tierBReward.ItemCount,
34 Reward: tierBReward.ItemType
35 },
36 {
37 RewardClaimed: false,
38 PointThreshold: 1500,
39 ItemCount: tierCReward.ItemCount,
40 Reward: tierCReward.ItemType
41 },
42 {
43 RewardClaimed: false,
44 PointThreshold: 2000,
45 ItemCount: tierDReward.ItemCount,
46 Reward: tierDReward.ItemType
47 }
48 ]
49 };
50
51 inventory.WeeklyGuildVaultBonusInfo = [weeklyBonus]; // TODO: Probably should not replace the entire array if there were unclaimed rewards or something?
52 await inventory.save();
53 53
54 54 res.json({
55 NewRewards: inventory.WeeklyGuildVaultBonusInfo.Rewards,
56 BonusRegion: inventory.WeeklyGuildVaultBonusInfo.BonusRegion
55 NewRewards: weeklyBonus.Rewards,
56 BonusRegion: weeklyBonus.BonusRegion
57 57 } satisfies IRollGuildVaultBonusResponse);
58 58 } else {
59 59 logger.debug(`data provided to ${req.path}: ${String(req.body)}`);
Modified src/controllers/api/inventoryController.ts +0 -3
@@ -644,9 +644,6 @@ export const getInventoryResponse = async (
644 644 inventoryResponse.Nemesis = undefined;
645 645 }
646 646
647 // On live, this is just empty in inventory response. Seems like the client sends a roll request request even with this given.
648 inventoryResponse.WeeklyGuildVaultBonusInfo = undefined;
649
650 647 // U42 migrated ability paths so translate them back for older versions
651 648 if (version_compare(buildLabel, gameToBuildVersion["42.0.0"]) >= 0) {
652 649 return inventoryResponse;
Modified src/models/inventoryModels/inventoryModel.ts +3 -3
@@ -101,7 +101,7 @@ import type {
101 101 IDialogueCounter,
102 102 ISketch,
103 103 IHybridFusionTreasure,
104 IWeeklyGuildVaultBonusInfo,
104 IWeeklyGuildVaultBonus,
105 105 IWeekGuildVaultBonusReward
106 106 } from "../../types/inventoryTypes/inventoryTypes.ts";
107 107 import { equipmentKeys } from "../../types/inventoryTypes/inventoryTypes.ts";
@@ -1587,7 +1587,7 @@ const weekGuildVaultBonusRewardSchema = new Schema<IWeekGuildVaultBonusReward>(
1587 1587 { _id: false }
1588 1588 );
1589 1589
1590 const weeklyGuildVaultBonusInfoSchema = new Schema<IWeeklyGuildVaultBonusInfo>(
1590 const weeklyGuildVaultBonusSchema = new Schema<IWeeklyGuildVaultBonus>(
1591 1591 {
1592 1592 Progress: { type: Number, required: true },
1593 1593 WeekCount: { type: Number, required: true },
@@ -2061,7 +2061,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
2061 2061
2062 2062 Sketches: { type: [sketchSchema], default: undefined },
2063 2063
2064 WeeklyGuildVaultBonusInfo: weeklyGuildVaultBonusInfoSchema
2064 WeeklyGuildVaultBonusInfo: { type: [weeklyGuildVaultBonusSchema], default: undefined }
2065 2065 },
2066 2066 { timestamps: { createdAt: "Created", updatedAt: false } }
2067 2067 );
Modified src/services/importService.ts +1 -1
@@ -596,7 +596,7 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
596 596 if (client.Sketches !== undefined) {
597 597 db.Sketches = client.Sketches;
598 598 }
599 if (typeof client.WeeklyGuildVaultBonusInfo == "object") {
599 if (client.WeeklyGuildVaultBonusInfo !== undefined) {
600 600 db.WeeklyGuildVaultBonusInfo = client.WeeklyGuildVaultBonusInfo;
601 601 }
602 602
Modified src/services/inventoryService.ts +5 -0
@@ -3059,6 +3059,11 @@ export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void =>
3059 3059 migrateFusionTreasures(inventory, inventory.FusionTreasures);
3060 3060 inventory.FusionTreasures = undefined;
3061 3061 }
3062
3063 // Fix WeeklyGuildVaultBonusInfo
3064 if (inventory.WeeklyGuildVaultBonusInfo && !Array.isArray(inventory.WeeklyGuildVaultBonusInfo)) {
3065 inventory.WeeklyGuildVaultBonusInfo = [inventory.WeeklyGuildVaultBonusInfo];
3066 }
3062 3067 };
3063 3068
3064 3069 export const migrateFusionTreasures = (
Modified src/types/inventoryTypes/inventoryTypes.ts +2 -2
@@ -561,7 +561,7 @@ export interface IInventoryClient
561 561 RetroPlayAllConvos?: boolean;
562 562 RetroDisableKissInboxMessage?: boolean;
563 563 Sketches?: ISketch[];
564 WeeklyGuildVaultBonusInfo?: IWeeklyGuildVaultBonusInfo;
564 WeeklyGuildVaultBonusInfo?: IWeeklyGuildVaultBonus[] | IWeeklyGuildVaultBonus; // should be an array
565 565 }
566 566
567 567 export interface IAffiliation {
@@ -1411,7 +1411,7 @@ export interface ISketch {
1411 1411 canvas?: string;
1412 1412 }
1413 1413
1414 export interface IWeeklyGuildVaultBonusInfo {
1414 export interface IWeeklyGuildVaultBonus {
1415 1415 Progress: number;
1416 1416 WeekCount: number;
1417 1417 BonusRegion: string;