diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index 518692590fea4a1fa52db859a771a4fceb4477f6..cf8dcff6e262a16fb487e59a5bcc7ecf3614c3ab 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -76,6 +76,7 @@ globalThis.DefaultRules = function(slave) { ProcessPiercings(slave, rule); ProcessSmartPiercings(slave, rule); ProcessTattoos(slave, rule); + ProcessBrands(slave, rule); ProcessPornFeedEnabled(slave, rule); ProcessPorn(slave, rule); ProcessLabel(slave, rule); @@ -2961,152 +2962,168 @@ globalThis.DefaultRules = function(slave) { } } } - if (rule.autoBrand === 1 && rule.brandDesign !== null) { - if (slave.health.condition > -20) { - const brands = App.Medicine.Modification.brandRecord(slave); - let brandPlace = ""; - let left; - let right; - - // Brand location needs to be split into a left and right - if (["ankles", "calves", "feet", "hands", "lower arms", "shoulders", "upper arms", "wrists", "cheeks", "ears", "buttocks", "breasts"].includes(rule.brandTarget)) { - if (rule.brandTarget === "ankles") { - left = "left ankle"; - right = "right ankle"; - } else if (rule.brandTarget === "calves") { - left = "left calf"; - right = "right calf"; - } else if (rule.brandTarget === "feet") { - left = "left foot"; - right = "right foot"; - } else if (rule.brandTarget === "hands") { - left = "left hand"; - right = "right hand"; - } else if (rule.brandTarget === "lower arms") { - left = "left lower arm"; - right = "right lower arm"; - } else if (rule.brandTarget === "shoulders") { - left = "left shoulder"; - right = "right shoulder"; - } else if (rule.brandTarget === "upper arms") { - left = "left upper arm"; - right = "right upper arm"; - } else if (rule.brandTarget === "wrists") { - left = "left wrist"; - right = "right wrist"; - } else if (rule.brandTarget === "cheeks") { - left = "left cheek"; - right = "right cheek"; - } else if (rule.brandTarget === "ears") { - left = "left ear"; - right = "right ear"; - } else if (rule.brandTarget === "buttocks") { - left = "left buttock"; - right = "right buttock"; - } else if (rule.brandTarget === "breasts") { - left = "left breast"; - right = "right breast"; - } - if (rule.brandDesign !== brands[left] && rule.brandDesign !== brands[right]) { - brandPlace = "both"; - } else if (rule.brandDesign !== brands[left]) { - brandPlace = "left"; - } else if (rule.brandDesign !== brands[right]) { + } + + /** + * @param {App.Entity.SlaveState} slave + * @param {FC.RA.RuleSetters} rule + */ + function ProcessBrands(slave, rule) { + if (rule.autoBrand !== 1 || slave.health.condition <= -20) { + return; + } + + if (rule.brandTarget == null) { + message(`${slave.slaveName} was scheduled for branding, but no location had been specified.`, sourceRecord.autoBrand); + return; + } + if (rule.brandDesign == null) { + message(`${slave.slaveName} was scheduled for branding, but no design had been specified.`, sourceRecord.autoBrand); + return; + } + + const brands = App.Medicine.Modification.brandRecord(slave); + let brandPlace = ""; + let left; + let right; + + // Brand location needs to be split into a left and right + if (["ankles", "calves", "feet", "hands", "lower arms", "shoulders", "upper arms", "wrists", "cheeks", "ears", "buttocks", "breasts"].includes(rule.brandTarget)) { + if (rule.brandTarget === "ankles") { + left = "left ankle"; + right = "right ankle"; + } else if (rule.brandTarget === "calves") { + left = "left calf"; + right = "right calf"; + } else if (rule.brandTarget === "feet") { + left = "left foot"; + right = "right foot"; + } else if (rule.brandTarget === "hands") { + left = "left hand"; + right = "right hand"; + } else if (rule.brandTarget === "lower arms") { + left = "left lower arm"; + right = "right lower arm"; + } else if (rule.brandTarget === "shoulders") { + left = "left shoulder"; + right = "right shoulder"; + } else if (rule.brandTarget === "upper arms") { + left = "left upper arm"; + right = "right upper arm"; + } else if (rule.brandTarget === "wrists") { + left = "left wrist"; + right = "right wrist"; + } else if (rule.brandTarget === "cheeks") { + left = "left cheek"; + right = "right cheek"; + } else if (rule.brandTarget === "ears") { + left = "left ear"; + right = "right ear"; + } else if (rule.brandTarget === "buttocks") { + left = "left buttock"; + right = "right buttock"; + } else if (rule.brandTarget === "breasts") { + left = "left breast"; + right = "right breast"; + } + if (rule.brandDesign !== brands[left] && rule.brandDesign !== brands[right]) { + brandPlace = "both"; + } else if (rule.brandDesign !== brands[left]) { + brandPlace = "left"; + } else if (rule.brandDesign !== brands[right]) { + brandPlace = "right"; + } + + // Check for amputations: + if (["upper arms", "lower arms", "wrists", "hands"].includes(rule.brandTarget)) { + // Arms + if (!hasAnyArms(slave)) { + brandPlace = ""; + } else if (!hasLeftArm(slave)) { + if (brandPlace === "both") { brandPlace = "right"; } - - // Check for amputations: - if (["upper arms", "lower arms", "wrists", "hands"].includes(rule.brandTarget)) { - // Arms - if (!hasAnyArms(slave)) { - brandPlace = ""; - } else if (!hasLeftArm(slave)) { - if (brandPlace === "both") { - brandPlace = "right"; - } - if (brandPlace === "left") { - brandPlace = ""; - } - } else if (!hasRightArm(slave)) { - if (brandPlace === "both") { - brandPlace = "left"; - } - if (brandPlace === "right") { - brandPlace = ""; - } - } - } else if (["thighs", "calves", "ankles", "feet"].includes(rule.brandTarget)) { - // Legs - if (!hasAnyLegs(slave)) { - brandPlace = ""; - } else if (!hasLeftLeg(slave)) { - if (brandPlace === "both") { - brandPlace = "right"; - } - if (brandPlace === "left") { - brandPlace = ""; - } - } else if (!hasRightLeg(slave)) { - if (brandPlace === "both") { - brandPlace = "left"; - } - if (brandPlace === "right") { - brandPlace = ""; - } - } - } else if (["ears"].includes(rule.brandTarget)) { - // Ears - if (slave.earShape === "none") { - brandPlace = ""; - } + if (brandPlace === "left") { + brandPlace = ""; } - - // Brand location does NOT need to be split into a left and right, (and may or may not contain left OR right already.) - } else if (brands[rule.brandTarget] !== rule.brandDesign) { - if ( - (!hasLeftArm(slave) && ["left upper arm", "left lower arm", "left wrist", "left hand"].includes(rule.brandTarget)) || - (!hasRightArm(slave) && ["right upper arm", "right lower arm", "right wrist", "right hand"].includes(rule.brandTarget)) || - (!hasLeftLeg(slave) && ["left thigh", "left calf", "left ankle", "left foot"].includes(rule.brandTarget)) || - (!hasRightLeg(slave) && ["right thigh", "right calf", "right ankle", "right foot"].includes(rule.brandTarget)) || - (slave.earShape === "none" && ["left ear"].includes(rule.brandTarget)) || - (slave.earShape === "none" && ["right ear"].includes(rule.brandTarget)) - ) { + } else if (!hasRightArm(slave)) { + if (brandPlace === "both") { + brandPlace = "left"; + } + if (brandPlace === "right") { brandPlace = ""; - } else { - brandPlace = "anywhere"; } } - - // Apply brands: - if (["left", "right", "anywhere"].includes(brandPlace)) { - healthDamage(slave, 10); - let m = `${slave.slaveName} has been branded on the `; + } else if (["thighs", "calves", "ankles", "feet"].includes(rule.brandTarget)) { + // Legs + if (!hasAnyLegs(slave)) { + brandPlace = ""; + } else if (!hasLeftLeg(slave)) { + if (brandPlace === "both") { + brandPlace = "right"; + } if (brandPlace === "left") { - App.Medicine.Modification.addBrand(slave, left, rule.brandDesign); - m += `${left}`; - } else if (brandPlace === "right") { - App.Medicine.Modification.addBrand(slave, right, rule.brandDesign); - m += `${right}`; - } else if (brandPlace === "anywhere") { - App.Medicine.Modification.addBrand(slave, rule.brandTarget, rule.brandDesign); - m += `${rule.brandTarget}`; - } - message(`${m}, with <span class="trust dec">fear</span>${slave.devotion < 18 ? `, <span class="devotion dec">regard,</span>` : ``} and <span class="health dec">health</span> consequences.`, sourceRecord.brandDesign); - if (slave.devotion < 18) { - slave.devotion -= 5; + brandPlace = ""; } - slave.trust -= 5; - } else if (brandPlace === "both") { - App.Medicine.Modification.addBrand(slave, left, rule.brandDesign); - App.Medicine.Modification.addBrand(slave, right, rule.brandDesign); - healthDamage(slave, 20); - message(`${slave.slaveName} has been branded on both ${rule.brandTarget}, with <span class="trust dec">fear</span>${slave.devotion < 18 ? `, <span class="devotion dec">regard,</span>` : ``} and <span class="health dec">health</span> consequences.`, sourceRecord.brandDesign); - if (slave.devotion < 18) { - slave.devotion -= 10; + } else if (!hasRightLeg(slave)) { + if (brandPlace === "both") { + brandPlace = "left"; } - slave.trust -= 10; + if (brandPlace === "right") { + brandPlace = ""; + } + } + } else if (["ears"].includes(rule.brandTarget)) { + // Ears + if (slave.earShape === "none") { + brandPlace = ""; } } + + // Brand location does NOT need to be split into a left and right, (and may or may not contain left OR right already.) + } else if (brands[rule.brandTarget] !== rule.brandDesign) { + if ( + (!hasLeftArm(slave) && ["left upper arm", "left lower arm", "left wrist", "left hand"].includes(rule.brandTarget)) || + (!hasRightArm(slave) && ["right upper arm", "right lower arm", "right wrist", "right hand"].includes(rule.brandTarget)) || + (!hasLeftLeg(slave) && ["left thigh", "left calf", "left ankle", "left foot"].includes(rule.brandTarget)) || + (!hasRightLeg(slave) && ["right thigh", "right calf", "right ankle", "right foot"].includes(rule.brandTarget)) || + (slave.earShape === "none" && ["left ear"].includes(rule.brandTarget)) || + (slave.earShape === "none" && ["right ear"].includes(rule.brandTarget)) + ) { + brandPlace = ""; + } else { + brandPlace = "anywhere"; + } + } + + // Apply brands: + if (["left", "right", "anywhere"].includes(brandPlace)) { + healthDamage(slave, 10); + let m = `${slave.slaveName} has been branded on the `; + if (brandPlace === "left") { + App.Medicine.Modification.addBrand(slave, left, rule.brandDesign); + m += `${left}`; + } else if (brandPlace === "right") { + App.Medicine.Modification.addBrand(slave, right, rule.brandDesign); + m += `${right}`; + } else if (brandPlace === "anywhere") { + App.Medicine.Modification.addBrand(slave, rule.brandTarget, rule.brandDesign); + m += `${rule.brandTarget}`; + } + message(`${m}, with <span class="trust dec">fear</span>${slave.devotion < 18 ? `, <span class="devotion dec">regard,</span>` : ``} and <span class="health dec">health</span> consequences.`, sourceRecord.brandDesign); + if (slave.devotion < 18) { + slave.devotion -= 5; + } + slave.trust -= 5; + } else if (brandPlace === "both") { + App.Medicine.Modification.addBrand(slave, left, rule.brandDesign); + App.Medicine.Modification.addBrand(slave, right, rule.brandDesign); + healthDamage(slave, 20); + message(`${slave.slaveName} has been branded on both ${rule.brandTarget}, with <span class="trust dec">fear</span>${slave.devotion < 18 ? `, <span class="devotion dec">regard,</span>` : ``} and <span class="health dec">health</span> consequences.`, sourceRecord.brandDesign); + if (slave.devotion < 18) { + slave.devotion -= 10; + } + slave.trust -= 10; } }