Added support for multi-item Winterfest presents.

This commit is contained in:
PRO100KatYT
2022-12-21 17:29:17 +01:00
parent d27c124659
commit b811be6769
2 changed files with 140 additions and 129 deletions

View File

@@ -321,111 +321,120 @@ express.post("/fortnite/api/game/v2/profile/*/client/UnlockRewardNode", async (r
var BaseRevision = profile.rvn || 0;
var QueryRevision = req.query.rvn || -1;
var StatChanged = false;
var CommonCoreChanged = false;
var ItemExists = false;
var Season = "Season" + memory.season;
var ID = functions.MakeID();
const GiftID = functions.MakeID();
profile.items[GiftID] = {"templateId":"GiftBox:gb_winterfestreward","attributes":{"max_level_bonus":0,"fromAccountId":"","lootList":[],"level":1,"item_seen":false,"xp":0,"giftedOn":new Date().toISOString(),"params":{"SubGame":"Athena","winterfestGift":"true"},"favorite":false},"quantity":1};
if (req.body.nodeId && req.body.rewardGraphId) {
if (WinterFestIDS[Season][req.body.nodeId].toLowerCase().startsWith("homebasebannericon:")) {
MultiUpdate.push({
"profileRevision": common_core.rvn || 0,
"profileId": "common_core",
"profileChangesBaseRevision": common_core.rvn || 0,
"profileChanges": [],
"profileCommandRevision": common_core.commandRevision || 0,
})
for (var i = 0; i < WinterFestIDS[Season][req.body.nodeId].length; i++) {
var ID = functions.MakeID();
Reward = WinterFestIDS[Season][req.body.nodeId][i]
for (var key in common_core.items) {
if (common_core.items[key].templateId.toLowerCase() == WinterFestIDS[Season][req.body.nodeId].toLowerCase()) {
common_core.items[key].attributes.item_seen = false;
ID = key;
ItemExists = true;
if (Reward.toLowerCase().startsWith("homebasebannericon:")) {
if (CommonCoreChanged == false) {
MultiUpdate.push({
"profileRevision": common_core.rvn || 0,
"profileId": "common_core",
"profileChangesBaseRevision": common_core.rvn || 0,
"profileChanges": [],
"profileCommandRevision": common_core.commandRevision || 0,
})
CommonCoreChanged = true;
}
for (var key in common_core.items) {
if (common_core.items[key].templateId.toLowerCase() == Reward.toLowerCase()) {
common_core.items[key].attributes.item_seen = false;
ID = key;
ItemExists = true;
MultiUpdate[0].profileChanges.push({
"changeType": "itemAttrChanged",
"itemId": key,
"attributeName": "item_seen",
"attributeValue": common_core.items[key].attributes.item_seen
})
}
}
if (ItemExists == false) {
common_core.items[ID] = {
"templateId": Reward,
"attributes": {
"max_level_bonus": 0,
"level": 1,
"item_seen": false,
"xp": 0,
"variants": [],
"favorite": false
},
"quantity": 1
};
MultiUpdate[0].profileChanges.push({
"changeType": "itemAttrChanged",
"itemId": key,
"attributeName": "item_seen",
"attributeValue": common_core.items[key].attributes.item_seen
"changeType": "itemAdded",
"itemId": ID,
"item": common_core.items[ID]
})
}
ItemExists = false;
common_core.rvn += 1;
common_core.commandRevision += 1;
MultiUpdate[0].profileRevision = common_core.rvn || 0;
MultiUpdate[0].profileCommandRevision = common_core.commandRevision || 0;
profile.items[GiftID].attributes.lootList.push({"itemType":Reward,"itemGuid":ID,"itemProfile":"common_core","attributes":{"creation_time":new Date().toISOString()},"quantity":1})
}
if (ItemExists == false) {
common_core.items[ID] = {
"templateId": WinterFestIDS[Season][req.body.nodeId],
"attributes": {
"max_level_bonus": 0,
"level": 1,
"item_seen": false,
"xp": 0,
"variants": [],
"favorite": false
},
"quantity": 1
};
MultiUpdate[0].profileChanges.push({
"changeType": "itemAdded",
"itemId": ID,
"item": common_core.items[ID]
})
}
if (!Reward.toLowerCase().startsWith("homebasebannericon:")) {
for (var key in profile.items) {
if (profile.items[key].templateId.toLowerCase() == Reward.toLowerCase()) {
profile.items[key].attributes.item_seen = false;
ID = key;
ItemExists = true;
ItemExists = false;
common_core.rvn += 1;
common_core.commandRevision += 1;
MultiUpdate[0].profileRevision = common_core.rvn || 0;
MultiUpdate[0].profileCommandRevision = common_core.commandRevision || 0;
profile.items[GiftID] = {"templateId":"GiftBox:gb_winterfestreward","attributes":{"max_level_bonus":0,"fromAccountId":"","lootList":[{"itemType":WinterFestIDS[Season][req.body.nodeId],"itemGuid":ID,"itemProfile":"common_core","attributes":{"creation_time":new Date().toISOString()},"quantity":1}],"level":1,"item_seen":false,"xp":0,"giftedOn":new Date().toISOString(),"params":{"SubGame":"Athena","winterfestGift":"true"},"favorite":false},"quantity":1};
}
if (!WinterFestIDS[Season][req.body.nodeId].toLowerCase().startsWith("homebasebannericon:")) {
for (var key in profile.items) {
if (profile.items[key].templateId.toLowerCase() == WinterFestIDS[Season][req.body.nodeId].toLowerCase()) {
profile.items[key].attributes.item_seen = false;
ID = key;
ItemExists = true;
ApplyProfileChanges.push({
"changeType": "itemAttrChanged",
"itemId": key,
"attributeName": "item_seen",
"attributeValue": profile.items[key].attributes.item_seen
})
}
}
if (ItemExists == false) {
profile.items[ID] = {
"templateId": Reward,
"attributes": {
"max_level_bonus": 0,
"level": 1,
"item_seen": false,
"xp": 0,
"variants": [],
"favorite": false
},
"quantity": 1
};
ApplyProfileChanges.push({
"changeType": "itemAttrChanged",
"itemId": key,
"attributeName": "item_seen",
"attributeValue": profile.items[key].attributes.item_seen
"changeType": "itemAdded",
"itemId": ID,
"item": profile.items[ID]
})
}
ItemExists = false;
profile.items[GiftID].attributes.lootList.push({"itemType":Reward,"itemGuid":ID,"itemProfile":"athena","attributes":{"creation_time":new Date().toISOString()},"quantity":1})
}
if (ItemExists == false) {
profile.items[ID] = {
"templateId": WinterFestIDS[Season][req.body.nodeId],
"attributes": {
"max_level_bonus": 0,
"level": 1,
"item_seen": false,
"xp": 0,
"variants": [],
"favorite": false
},
"quantity": 1
};
ApplyProfileChanges.push({
"changeType": "itemAdded",
"itemId": ID,
"item": profile.items[ID]
})
}
ItemExists = false;
profile.items[GiftID] = {"templateId":"GiftBox:gb_winterfestreward","attributes":{"max_level_bonus":0,"fromAccountId":"","lootList":[{"itemType":WinterFestIDS[Season][req.body.nodeId],"itemGuid":ID,"itemProfile":"athena","attributes":{"creation_time":new Date().toISOString()},"quantity":1}],"level":1,"item_seen":false,"xp":0,"giftedOn":new Date().toISOString(),"params":{"SubGame":"Athena","winterfestGift":"true"},"favorite":false},"quantity":1};
}
profile.items[req.body.rewardGraphId].attributes.reward_keys[0].unlock_keys_used += 1;
profile.items[req.body.rewardGraphId].attributes.reward_nodes_claimed.push(req.body.nodeId);
@@ -457,7 +466,9 @@ express.post("/fortnite/api/game/v2/profile/*/client/UnlockRewardNode", async (r
})
fs.writeFileSync(`./profiles/${req.query.profileId || "athena"}.json`, JSON.stringify(profile, null, 2));
fs.writeFileSync("./profiles/common_core.json", JSON.stringify(common_core, null, 2));
if (CommonCoreChanged == true) {
fs.writeFileSync("./profiles/common_core.json", JSON.stringify(common_core, null, 2));
}
}
// this doesn't work properly on version v12.20 and above but whatever