返回提交历史
Modified
src/controllers/api/inboxController.ts
+66
-58
Modified
src/controllers/api/inventoryController.ts
+18
-1
Modified
src/helpers/relicHelper.ts
+3
-3
Modified
src/models/inboxModel.ts
+2
-0
Modified
src/models/inventoryModels/inventoryModel.ts
+1
-0
Modified
src/types/inventoryTypes/inventoryTypes.ts
+1
-0
XFEstudio/XFESpaceNinjaServer
chore: make it apparent to the user when they earned platinum (#4176)
Closes #4174 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4176 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
5e842adc
代码差异
6 个文件
+91
-62
@@ -20,6 +20,7 @@ import {
20
20
import {
21
21
addItems,
22
22
combineInventoryChanges,
23
CurrencyType,
23
24
getEffectiveAvatarImageType,
24
25
getInventory,
25
26
updateCurrency
@@ -33,6 +34,7 @@ import { unixTimesInMs } from "../../constants/timeConstants.ts";
33
34
import { config } from "../../services/configService.ts";
34
35
import { Types } from "mongoose";
35
36
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
37
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
36
38
37
39
export const inboxController: RequestHandler = async (req, res) => {
38
40
const { deleteId, lastMessage: latestClientMessageId, messageId } = req.query;
@@ -62,68 +64,74 @@ export const inboxController: RequestHandler = async (req, res) => {
62
64
63
65
const attachmentItems = message.attVisualOnly ? undefined : message.att;
64
66
const attachmentCountedItems = message.attVisualOnly ? undefined : message.countedAtt;
65
66
if (!attachmentItems && !attachmentCountedItems && !message.gifts) {
67
res.status(200).end();
68
return;
69
}
70
71
const inventory = await getInventory(account._id, undefined);
72
const inventoryChanges = {};
73
if (attachmentItems) {
74
await addItems(
75
inventory,
76
attachmentItems.map(attItem => ({
77
ItemType: isStoreItem(attItem) ? fromStoreItem(attItem) : attItem,
78
ItemCount: 1
79
})),
80
inventoryChanges
81
);
82
}
83
if (attachmentCountedItems) {
84
await addItems(inventory, attachmentCountedItems, inventoryChanges);
85
}
86
if (message.gifts) {
87
const sender = await getAccountFromSuffixedName(message.sndr);
88
const recipientName = getSuffixedName(account);
89
const giftQuantity = message.arg!.find(x => x.Key == "GIFT_QUANTITY")!.Tag as number;
90
for (const gift of message.gifts) {
91
combineInventoryChanges(
92
inventoryChanges,
93
(await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
67
if (
68
attachmentItems ||
69
attachmentCountedItems ||
70
message.gifts ||
71
message.RegularCredits ||
72
message.PremiumCredits
73
) {
74
const inventory = await getInventory(account._id, undefined);
75
const inventoryChanges: IInventoryChanges = {};
76
if (attachmentItems) {
77
await addItems(
78
inventory,
79
attachmentItems.map(attItem => ({
80
ItemType: isStoreItem(attItem) ? fromStoreItem(attItem) : attItem,
81
ItemCount: 1
82
})),
83
inventoryChanges
94
84
);
95
if (sender) {
96
await createMessage(sender._id, [
97
{
98
sndr: recipientName,
99
msg: "/Lotus/Language/Menu/GiftReceivedConfirmationBody",
100
arg: [
101
{
102
Key: "RECIPIENT_NAME",
103
Tag: recipientName
104
},
105
{
106
Key: "GIFT_TYPE",
107
Tag: gift.GiftType
108
},
109
{
110
Key: "GIFT_QUANTITY",
111
Tag: giftQuantity
112
}
113
],
114
sub: "/Lotus/Language/Menu/GiftReceivedConfirmationSubject",
115
icon: ExportFlavour[getEffectiveAvatarImageType(inventory)].icon,
116
highPriority: true
117
}
118
]);
85
}
86
if (attachmentCountedItems) {
87
await addItems(inventory, attachmentCountedItems, inventoryChanges);
88
}
89
if (message.gifts) {
90
const sender = await getAccountFromSuffixedName(message.sndr);
91
const recipientName = getSuffixedName(account);
92
const giftQuantity = message.arg!.find(x => x.Key == "GIFT_QUANTITY")!.Tag as number;
93
for (const gift of message.gifts) {
94
combineInventoryChanges(
95
inventoryChanges,
96
(await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
97
);
98
if (sender) {
99
await createMessage(sender._id, [
100
{
101
sndr: recipientName,
102
msg: "/Lotus/Language/Menu/GiftReceivedConfirmationBody",
103
arg: [
104
{
105
Key: "RECIPIENT_NAME",
106
Tag: recipientName
107
},
108
{
109
Key: "GIFT_TYPE",
110
Tag: gift.GiftType
111
},
112
{
113
Key: "GIFT_QUANTITY",
114
Tag: giftQuantity
115
}
116
],
117
sub: "/Lotus/Language/Menu/GiftReceivedConfirmationSubject",
118
icon: ExportFlavour[getEffectiveAvatarImageType(inventory)].icon,
119
highPriority: true
120
}
121
]);
122
}
119
123
}
120
124
}
125
if (message.RegularCredits) {
126
updateCurrency(inventory, -message.RegularCredits, CurrencyType.CREDITS, inventoryChanges);
127
}
128
if (message.PremiumCredits) {
129
updateCurrency(inventory, -message.PremiumCredits, CurrencyType.PLATINUM, inventoryChanges);
130
}
131
await inventory.save();
132
res.json({ InventoryChanges: inventoryChanges });
121
133
}
122
if (message.RegularCredits) {
123
updateCurrency(inventory, -message.RegularCredits, false, inventoryChanges);
124
}
125
await inventory.save();
126
res.json({ InventoryChanges: inventoryChanges });
134
res.end();
127
135
} else if (latestClientMessageId) {
128
136
await createNewEventMessages(account);
129
137
const newMessages = await getMessagesSorted(account._id, buildLabel, parseOid(latestClientMessageId as string));
@@ -259,6 +259,23 @@ export const inventoryController: RequestHandler = async (request, response) =>
259
259
//await inventory.save();
260
260
}
261
261
262
const forWebui = "wsid" in request.query;
263
264
if (inventory.pendingPremiumCredits && !forWebui) {
265
await createMessage(inventory.accountOwnerId, [
266
{
267
sndr: "/Lotus/Language/Bosses/Ordis",
268
msg: "/Lotus/Language/Inbox/FoundItemsBody",
269
sub: "/Lotus/Language/Inbox/FoundItemsTitle",
270
icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
271
PremiumCredits: inventory.pendingPremiumCredits,
272
highPriority: true // FoundItems messages on live have this flag, tho as we are reusing it here for platinum rewards, it's maybe questionable if it's needed, but whatever.
273
}
274
]);
275
inventory.pendingPremiumCredits = undefined;
276
//await inventory.save();
277
}
278
262
279
for (let i = 0; i != inventory.QualifyingInvasions.length; ) {
263
280
const qi = inventory.QualifyingInvasions[i];
264
281
const invasion = getInvasionByOid(qi.invasionId.toString());
@@ -345,7 +362,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
345
362
inventory,
346
363
"xpBasedLevelCapDisabled" in request.query,
347
364
getBuildLabel(request, account),
348
"wsid" in request.query
365
forWebui
349
366
)
350
367
);
351
368
};
@@ -53,9 +53,9 @@ export const crackRelic = async (
53
53
54
54
const platinumValue =
55
55
getRelicPlatinumBonusForRarity(inventory, reward.rarity) * (inventory.relicRewardItemCountMultiplier ?? 1);
56
if (platinumValue > 0 && !inventory.infinitePlatinum) {
57
inventory.PremiumCredits += platinumValue;
58
combineInventoryChanges(inventoryChanges, { PremiumCredits: platinumValue });
56
if (platinumValue != 0) {
57
inventory.pendingPremiumCredits ??= 0;
58
inventory.pendingPremiumCredits += platinumValue;
59
59
}
60
60
61
61
// Client has picked its own reward (for lack of choice)
@@ -58,6 +58,7 @@ export interface IMessage {
58
58
declineAction?: string;
59
59
hasAccountAction?: boolean;
60
60
RegularCredits?: number;
61
PremiumCredits?: number;
61
62
}
62
63
63
64
interface Arg {
@@ -153,6 +154,7 @@ const messageSchema = new Schema<IMessageDatabase>(
153
154
declineAction: String,
154
155
hasAccountAction: Boolean,
155
156
RegularCredits: Number,
157
PremiumCredits: Number,
156
158
minBuildVersion: Number
157
159
},
158
160
{ id: false }
@@ -1655,6 +1655,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1655
1655
PremiumCredits: { type: Number, default: 0 },
1656
1656
//Gift Platinum(Non trade)
1657
1657
PremiumCreditsFree: { type: Number, default: 0 },
1658
pendingPremiumCredits: Number,
1658
1659
//Endo
1659
1660
FusionPoints: { type: Number, default: 0 },
1660
1661
//Dirac
@@ -177,6 +177,7 @@ export interface IInventoryDatabase
177
177
duviriSeedRefresh?: Date;
178
178
HybridFusionTreasures: IHybridFusionTreasure[]; // SNS-specific in-database format to support both modern & legacy clients
179
179
receivedThousandYearFishDeco?: true; // placed decos are not in inventory, hence this boolean
180
pendingPremiumCredits?: number;
180
181
181
182
Created: Date;
182
183
CurrentLoadOutIds: Types.ObjectId[];