diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index 07a3ecdf08832ff4da98134c3964cf45dc61fbbc..736d5655c62fdf878a7f345a7ddef55264bd2141 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -18,18 +18,18 @@ App.Update.autoshred = function(node) { node.append(`Done!`); }; +/** + * @template {object} T + * @template {keyof T} K + * @param {T} obj + * @param {Record<K, T[K]>} props + */ App.Update.setNonexistentProperties = function(obj, props) { - let count = 0; for (const p of Object.getOwnPropertyNames(props)) { if (typeof obj[p] === "undefined") { - if (obj[p] !== props[p]) { - console.log("setting V." + p + " to ", props[p]); - } obj[p] = clone(props[p]); - count++; } } - return console.log(`Set up ${count} variables.`); }; App.Update.setExistentProperties = function(obj, array) { @@ -45,6 +45,40 @@ App.Update.setExistentProperties = function(obj, array) { } }; +/** + * Moves properties listed in `props` values from `src` to `dst`, renaming them according to + * `props` keys + * @template {object} T + * @template {keyof T} K + * @param {T} target + * @param {object} source + * @param {Record<K, string>} props + * @param {boolean}[overwrite=true] Overwrite target properties + * @param {boolean}[alwaysDelete=false] Delete source property even if it was not moved + */ +App.Update.moveProperties = function(target, source, props, overwrite = true, alwaysDelete = false) { + for (const [k, v] of Object.entries(props)) { + if (source.hasOwnProperty(v)) { + if (overwrite || !target.hasOwnProperty(k)) { + target[k] = source[v]; + delete source[v]; + } else if (alwaysDelete) { + delete source[v]; + } + } + } +}; + +/** + * @param {object} obj + * @param {string[]} props + */ +App.Update.deleteProperties = function(obj, props) { + for (const p of props) { + delete obj[p]; + } +}; + /** * @returns {DocumentFragment} */ @@ -170,14 +204,10 @@ App.Update.globalVariables = function(node) { if (jQuery.isEmptyObject(V.scarDesign)) { V.scarDesign = {primary: "generic", local: "generic"}; } - if (V.customItem.hasOwnProperty("dildos")) { - V.customItem.vaginalAccessory = V.customItem.dildos; - delete V.customItem.dildos; - } - if (V.customItem.hasOwnProperty("buttPlugs")) { - V.customItem.buttplug = V.customItem.buttPlugs; - delete V.customItem.buttPlugs; - } + App.Update.moveProperties(V.customItem, V.customItem, { + vaginalAccessory: "dildos", + buttplug: "buttPlugs" + }); if (V.releaseID <= 1110) { V.researchLab.tasks = V.researchLab.tasks.filter((t) => (!(t.hasOwnProperty("slaveID")) || Object.keys(V.slaveIndices).includes(t.slaveID))); } diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js index ab3522a1934e0f65dc396ddedea1cce1b9a96a1c..1d01e17a14a333f5a0df44054655b40696f224a0 100644 --- a/src/data/backwardsCompatibility/datatypeCleanup.js +++ b/src/data/backwardsCompatibility/datatypeCleanup.js @@ -24,12 +24,7 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { migrateHealth(slave); App.Entity.Utils.migratePronouns(slave); - if (slave.hasOwnProperty("assignmentVisible")) { - delete slave.assignmentVisible; - } - if (slave.hasOwnProperty("tired")) { - delete slave.tired; - } + App.Update.deleteProperties(slave, ["assignmentVisible", "tired"]); } /** @@ -55,20 +50,15 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { function migrateRules(slave) { if (!slave.hasOwnProperty("rules")) { slave.rules = new App.Entity.RuleState(); - slave.rules.lactation = slave.lactationRules; - delete slave.lactationRules; - slave.rules.living = slave.livingRules; - delete slave.livingRules; - slave.rules.relationship = slave.relationshipRules; - delete slave.relationshipRules; - slave.rules.release = slave.releaseRules; - delete slave.releaseRules; - slave.rules.speech = slave.speechRules; - delete slave.speechRules; - slave.rules.punishment = slave.standardPunishment; - delete slave.standardPunishment; - slave.rules.reward = slave.standardReward; - delete slave.standardReward; + App.Update.moveProperties(slave.rules, slave, { + lactation: "lactationRules", + living: "livingRules", + relationship: "relationshipRules", + release: "releaseRules", + speech: "speechRules", + punishment: "standardPunishment", + reward: "standardReward" + }); } } @@ -146,41 +136,19 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { delete slave[prop]; } } - if (slave.hasOwnProperty("pornFameType")) { - slave.porn.fameType = slave.pornFameType; - delete slave.pornFameType; - } - - if (slave.hasOwnProperty("pornFocus")) { - slave.porn.focus = slave.pornFocus; - delete slave.pornFocus; - } - } - - if (slave.hasOwnProperty("pornFeed")) { - slave.porn.feed = slave.pornFeed; - delete slave.pornFeed; - } - - if (slave.hasOwnProperty("pornFame")) { - slave.porn.viewerCount = slave.pornFame; - delete slave.pornFame; - } - - if (slave.hasOwnProperty("pornFameSpending")) { - slave.porn.spending = slave.pornFameSpending; - delete slave.pornFameSpending; - } - - if (slave.hasOwnProperty("pornPrestige")) { - slave.porn.prestige = slave.pornPrestige; - delete slave.pornPrestige; + App.Update.moveProperties(slave.porn, slave, { + fameType: "pornFameType", + focus: "pornFocus" + }); } - if (slave.hasOwnProperty("pornPrestigeDesc")) { - slave.porn.prestigeDesc = slave.pornPrestigeDesc; - delete slave.pornPrestigeDesc; - } + App.Update.moveProperties(slave.porn, slave, { + feed: "pornFeed", + viewerCount: "pornFame", + spending: "pornFameSpending", + prestige: "pornPrestige", + prestigeDesc: "pornPrestigeDesc", + }); } /** @@ -189,18 +157,14 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { function migrateSkills(slave) { if (!slave.hasOwnProperty("skill")) { slave.skill = new App.Entity.SlaveSkillsState(); - slave.skill.anal = slave.analSkill; - slave.skill.combat = slave.combatSkill; - slave.skill.entertainment = slave.entertainSkill; - slave.skill.oral = slave.oralSkill; - slave.skill.vaginal = slave.vaginalSkill; - slave.skill.whoring = slave.whoreSkill; - delete slave.analSkill; - delete slave.combatSkill; - delete slave.entertainSkill; - delete slave.oralSkill; - delete slave.vaginalSkill; - delete slave.whoreSkill; + App.Update.moveProperties(slave.skill, slave, { + anal: "analSkill", + combat: "combatSkill", + entertainment: "entertainSkill", + oral: "oralSkill", + vaginal: "vaginalSkill", + whoring: "whoreSkill" + }); const nameMap = { "HG": "headGirl", @@ -237,14 +201,13 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { function migrateCounters(slave) { if (!slave.hasOwnProperty("counter")) { slave.counter = new App.Entity.SlaveActionsCountersState(); - let c = slave.counter; - const nameMap = { // old => new - analCount: "anal", - mammaryCount: "mammary", - oralCount: "oral", - penetrativeCount: "penetrative", - vaginalCount: "vaginal", - publicCount: "publicUse", + App.Update.moveProperties(slave.counter, slave, { // new <= old + anal: "analCount", + mammary: "mammaryCount", + oral: "oralCount", + penetrative: "penetrativeCount", + vaginal: "vaginalCount", + publicUse: "publicCount", pitKills: "pitKills", milk: "milk", cum: "cum", @@ -255,13 +218,7 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { PCChildrenFathered: "PCChildrenFathered", slavesKnockedUp: "slavesKnockedUp", PCKnockedUp: "PCKnockedUp", - }; - for (let prop in slave) { - if (nameMap.hasOwnProperty(prop)) { - c[nameMap[prop]] = slave[prop]; - delete slave[prop]; - } - } + }); } } @@ -274,30 +231,21 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { const c = slave.custom; // custom image and format compose an object together if (slave.customImage !== "" && slave.customImage !== undefined) { - const fileType = slave.customImageFormat || "png"; c.image = { filename: slave.customImage, - format: fileType + format: slave.customImageFormat || "png" }; } - delete slave.customImageFormat; - delete slave.customImage; - - const nameMap = { // old => new - customTat: "tattoo", - customLabel: "label", - customDesc: "desc", - customTitle: "title", - customTitleLisp: "titleLisp", - customHairVector: "hairVector" - }; - - for (let prop in slave) { - if (nameMap.hasOwnProperty(prop)) { - c[nameMap[prop]] = slave[prop]; - delete slave[prop]; - } - } + App.Update.deleteProperties(slave, ["customImageFormat", "customImage"]); + + App.Update.moveProperties(c, slave, { // new <= old + tattoo: "customTat", + label: "customLabel", + desc: "customDesc", + title: "customTitle", + titleLisp: "customTitleLisp", + hairVector: "customHairVector" + }); } } @@ -1665,12 +1613,8 @@ globalThis.PCDatatypeCleanup = (function PCDatatypeCleanup() { PC.origBodyOwner = ""; } PC.origBodyOwnerID = Math.max(+PC.origBodyOwnerID, 0) || 0; - if (PC.indenture !== undefined) { - delete PC.indenture; - } - if (PC.indentureRestrictions !== undefined) { - delete PC.indentureRestrictions; - } + App.Update.deleteProperties(PC, ["indenture", "indentureRestrictions"]); + if (typeof PC.partners !== "object") { PC.partners = new Set(); } @@ -1891,10 +1835,9 @@ globalThis.FacilityDatatypeCleanup = (function() { V.brothel = Math.max(+V.brothel, 0) || 0; V.brothelUpgradeDrugs = Math.clamp(+V.brothelUpgradeDrugs, 0, 2) || 0; V.brothelBoost.selected = Math.clamp(+V.brothelBoost.selected, 0, 10) || 0; - if (typeof V.brothelBoost.eligable !== "undefined") { // FFS, spell it right... - V.brothelBoost.eligible = V.brothelBoost.eligable; - delete V.brothelBoost.eligable; - } + App.Update.moveProperties(V.brothelBoost, V.brothelBoost, { // FFS, spell it right... + eligible: "eligable" + }); V.brothelBoost.eligible = Math.clamp(+V.brothelBoost.eligible, 0, 10) || 0; /* madam */ V.MadamID = findSlaveId(s => s.assignment === Job.MADAM); @@ -2073,7 +2016,7 @@ App.Entity.Utils.GenePoolRecordCleanup = (function() { App.Entity.Utils.SlaveDataSchemeCleanup(slave); // the following attributes are unneeded for gene pool records - [ + App.Update.deleteProperties(slave, [ "counter", "custom", "porn", "prestige", "prestigeDesc", "subTarget", "relationship", "relationshipTarget", "rivalry", "rivalryTarget", @@ -2119,7 +2062,7 @@ App.Entity.Utils.GenePoolRecordCleanup = (function() { "NCSyouthening", "lastWeeksCashIncome", "lastWeeksRepIncome", "lastWeeksRepExpenses", "lifetimeCashIncome", "lifetimeCashExpenses", "lifetimeRepIncome", "lifetimeRepExpenses" - ].forEach((s) => delete slave[s]); + ]); } })(); @@ -2264,56 +2207,66 @@ App.Entity.Utils.RARuleDatatypeCleanup = function() { } /** - * @param {FC.RA.RuleSetters} set + * @param {FC.RA.RuleReleaseSetters} rr + * @returns {FC.RA.RuleReleaseSetters} */ - function migrateReleaseRules(set) { - if (typeof set.releaseRules === 'string') { - let newRule = {}; - switch (set.releaseRules) { + function convertReleaseRules(rr) { + if (typeof rr === 'string') { + switch (rr) { case "chastity": - newRule.masturbation = 0; - newRule.partner = 0; - newRule.family = 0; - newRule.slaves = 0; - newRule.master = 0; - break; + return { + facilityLeader: 0, + masturbation: 0, + partner: 0, + family: 0, + slaves: 0, + master: 0 + }; case "restrictive": - newRule.masturbation = 0; - newRule.partner = 1; - newRule.family = 0; - newRule.slaves = 0; - newRule.master = 1; - break; + return { + facilityLeader: 1, + masturbation: 0, + partner: 1, + family: 0, + slaves: 0, + master: 1 + }; case "masturbation": - newRule.masturbation = 1; - newRule.partner = 0; - newRule.family = 0; - newRule.slaves = 0; - newRule.master = 1; - break; + return { + facilityLeader: 1, + masturbation: 1, + partner: 0, + family: 0, + slaves: 0, + master: 1 + }; case "sapphic": - newRule.masturbation = 0; - newRule.partner = 1; - newRule.family = 1; - newRule.slaves = 1; - newRule.master = 1; - break; + return { + facilityLeader: 1, + masturbation: 0, + partner: 1, + family: 1, + slaves: 1, + master: 1, + }; case "permissive": - newRule.masturbation = 1; - newRule.partner = 1; - newRule.family = 1; - newRule.slaves = 1; - newRule.master = 1; - break; + return { + facilityLeader: 1, + masturbation: 1, + partner: 1, + family: 1, + slaves: 1, + master: 1, + }; } - set.releaseRules = newRule; } + return rr; } /** @param {FC.RA.RuleSetters} set */ function cleanupSetters(set) { settersSchemeCleanup(set); - migrateReleaseRules(set); + set.releaseRules = convertReleaseRules(set.releaseRules); replaceDefaultValues(set); function transformValues(obj, props, cb) { diff --git a/src/data/backwardsCompatibility/modsBC.js b/src/data/backwardsCompatibility/modsBC.js index c5631e96cf46f1d51db0e37e86b73171156b6641..d536a0f680db20dcb3148e9e6c3b0708a76185bf 100644 --- a/src/data/backwardsCompatibility/modsBC.js +++ b/src/data/backwardsCompatibility/modsBC.js @@ -1,93 +1,20 @@ -// @ts-nocheck App.Update.mods = function(node) { food(); function food() { - if (!V.mods) { - V.mods = {}; - } - if (!V.mods.food) { - V.mods.food = { - enabled: false, - - amount: 125000, - cost: 25, - lastWeek: 0, - market: false, - produced: 0, - rate: { - slave: 8, - lower: 14.5, - middle: 16, - upper: 17.5, - top: 19, - }, - rations: 0, - total: 0, - warned: false, - }; - } - - if (V.food) { - V.mods.food.amount = V.food; - - delete V.food; - } - - if (V.foodCost) { - V.mods.food.cost = V.foodCost; - - delete V.farmyardFoodCost; - delete V.foodCost; - } - - if (V.foodLastWeek) { - V.mods.food.lastWeek = V.foodLastWeek; - - delete V.foodLastWeek; - } - - if (V.foodMarket) { - V.mods.food.market = true; - - delete V.foodMarket; - } - - if (V.foodMarket) { - V.mods.food.market = V.foodMarket; - - delete V.foodMarket; - } - - if (V.foodProduced) { - V.mods.food.produced = V.foodProduced; - - delete V.foodProduced; - } - - if (V.foodRate) { - V.mods.food.rate = V.foodRate; - - delete V.foodRate; - } - - if (V.foodRation) { - V.mods.food.rations = V.foodRations; - - delete V.foodRations; - } - - if (V.foodTotal) { - V.mods.food.total = V.foodTotal; - - delete V.foodTotal; - } - - if (V.foodWarned) { - V.mods.food.warned = V.foodWarned; - - delete V.foodWarned; - } + App.Update.deleteProperties(V, ["farmyardFoodCost"]); + + App.Update.moveProperties(V.mods.food, V, { + cost: "foodCost", + amount: "food", + lastWeek: "foodLastWeek", + market: "foodMarket", + produced: "foodProduced", + rate: "foodRate", + rations: "foodRations", + total: "foodTotal", + warned: "foodWarned" + }); V.mods.food.amount = Math.max(+V.mods.food.amount, 0) || 12500; V.mods.food.cost = Math.trunc(2500 / V.localEcon); diff --git a/src/data/backwardsCompatibility/policiesBC.js b/src/data/backwardsCompatibility/policiesBC.js index d785f8f5284278a33dbd5cf642edc1909a45e2d6..af28db08ccd7df11a64bc1ea017a14a3784a9805 100644 --- a/src/data/backwardsCompatibility/policiesBC.js +++ b/src/data/backwardsCompatibility/policiesBC.js @@ -1,4 +1,3 @@ -// @ts-nocheck App.Update.policies = function() { function convertMain(variable, pro, anti) { if (V[pro]) { @@ -14,11 +13,11 @@ App.Update.policies = function() { } } - if(V.policies.gumjobFetishism == null) { + if (V.policies.gumjobFetishism == null) { V.policies.gumjobFetishism = 0; } - if(V.policies.gumjobFetishismSMR == null) { + if (V.policies.gumjobFetishismSMR == null) { V.policies.gumjobFetishismSMR = 0; } @@ -29,23 +28,25 @@ App.Update.policies = function() { V.policies.immigrationRep = V.policies.immigrationRep || V.policies.immmigrationRep || 0; if (V.releaseID < 1069) { - V.policies.childProtectionAct = V.childProtectionAct; - V.policies.culturalOpenness = V.CulturalOpenness; - V.policies.sexualOpenness = V.sexualOpenness || V.sexualOpeness; - V.policies.proRefugees = V.ProRefugees; - V.policies.publicFuckdolls = V.publicFuckdolls; - - V.policies.proRecruitment = V.ProRecruitment; - V.policies.cash4Babies = V.Cash4Babies; - V.policies.regularParties = V.RegularParties; - V.policies.publicPA = V.PAPublic; - V.policies.coursingAssociation = V.CoursingAssociation; - - V.policies.raidingMercenaries = V.RaidingMercenaries; - V.policies.mixedMarriage = V.MixedMarriage; - V.policies.goodImageCampaign = V.goodImageCampaign; - V.policies.alwaysSubsidizeRep = V.alwaysSubsidizeRep; - V.policies.alwaysSubsidizeGrowth = V.alwaysSubsidizeGrowth; + App.Update.moveProperties(V.policies, V, { + childProtectionAct: "childProtectionAct", + culturalOpenness: "CulturalOpenness", + sexualOpenness: V.hasOwnProperty("sexualOpenness") ? "sexualOpenness" : "sexualOpeness", + proRefugees: "ProRefugees", + publicFuckdolls: "publicFuckdolls", + + proRecruitment: "ProRecruitment", + cash4Babies: "Cash4Babies", + regularParties:"RegularParties", + publicPA: "PAPublic", + coursingAssociation: "CoursingAssociation", + + raidingMercenaries: "RaidingMercenaries", + mixedMarriage: "MixedMarriage", + goodImageCampaign: "goodImageCampaign", + alwaysSubsidizeRep: "alwaysSubsidizeRep", + alwaysSubsidizeGrowth: "alwaysSubsidizeGrowth" + }); convertMain('immigrationCash', 'ProImmigrationCash', 'AntiImmigrationCash'); convertMain('immigrationRep', 'ProImmigrationRep', 'AntiImmigrationRep'); @@ -63,37 +64,56 @@ App.Update.policies = function() { convertRetirement('births', 'BirthsMilestoneRetirement', 'retirementBirths'); convertRetirement('kills', 'KillsMilestoneRetirement', 'retirementKills'); - if (V.BioreactorRetirement) { - V.policies.retirement.fate = "bioreactor"; - } else if (V.ArcadeRetirement) { - V.policies.retirement.fate = "arcade"; - } else if (V.CitizenRetirement) { - V.policies.retirement.fate = "citizen"; + const retirementFates = { + bioreactor: "BioreactorRetirement", + arcade: "ArcadeRetirement", + citizen: "CitizenRetirement" + }; + for (const [k, v] of Object.entries(retirementFates)) { + if (V[v]) { + V.policies.retirement.fate = k; + } } - - V.policies.retirement.menial2Citizen = V.citizenRetirementMenials; - V.policies.retirement.customAgePolicy = V.policies.retirement.customAgePolicySet || V.CustomRetirementAgePolicy; - V.policies.retirement.physicalAgePolicy = V.PhysicalRetirementAgePolicy; - - V.policies.SMR.basicSMR = V.BasicSMR; - V.policies.SMR.healthInspectionSMR = V.HealthInspectionSMR; - V.policies.SMR.educationSMR = V.EducationSMR; - V.policies.SMR.frigiditySMR = V.FrigiditySMR; - - V.policies.SMR.weightSMR = V.BasicWeightSMR; - V.policies.SMR.honestySMR = V.HonestySMR; - - V.policies.SMR.beauty.basicSMR = V.BasicBeautySMR; - V.policies.SMR.beauty.qualitySMR = V.QualityBeautySMR; - - V.policies.SMR.height.basicSMR = V.BasicHeightSMR; - V.policies.SMR.height.advancedSMR = V.AdvancedHeightSMR; - - V.policies.SMR.intelligence.basicSMR = V.BasicIntelligenceSMR; - V.policies.SMR.intelligence.qualitySMR = V.QualityIntelligenceSMR; - - V.policies.SMR.eugenics.faceSMR = V.FaceEugenicsSMR; - V.policies.SMR.eugenics.heightSMR = V.HeightEugenicsSMR; - V.policies.SMR.eugenics.intelligenceSMR = V.IntelligenceEugenicsSMR; + App.Update.deleteProperties(V, Object.values(retirementFates)); + + App.Update.moveProperties(V.policies.retirement, V, { + menial2Citizen: "citizenRetirementMenials", + physicalAgePolicy: "PhysicalRetirementAgePolicy" + }); + + App.Update.moveProperties(V.policies.retirement, V, { + customAgePolicy: "CustomRetirementAgePolicy" + }, false, true); + + App.Update.moveProperties(V.policies.SMR, V, { + basicSMR: "BasicSMR", + healthInspectionSMR: "HealthInspectionSMR", + educationSMR: "EducationSMR", + frigiditySMR: "FrigiditySMR", + + weightSMR: "BasicWeightSMR", + honestySMR: "HonestySMR" + }); + + App.Update.moveProperties(V.policies.SMR.beauty, V, { + basicSMR: "BasicBeautySMR", + qualitySMR: "QualityBeautySMR" + }); + + App.Update.moveProperties(V.policies.SMR.height, V, { + basicSMR: "BasicHeightSMR", + advancedSMR: "AdvancedHeightSMR" + }); + + App.Update.moveProperties(V.policies.SMR.intelligence, V, { + basicSMR: "BasicIntelligenceSMR", + qualitySMR: "QualityIntelligenceSMR" + }); + + App.Update.moveProperties(V.policies.SMR.eugenics, V, { + faceSMR: "FaceEugenicsSMR", + heightSMR: "HeightEugenicsSMR", + intelligenceSMR: "IntelligenceEugenicsSMR" + }); } }; diff --git a/src/data/backwardsCompatibility/updateCustomSlaveOrder.js b/src/data/backwardsCompatibility/updateCustomSlaveOrder.js index 79bd6a4bf60318eb4caf1243a127062fe9dd1b56..d58dec2814789d7140d19aade73beb4e0b25f707 100644 --- a/src/data/backwardsCompatibility/updateCustomSlaveOrder.js +++ b/src/data/backwardsCompatibility/updateCustomSlaveOrder.js @@ -18,26 +18,19 @@ App.Update.CustomSlaveOrder = function(customSlaveOrder) { } } - if (customSlaveOrder.hasOwnProperty("amp")) { - delete customSlaveOrder.amp; - } + App.Update.deleteProperties(customSlaveOrder, ["amp"]); - if (!customSlaveOrder.hasOwnProperty("skill")) { - customSlaveOrder.skill = {whore: 15, combat: 0}; - } + App.Update.setNonexistentProperties(customSlaveOrder, { + skill: {whore: 15, combat: 0}, + }); - if (customSlaveOrder.hasOwnProperty("whoreSkills")) { - customSlaveOrder.skill.whore = customSlaveOrder.whoreSkills; - delete customSlaveOrder.whoreSkills; - } - - if (customSlaveOrder.hasOwnProperty("combatSkills")) { - customSlaveOrder.skill.combat = customSlaveOrder.combatSkills; - delete customSlaveOrder.combatSkills; - } + App.Update.moveProperties(customSlaveOrder.skill, customSlaveOrder, { + whore: "whoreSkills", + combat: "combatSkills" + }); if (V.releaseID < 1059) { customSlaveOrder.eye = new App.Entity.EyeState(); - delete customSlaveOrder.eyes; + App.Update.deleteProperties(customSlaveOrder, ["eyes"]); } }; diff --git a/src/data/backwardsCompatibility/updateSlaveObject.js b/src/data/backwardsCompatibility/updateSlaveObject.js index b9a153a7c1625e0abfc7d8218cca922b48f00c38..067747223df29d49b5a40c3f44be1c43685b464f 100644 --- a/src/data/backwardsCompatibility/updateSlaveObject.js +++ b/src/data/backwardsCompatibility/updateSlaveObject.js @@ -1,36 +1,59 @@ +// @ts-nocheck +/** + * @param {FC.SlaveState} slave + * @param {boolean} [genepool=false] + */ App.Update.Slave = function(slave, genepool = false) { const quirks = {}; App.Data.geneticQuirks.forEach((value, q) => quirks[q] = 0); slave.geneticQuirks = Object.assign(clone(quirks), slave.geneticQuirks); - if (slave.earShape === undefined) { slave.earShape = "normal"; } - if (slave.earT === undefined) { slave.earT = "none"; } - if (slave.earTColor === undefined) { slave.earTColor = "hairless"; } - if (slave.earTEffect === undefined) { slave.earTEffect = "none"; } - if (slave.earTEffectColor === undefined) { slave.earTEffectColor = "none"; } - if (slave.horn === undefined) { slave.horn = "none"; } - if (slave.hornColor === undefined) { slave.hornColor = "none"; } - if (slave.tail === undefined) { slave.tail = "none"; } - if (slave.tailShape === undefined) { slave.tailShape = "none"; } - if (slave.tailColor === undefined) { slave.tailColor = "none"; } - if (slave.appendages === undefined) { slave.appendages = "none"; } - if (slave.wingsShape === undefined) { slave.wingsShape = "none"; } - if (slave.appendagesColor === undefined) { slave.appendagesColor = "none"; } - if (slave.hColor === undefined) { slave.hColor = "black"; } - if (slave.hEffect === undefined) { slave.hEffect = "none"; } - if (slave.hEffectColor === undefined) { slave.hEffectColor = "none"; } - if (slave.tailEffect === undefined) { slave.tailEffect = "none"; } - if (slave.tailEffectColor === undefined) { slave.tailEffectColor = "none"; } - if (slave.appendagesEffect === undefined) { slave.appendagesEffect = "none"; } - if (slave.appendagesEffectColor === undefined) { slave.appendagesEffectColor = "none"; } + App.Update.setNonexistentProperties(slave, { + earShape: "normal", + earT: "none", + earTColor: "hairless", + earTEffect: "none", + earTEffectColor: "none", + horn: "none", + hornColor: "none", + tail: "none", + tailShape: "none", + tailColor: "none", + appendages: "none", + wingsShape: "none", + appendagesColor: "none", + hColor: "black", + hEffect: "none", + hEffectColor: "none", + tailEffect: "none", + appendagesEffect: "none", + appendagesEffectColor: "none", + daughters: 0, + sisters: 0, + wombImplant: "none", + induceLactation: 0, + weightDirection: 0, + clone: 0, + abortionTat: -1, + birthsTat: -1, + readyProsthetics: [], + /* eslint-disable camelcase */ + override_Race: 0, + override_Skin: 0, + override_Eye_Color: 0, + override_H_Color: 0, + override_Pubic_H_Color: 0, + override_Arm_H_Color: 0, + /* eslint-enable camelcase */ + pregControl: "none", + }); + if (slave.prostateImplant !== undefined) { if (slave.prostateImplant === 1) { slave.prostate = 3; } delete slave.prostateImplant; } - if (slave.daughters === undefined) { slave.daughters = 0; } - if (slave.sisters === undefined) { slave.sisters = 0; } if (slave.pregGenerator !== undefined) { delete slave.pregGenerator; } if (slave.pregAdaptation === undefined) { if (slave.physicalAge <= 3) { @@ -80,7 +103,6 @@ App.Update.Slave = function(slave, genepool = false) { delete slave.inducedNCS; } if (slave.PCSlutContacts !== undefined) { delete slave.PCSlutContacts; } - if (slave.wombImplant === undefined) { slave.wombImplant = "none"; } if (slave.superfetation !== undefined) { delete slave.superfetation; } if (slave.lactationDuration === undefined) { if (slave.lactation === 0) { @@ -89,11 +111,7 @@ App.Update.Slave = function(slave, genepool = false) { slave.lactationDuration = 2; } } - if (slave.induceLactation === undefined) { slave.induceLactation = 0; } - if (slave.weightDirection === undefined) { slave.weightDirection = 0; } - if (slave.clone === undefined) { slave.clone = 0; } - if (slave.abortionTat === undefined) { slave.abortionTat = -1; } - if (slave.birthsTat === undefined) { slave.birthsTat = -1; } + if (slave.reservedChildren !== undefined) { delete slave.reservedChildren; } if (slave.origin !== undefined && slave.origin !== 0) { slave.origin = pronounReplacer(slave.origin); } if (slave.custom !== undefined) { @@ -171,7 +189,6 @@ App.Update.Slave = function(slave, genepool = false) { if (slave.auricle !== undefined) { delete slave.auricle; } - if (slave.readyProsthetics === undefined) { slave.readyProsthetics = []; } if (slave.readyLimbs !== undefined) { for (let k = 0; k < slave.readyLimbs.length; k++) { switch (slave.readyLimbs[k].type) { @@ -320,15 +337,6 @@ App.Update.Slave = function(slave, genepool = false) { slave.race = "white"; } - /* eslint-disable camelcase */ - if (slave.override_Race === undefined) { slave.override_Race = 0; } - if (slave.override_Skin === undefined) { slave.override_Skin = 0; } - if (slave.override_Eye_Color === undefined) { slave.override_Eye_Color = 0; } - if (slave.override_H_Color === undefined) { slave.override_H_Color = 0; } - if (slave.override_Pubic_H_Color === undefined) { slave.override_Pubic_H_Color = 0; } - if (slave.override_Arm_H_Color === undefined) { slave.override_Arm_H_Color = 0; } - /* eslint-enable camelcase */ - switch (slave.skin) { case "red dyed": slave.skin = "dyed red"; @@ -714,203 +722,34 @@ App.Update.Slave = function(slave, genepool = false) { } } - switch (slave.boobsTat) { - case "floral designs": - slave.boobsTat = "flowers"; - break; - case "demeaning inscriptions": - slave.boobsTat = "rude words"; - break; - case "lewd scenes": - slave.boobsTat = "scenes"; - break; - case "degrading language": - slave.boobsTat = "degradation"; - break; - case "slutty advertisements": - slave.boobsTat = "advertisements"; - break; - } - - switch (slave.buttTat) { - case "floral designs": - slave.buttTat = "flowers"; - break; - case "demeaning inscriptions": - slave.buttTat = "rude words"; - break; - case "lewd scenes": - slave.buttTat = "scenes"; - break; - case "degrading language": - slave.buttTat = "degradation"; - break; - case "slutty advertisements": - slave.buttTat = "advertisements"; - break; - } - - switch (slave.vaginaTat) { - case "floral designs": - slave.vaginaTat = "flowers"; - break; - case "demeaning inscriptions": - slave.vaginaTat = "rude words"; - break; - case "lewd scenes": - slave.vaginaTat = "scenes"; - break; - case "degrading language": - slave.vaginaTat = "degradation"; - break; - case "slutty advertisements": - slave.vaginaTat = "advertisements"; - break; - } - - switch (slave.dickTat) { - case "floral designs": - slave.dickTat = "flowers"; - break; - case "demeaning inscriptions": - slave.dickTat = "rude words"; - break; - case "lewd scenes": - slave.dickTat = "scenes"; - break; - case "degrading language": - slave.dickTat = "degradation"; - break; - case "slutty advertisements": - slave.dickTat = "advertisements"; - break; - } - - switch (slave.anusTat) { - case "floral designs": - slave.anusTat = "flowers"; - break; - case "demeaning inscriptions": - slave.anusTat = "rude words"; - break; - case "lewd scenes": - slave.anusTat = "scenes"; - break; - case "degrading language": - slave.anusTat = "degradation"; - break; - case "slutty advertisements": - slave.anusTat = "advertisements"; - break; - } - - switch (slave.backTat) { - case "floral designs": - slave.backTat = "flowers"; - break; - case "demeaning inscriptions": - slave.backTat = "rude words"; - break; - case "lewd scenes": - slave.backTat = "scenes"; - break; - case "degrading language": - slave.backTat = "degradation"; - break; - case "slutty advertisements": - slave.backTat = "advertisements"; - break; - } - - switch (slave.shouldersTat) { - case "floral designs": - slave.shouldersTat = "flowers"; - break; - case "demeaning inscriptions": - slave.shouldersTat = "rude words"; - break; - case "lewd scenes": - slave.shouldersTat = "scenes"; - break; - case "degrading language": - slave.shouldersTat = "degradation"; - break; - case "slutty advertisements": - slave.shouldersTat = "advertisements"; - break; - } - - switch (slave.armsTat) { - case "floral designs": - slave.armsTat = "flowers"; - break; - case "demeaning inscriptions": - slave.armsTat = "rude words"; - break; - case "lewd scenes": - slave.armsTat = "scenes"; - break; - case "degrading language": - slave.armsTat = "degradation"; - break; - case "slutty advertisements": - slave.armsTat = "advertisements"; - break; - } - - switch (slave.legsTat) { - case "floral designs": - slave.legsTat = "flowers"; - break; - case "demeaning inscriptions": - slave.legsTat = "rude words"; - break; - case "lewd scenes": - slave.legsTat = "scenes"; - break; - case "degrading language": - slave.legsTat = "degradation"; - break; - case "slutty advertisements": - slave.legsTat = "advertisements"; - break; - } - - switch (slave.stampTat) { - case "floral designs": - slave.stampTat = "flowers"; - break; - case "demeaning inscriptions": - slave.stampTat = "rude words"; - break; - case "lewd scenes": - slave.stampTat = "scenes"; - break; - case "degrading language": - slave.stampTat = "degradation"; - break; - case "slutty advertisements": - slave.stampTat = "advertisements"; - break; - } - - switch (slave.lipsTat) { - case "floral designs": - slave.lipsTat = "flowers"; - break; - case "demeaning inscriptions": - slave.lipsTat = "rude words"; - break; - case "lewd scenes": - slave.lipsTat = "scenes"; - break; - case "degrading language": - slave.lipsTat = "degradation"; - break; - case "slutty advertisements": - slave.lipsTat = "advertisements"; - break; - } + const tatMap = v => { + switch (v) { + case "floral designs": + return "flowers"; + case "demeaning inscriptions": + return "rude words"; + case "lewd scenes": + return "scenes"; + case "degrading language": + return "degradation"; + case "slutty advertisements": + return "advertisements"; + default: + return v; + } + }; + + slave.boobsTat = tatMap(slave.boobsTat); + slave.buttTat = tatMap(slave.buttTat); + slave.vaginaTat = tatMap(slave.vaginaTat); + slave.dickTat = tatMap(slave.dickTat); + slave.anusTat = tatMap(slave.anusTat); + slave.backTat = tatMap(slave.backTat); + slave.shouldersTat = tatMap(slave.shouldersTat); + slave.armsTat = tatMap(slave.armsTat); + slave.legsTat = tatMap(slave.legsTat); + slave.stampTat = tatMap(slave.stampTat); + slave.lipsTat = tatMap(slave.lipsTat); if (slave.currentRules === undefined || slave.currentRules.length < 1) { slave.currentRules = []; @@ -945,7 +784,6 @@ App.Update.Slave = function(slave, genepool = false) { if (slave.areoleaPiercing !== undefined) { delete slave.areoleaPiercing; } - if (slave.pregControl === undefined) { slave.pregControl = "none"; } if (slave.pregControl === "labor supressors") { slave.pregControl = "labor suppressors"; }