返回提交历史
Modified
src/controllers/api/loginRewardsController.ts
+10
-1
Modified
src/services/loginRewardService.ts
+5
-3
XFEstudio/SpaceNinjaServer
chore: improve reward data given to pre-daily tribute clients (#3859)
Closes #3857 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3859 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
a3d02dac
代码差异
2 个文件
+15
-4
@@ -11,6 +11,7 @@ import { getInventory } from "../../services/inventoryService.ts";
11
11
import { sendWsBroadcastTo } from "../../services/wsService.ts";
12
12
import { version_compare } from "../../helpers/inventoryHelpers.ts";
13
13
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
14
import { ExportBoosters, ExportResources } from "warframe-public-export-plus";
14
15
15
16
export const loginRewardsController: RequestHandler = async (req, res) => {
16
17
const account = await getAccountForRequest(req);
@@ -53,10 +54,18 @@ export const loginRewardsController: RequestHandler = async (req, res) => {
53
54
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
54
55
}
55
56
if (is_pre_daily_tribute) {
56
// Ensure icon is something the client can display.
57
// Ensure the client has an icon it can display.
57
58
for (const reward of response.DailyTributeInfo.Rewards!) {
58
59
if (reward.Icon == "/Lotus/Interface/Icons/StoreIcons/Currency/CreditsLarge.png") {
59
60
reward.Icon = "/Lotus/Interface/Icons/Store/CreditBooster.png";
61
} else if (reward.RewardType == "RT_RESOURCE") {
62
reward.Icon = ExportResources[reward.ItemType].icon
63
.split("/Lotus/Interface/Icons/StoreIcons/Resources/CraftingComponents/")
64
.join("/Lotus/Interface/Icons/Store/");
65
} else if (reward.RewardType == "RT_BOOSTER") {
66
reward.Icon = ExportBoosters[reward.StoreItemType].icon
67
.split("/Lotus/Interface/Icons/StoreIcons/Boosters/")
68
.join("/Lotus/Interface/Icons/Store/");
60
69
}
61
70
}
62
71
res.json({ Rewards: response.DailyTributeInfo.Rewards });
@@ -12,7 +12,8 @@ import {
12
12
ExportWarframes,
13
13
ExportWeapons
14
14
} from "warframe-public-export-plus";
15
import { toStoreItem } from "./itemDataService.ts";
15
import { fromStoreItem, toStoreItem } from "./itemDataService.ts";
16
import { logger } from "../utils/logger.ts";
16
17
17
18
export interface ILoginRewardsReponse {
18
19
DailyTributeInfo: {
@@ -35,7 +36,7 @@ export interface ILoginReward {
35
36
RewardType: string;
36
37
//CouponType: "CPT_PLATINUM";
37
38
Icon: string;
38
//ItemType: "";
39
ItemType: string; // pre-daily tribute
39
40
StoreItemType: string; // uniquely identifies the reward
40
41
//ProductCategory: "Pistols";
41
42
Amount: number;
@@ -122,7 +123,7 @@ const getRandomLoginReward = (rng: SRng, day: number, inventory: TInventoryDatab
122
123
RewardType: reward.RewardType,
123
124
//CouponType: "CPT_PLATINUM",
124
125
Icon: reward.Icon ?? "",
125
//ItemType: "",
126
ItemType: fromStoreItem(storeItemType),
126
127
StoreItemType: storeItemType,
127
128
//ProductCategory: "Pistols",
128
129
Amount: reward.Duration
@@ -163,6 +164,7 @@ export const claimLoginReward = async (
163
164
return updateCurrency(inventory, -reward.Amount, false);
164
165
165
166
case "RT_BOOSTER": {
167
logger.debug(`claim login reward`, reward); // all other paths already log in some other way
166
168
const ItemType = ExportBoosters[reward.StoreItemType].typeName;
167
169
const ExpiryDate = 3600 * reward.Duration;
168
170
addBooster(ItemType, ExpiryDate, inventory);