Support for generating proper survivor items

This commit is contained in:
PRO100KatYT
2023-03-13 15:47:38 +01:00
parent 4d2f8e4b7c
commit e8d29b819f
4 changed files with 1040 additions and 460 deletions

View File

@@ -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