返回提交历史
Modified
src/controllers/api/syndicateSacrificeController.ts
+7
-0
Modified
src/services/purchaseService.ts
+26
-16
XFEstudio/SpaceNinjaServer
fix: track FreeFavorsEarned & FreeFavorsUsed (#792)
9fd2fb6b
代码差异
2 个文件
+33
-16
@@ -50,6 +50,13 @@ export const syndicateSacrificeController: RequestHandler = async (request, resp
50
50
syndicate.Title ??= 0;
51
51
syndicate.Title += 1;
52
52
53
if (syndicate.Title > 0 && manifest.favours.length != 0) {
54
syndicate.FreeFavorsEarned ??= [];
55
if (!syndicate.FreeFavorsEarned.includes(syndicate.Title)) {
56
syndicate.FreeFavorsEarned.push(syndicate.Title);
57
}
58
}
59
53
60
await inventory.save();
54
61
55
62
if (reward) {
@@ -80,23 +80,33 @@ export const handlePurchase = async (
80
80
81
81
switch (purchaseRequest.PurchaseParams.Source) {
82
82
case 2:
83
if (!purchaseRequest.PurchaseParams.UseFreeFavor!) {
83
{
84
84
const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!;
85
const syndicate = ExportSyndicates[syndicateTag];
86
if (syndicate) {
87
const favour = syndicate.favours.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
88
if (favour) {
89
const inventory = await getInventory(accountId);
90
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
91
if (affiliation) {
92
purchaseResponse.Standing = [
93
{
94
Tag: syndicateTag,
95
Standing: favour.standingCost
96
}
97
];
98
affiliation.Standing -= favour.standingCost;
99
await inventory.save();
85
if (purchaseRequest.PurchaseParams.UseFreeFavor!) {
86
const inventory = await getInventory(accountId);
87
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag)!;
88
affiliation.FreeFavorsUsed ??= [];
89
affiliation.FreeFavorsUsed.push(affiliation.FreeFavorsEarned![affiliation.FreeFavorsUsed.length]);
90
await inventory.save();
91
} else {
92
const syndicate = ExportSyndicates[syndicateTag];
93
if (syndicate) {
94
const favour = syndicate.favours.find(
95
x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem
96
);
97
if (favour) {
98
const inventory = await getInventory(accountId);
99
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
100
if (affiliation) {
101
purchaseResponse.Standing = [
102
{
103
Tag: syndicateTag,
104
Standing: favour.standingCost
105
}
106
];
107
affiliation.Standing -= favour.standingCost;
108
await inventory.save();
109
}
100
110
}
101
111
}
102
112
}