Merge pull request #55 from PRO100KatYT/main

Added V-Bucks Item refund system.
This commit is contained in:
Lawin0129
2022-01-13 21:10:37 +00:00
committed by GitHub
2 changed files with 271 additions and 2 deletions

View File

@@ -1949,6 +1949,102 @@ express.post("/fortnite/api/game/v2/profile/*/client/ClientQuestLogin", async (r
res.end(); res.end();
}); });
// Refund V-Bucks purchase
express.post("/fortnite/api/game/v2/profile/*/client/RefundMtxPurchase", async (req, res) => {
const profile = require(`./profiles/${req.query.profileId || "common_core"}.json`);
// do not change any of these or you will end up breaking it
var ApplyProfileChanges = [];
var MultiUpdate = [];
var BaseRevision = profile.rvn || 0;
var QueryRevision = req.query.rvn || -1;
var StatChanged = false;
var ItemProfile = require("./profiles/athena.json");
var ItemCost = [];
var ItemGuids = [];
if (req.body.purchaseId) {
for (var purchase in profile.stats.attributes.mtx_purchase_history.purchases) {
if (profile.stats.attributes.mtx_purchase_history.purchases[purchase].purchaseId == req.body.purchaseId) {
for (var item in profile.stats.attributes.mtx_purchase_history.purchases[purchase].lootResult) {
ItemGuids.push(profile.stats.attributes.mtx_purchase_history.purchases[purchase].lootResult[item].itemGuid)
}
}
}
}
if (ItemCost && ItemGuids) {
profile.stats.attributes.mtx_purchase_history.refundsUsed += 1;
profile.stats.attributes.mtx_purchase_history.refundCredits -= 1;
for (var purchase in profile.stats.attributes.mtx_purchase_history.purchases) {
if (profile.stats.attributes.mtx_purchase_history.purchases[purchase].purchaseId == req.body.purchaseId) {
profile.stats.attributes.mtx_purchase_history.purchases[purchase].refundDate = new Date().toISOString();
}
}
for (var item in ItemGuids) {
delete ItemProfile.items[item]
}
ItemProfile.rvn += 1;
ItemProfile.commandRevision += 1;
StatChanged = true;
}
if (StatChanged == true) {
profile.rvn += 1;
profile.commandRevision += 1;
ApplyProfileChanges.push({
"changeType": "statModified",
"name": "mtx_purchase_history",
"value": profile.stats.attributes.mtx_purchase_history
})
MultiUpdate.push({
"profileRevision": ItemProfile.rvn || 0,
"profileId": "athena",
"profileChangesBaseRevision": ItemProfile.rvn || 0,
"profileChanges": [],
"profileCommandRevision": ItemProfile.commandRevision || 0,
})
for (var item in ItemGuids) {
MultiUpdate[0].profileChanges.push({
"changeType": "itemRemoved",
"itemId": item
})
}
MultiUpdate[0].profileRevision = ItemProfile.rvn || 0;
MultiUpdate[0].profileCommandRevision = ItemProfile.commandRevision || 0;
fs.writeFileSync(`./profiles/${req.query.profileId || "athena"}.json`, JSON.stringify(profile, null, 2));
fs.writeFileSync(`./profiles/athena.json`, JSON.stringify(ItemProfile, null, 2));
}
// this doesn't work properly on version v12.20 and above but whatever
if (QueryRevision != BaseRevision) {
ApplyProfileChanges = [{
"changeType": "fullProfileUpdate",
"profile": profile
}];
}
res.json({
"profileRevision": profile.rvn || 0,
"profileId": req.query.profileId || "athena",
"profileChangesBaseRevision": BaseRevision,
"profileChanges": ApplyProfileChanges,
"profileCommandRevision": profile.commandRevision || 0,
"serverTime": new Date().toISOString(),
"multiUpdate": MultiUpdate,
"responseVersion": 1
})
res.end();
});
// Claim STW daily reward // Claim STW daily reward
express.post("/fortnite/api/game/v2/profile/*/client/ClaimLoginReward", async (req, res) => { express.post("/fortnite/api/game/v2/profile/*/client/ClaimLoginReward", async (req, res) => {
const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`);
@@ -4525,7 +4621,7 @@ express.post("/fortnite/api/game/v2/profile/*/client/SetActiveHeroLoadout", asyn
res.end(); res.end();
}); });
// Activate consumable stw STW // Activate consumable STW
express.post("/fortnite/api/game/v2/profile/*/client/ActivateConsumable", async (req, res) => { express.post("/fortnite/api/game/v2/profile/*/client/ActivateConsumable", async (req, res) => {
const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`);

View File

@@ -2007,7 +2007,180 @@
"personal_offers": {}, "personal_offers": {},
"intro_game_played": true, "intro_game_played": true,
"import_friends_claimed": {}, "import_friends_claimed": {},
"mtx_purchase_history": {}, "mtx_purchase_history": {
"refundsUsed": 0,
"refundCredits": 3,
"purchases": [
{
"purchaseId": "AthenaCharacter:CID_009_Athena_Commando_M",
"offerId": "v2:/AthenaCharacter:CID_009_Athena_Commando_M",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_009_Athena_Commando_M",
"itemGuid": "AthenaCharacter:CID_009_Athena_Commando_M",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "Lawin",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_010_Athena_Commando_M",
"offerId": "v2:/AthenaCharacter:CID_010_Athena_Commando_M",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_010_Athena_Commando_M",
"itemGuid": "AthenaCharacter:CID_010_Athena_Commando_M",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "PRO100KatYT",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_011_Athena_Commando_M",
"offerId": "v2:/AthenaCharacter:CID_011_Athena_Commando_M",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_011_Athena_Commando_M",
"itemGuid": "AthenaCharacter:CID_011_Athena_Commando_M",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "Lawin",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_012_Athena_Commando_M",
"offerId": "v2:/AthenaCharacter:CID_012_Athena_Commando_M",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_012_Athena_Commando_M",
"itemGuid": "AthenaCharacter:CID_012_Athena_Commando_M",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "TI93",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_013_Athena_Commando_F",
"offerId": "v2:/AthenaCharacter:CID_013_Athena_Commando_F",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_013_Athena_Commando_F",
"itemGuid": "AthenaCharacter:CID_013_Athena_Commando_F",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "Lawin",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_014_Athena_Commando_F",
"offerId": "v2:/AthenaCharacter:CID_014_Athena_Commando_F",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_014_Athena_Commando_F",
"itemGuid": "AthenaCharacter:CID_014_Athena_Commando_F",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "Playeereq",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_015_Athena_Commando_F",
"offerId": "v2:/AthenaCharacter:CID_015_Athena_Commando_F",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_015_Athena_Commando_F",
"itemGuid": "AthenaCharacter:CID_015_Athena_Commando_F",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "Lawin",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
},
{
"purchaseId": "AthenaCharacter:CID_016_Athena_Commando_F",
"offerId": "v2:/AthenaCharacter:CID_016_Athena_Commando_F",
"purchaseDate": "9999-12-31T00:00:00.000Z",
"freeRefundEligible": false,
"fulfillments": [],
"lootResult": [
{
"itemType": "AthenaCharacter:CID_016_Athena_Commando_F",
"itemGuid": "AthenaCharacter:CID_016_Athena_Commando_F",
"itemProfile": "athena",
"quantity": 1
}
],
"totalMtxPaid": 800,
"metadata": {
"mtx_affiliate": "Matteoki",
"mtx_affiliate_id": "29063ead167541899959bbc9c439acc6"
},
"gameContext": ""
}
]
},
"undo_cooldowns": [], "undo_cooldowns": [],
"mtx_affiliate_set_time": "", "mtx_affiliate_set_time": "",
"inventory_limit_bonus": 0, "inventory_limit_bonus": 0,