mirror of
https://github.com/Lawin0129/LawinServer.git
synced 2026-01-13 10:52:23 +01:00
Support for generating proper survivor items
This commit is contained in:
@@ -284,6 +284,47 @@ function getContentPages(req) {
|
||||
return contentpages;
|
||||
}
|
||||
|
||||
function MakeSurvivorAttributes(templateId) {
|
||||
const SurvivorData = require("./../responses/Campaign/survivorData.json");
|
||||
var SurvivorAttributes = {
|
||||
"level": 1,
|
||||
"item_seen": false,
|
||||
"squad_slot_idx": -1,
|
||||
"building_slot_used": -1
|
||||
};
|
||||
|
||||
if (SurvivorData.fixedAttributes.hasOwnProperty(templateId)) {
|
||||
SurvivorAttributes = {...SurvivorAttributes, ...SurvivorData.fixedAttributes[templateId]};
|
||||
}
|
||||
|
||||
if (!SurvivorAttributes.hasOwnProperty("gender")) {
|
||||
SurvivorAttributes.gender = (Math.floor(Math.random() * (1 - 3) + 3)).toString(); // Set a random survivor gender ("1" = male, "2" = female)
|
||||
}
|
||||
|
||||
if (!SurvivorAttributes.hasOwnProperty("managerSynergy")) {
|
||||
var randomNumber = Math.floor(Math.random() * SurvivorData.bonuses.length);
|
||||
SurvivorAttributes.set_bonus = SurvivorData.bonuses[randomNumber];
|
||||
}
|
||||
|
||||
if (!SurvivorAttributes.hasOwnProperty("personality")) {
|
||||
var randomNumber = Math.floor(Math.random() * SurvivorData.personalities.length);
|
||||
SurvivorAttributes.personality = SurvivorData.personalities[randomNumber];
|
||||
}
|
||||
|
||||
if (!SurvivorAttributes.hasOwnProperty("portrait")) {
|
||||
portraitFactor = SurvivorAttributes.personality;
|
||||
if (SurvivorAttributes.hasOwnProperty("managerSynergy")) {
|
||||
portraitFactor = SurvivorAttributes.managerSynergy;
|
||||
}
|
||||
|
||||
var gender = SurvivorAttributes.gender
|
||||
var randomNumber = Math.floor(Math.random() * SurvivorData.portraits[portraitFactor][gender].length);
|
||||
SurvivorAttributes.portrait = SurvivorData.portraits[portraitFactor][gender][randomNumber];
|
||||
}
|
||||
|
||||
return SurvivorAttributes;
|
||||
}
|
||||
|
||||
function MakeID() {
|
||||
return uuid.v4();
|
||||
}
|
||||
@@ -311,6 +352,7 @@ module.exports = {
|
||||
getItemShop,
|
||||
getTheater,
|
||||
getContentPages,
|
||||
MakeSurvivorAttributes,
|
||||
MakeID,
|
||||
sendXmppMessageToAll,
|
||||
DecodeBase64
|
||||
|
||||
@@ -2434,6 +2434,9 @@ express.post("/fortnite/api/game/v2/profile/*/client/TransmogItem", async (req,
|
||||
const randomNumber = Math.floor(Math.random() * transformItemIDS.length);
|
||||
const ID = functions.MakeID();
|
||||
var Item = {"templateId":transformItemIDS[randomNumber],"attributes":{"legacy_alterations":[],"max_level_bonus":0,"level":1,"refund_legacy_item":false,"item_seen":false,"alterations":["","","","","",""],"xp":0,"refundable":false,"alteration_base_rarities":[],"favorite":false},"quantity":1};
|
||||
if (transformItemIDS[randomNumber].toLowerCase().startsWith("worker:")) {
|
||||
Item.attributes = functions.MakeSurvivorAttributes(transformItemIDS[randomNumber]);
|
||||
}
|
||||
|
||||
profile.items[ID] = Item
|
||||
|
||||
@@ -4563,6 +4566,9 @@ express.post("/fortnite/api/game/v2/profile/*/client/OpenCardPack", async (req,
|
||||
const randomNumber = Math.floor(Math.random() * ItemIDS.length);
|
||||
const ID = functions.MakeID();
|
||||
var Item = {"templateId":ItemIDS[randomNumber],"attributes":{"legacy_alterations":[],"max_level_bonus":0,"level":1,"refund_legacy_item":false,"item_seen":false,"alterations":["","","","","",""],"xp":0,"refundable":false,"alteration_base_rarities":[],"favorite":false},"quantity":1};
|
||||
if (ItemIDS[randomNumber].toLowerCase().startsWith("worker:")) {
|
||||
Item.attributes = functions.MakeSurvivorAttributes(ItemIDS[randomNumber]);
|
||||
}
|
||||
|
||||
profile.items[ID] = Item
|
||||
|
||||
@@ -4652,7 +4658,13 @@ express.post("/fortnite/api/game/v2/profile/*/client/PopulatePrerolledOffers", a
|
||||
for (var i = 0; i < 10; i++) {
|
||||
const randomNumber = Math.floor(Math.random() * ItemIDS.length);
|
||||
|
||||
profile.items[key].attributes.items.push({"itemType":ItemIDS[randomNumber],"attributes":{"legacy_alterations":[],"max_level_bonus":0,"level":1,"refund_legacy_item":false,"item_seen":false,"alterations":["","","","","",""],"xp":0,"refundable":false,"alteration_base_rarities":[],"favorite":false},"quantity":1})
|
||||
var Item = {"itemType":ItemIDS[randomNumber],"attributes":{"legacy_alterations":[],"max_level_bonus":0,"level":1,"refund_legacy_item":false,"item_seen":false,"alterations":["","","","","",""],"xp":0,"refundable":false,"alteration_base_rarities":[],"favorite":false},"quantity":1};
|
||||
|
||||
if (ItemIDS[randomNumber].toLowerCase().startsWith("worker:")) {
|
||||
Item.attributes = functions.MakeSurvivorAttributes(ItemIDS[randomNumber]);
|
||||
}
|
||||
|
||||
profile.items[key].attributes.items.push(Item)
|
||||
}
|
||||
|
||||
ApplyProfileChanges.push({
|
||||
@@ -5593,7 +5605,13 @@ express.post("/fortnite/api/game/v2/profile/*/client/PurchaseCatalogEntry", asyn
|
||||
for (var i = 0; i < 10; i++) {
|
||||
const randomNumber = Math.floor(Math.random() * ItemIDS.length);
|
||||
|
||||
campaign.items[key].attributes.items.push({"itemType":ItemIDS[randomNumber],"attributes":{"legacy_alterations":[],"max_level_bonus":0,"level":1,"refund_legacy_item":false,"item_seen":false,"alterations":["","","","","",""],"xp":0,"refundable":false,"alteration_base_rarities":[],"favorite":false},"quantity":1})
|
||||
var Item = {"itemType":ItemIDS[randomNumber],"attributes":{"legacy_alterations":[],"max_level_bonus":0,"level":1,"refund_legacy_item":false,"item_seen":false,"alterations":["","","","","",""],"xp":0,"refundable":false,"alteration_base_rarities":[],"favorite":false},"quantity":1};
|
||||
|
||||
if (ItemIDS[randomNumber].toLowerCase().startsWith("worker:")) {
|
||||
Item.attributes = functions.MakeSurvivorAttributes(ItemIDS[randomNumber]);
|
||||
}
|
||||
|
||||
campaign.items[key].attributes.items.push(Item)
|
||||
}
|
||||
|
||||
MultiUpdate[0].profileChanges.push({
|
||||
|
||||
Reference in New Issue
Block a user