diff --git a/src/events/scheduled/pitFightLethal.js b/src/events/scheduled/pitFightLethal.js index 5674030d06ca5bf51de0b89b2813b61be4f8fe7d..ec584caf02e26a8d284042b727b2498f595d4d56 100644 --- a/src/events/scheduled/pitFightLethal.js +++ b/src/events/scheduled/pitFightLethal.js @@ -19,22 +19,23 @@ App.Facilities.Pit.lethalFight = function(fighters) { console.log(winner, loser); } - frag.append( - intro(), - fighterDeadliness(getSlave(fighters[0])), - !V.pit.animal ? fighterDeadliness(getSlave(fighters[1])) : '', - fight(), - postFight(), - ); + intro(frag); + fighterDeadliness(frag, getSlave(fighters[0])); + if (!V.pit.animal) { + fighterDeadliness(frag, getSlave(fighters[1])); + } + fight(frag); + postFight(frag); V.pit.slaveFightingBodyguard = null; return frag; - function intro() { - const introDiv = document.createElement("div"); - + /** + * @param {DocumentFragment} parent + */ + function intro(parent) { const fighterOne = getSlave(fighters[0]); const fighterTwo = getSlave(fighters[1]) || null; @@ -44,13 +45,15 @@ App.Facilities.Pit.lethalFight = function(fighters) { const r = []; - introDiv.classList.add("pit-section"); - - App.Events.drawEventArt(introDiv, fighters.map(id => getSlave(id)), "no clothing"); + App.Events.drawEventArt(parent, fighters.map(id => getSlave(id)), "no clothing"); const anAnimal = animal ? `${animal.articleAn} ${animal.name}.` : null; - r.push(`This week's fight is between`, App.UI.DOM.slaveDescriptionDialog(fighterOne), `and`, animal ? anAnimal : App.UI.DOM.combineNodes(contextualIntro(fighterOne, fighterTwo, "DOM"), ".")); + r.push(`This week's fight is between`, + App.UI.DOM.slaveDescriptionDialog(fighterOne), `and`, + animal + ? anAnimal + : App.UI.DOM.combineNodes(contextualIntro(fighterOne, fighterTwo, "DOM"), ".")); if (V.pit.audience === "none") { r.push(`You are alone above the pit, left to watch them kill and die in private.`); @@ -78,25 +81,22 @@ App.Facilities.Pit.lethalFight = function(fighters) { r.push(`You review the rules — the slave will use ${his} choice of swords, and the fight will be to the death. If ${he} wins, ${he} will earn two complete days of rest, not to mention continued life. You take a moment to look over ${fighterOne.slaveName} one more time before giving the word. After all, it might be the last time you'll see ${him} alive.`); } else { - r.push(`You review the rules — the combatants will use their choice of swords, and the fight will be to the death, with both fighters executed if no decision is reached. The winner will earn two complete days of rest, not to mention continued life. You take a moment to look over your fighters one more time before giving the word. After all, this is likely the last time you'll see one of them alive.`); + r.push(`You review the rules — the combatants will use their choice of swords, and the fight will be to the death, with both fighters executed if no decision is reached. The winner will earn two complete days of rest, not to mention continued life. You take a moment to look over your fighters one more time before giving the word. After all, this is likely the last time you'll see one of them alive.`); } - App.Events.addNode(introDiv, r); - - return introDiv; + App.Events.addParagraph(parent, r); } - /** @param {App.Entity.SlaveState} fighter */ - function fighterDeadliness(fighter) { - const deadlinessDiv = document.createElement("div"); - + /** + * @param {DocumentFragment} parent + * @param {App.Entity.SlaveState} fighter + */ + function fighterDeadliness(parent, fighter) { const {he, his, him, himself, He, His} = getPronouns(fighter); const fighterDeadliness = deadliness(fighter); const r = []; - deadlinessDiv.classList.add("pit-section"); - r.push( confidence(), willingness(), @@ -115,10 +115,7 @@ App.Facilities.Pit.lethalFight = function(fighters) { prosthetics(), ); - App.Events.addNode(deadlinessDiv, r); - - return deadlinessDiv; - + App.Events.addParagraph(parent, r); function confidence() { if (fighter.fetish === "mindbroken") { @@ -321,9 +318,10 @@ App.Facilities.Pit.lethalFight = function(fighters) { } } - function fight() { - const fightDiv = App.UI.DOM.makeElement('div', ``, ["pit-section"]); - + /** + * @param {DocumentFragment} parent + */ + function fight(parent) { const r = []; r.push(`In any case, ${animal ? `the slave and the ${animal.name} have both` : `both of the slaves`} been dosed with aggression enhancers and inhibition blockers; they'll fight to kill.`); @@ -347,7 +345,7 @@ App.Facilities.Pit.lethalFight = function(fighters) { repX(1000, "pit", winner); } } else if (winner.muscles) { - r.push(`${winner.slaveName} is so massively muscular that ${he}'s actually impeded by ${his} lack of speed and flexibility. The ${animal.species} is suitably cautious, and it does its best to avoid ${his} sword. The two go back and forth for a while – the slave slashing and swinging, the animal leaping out of the way. ${winner.slaveName} finally manages to get the better of the ${animal.species}, though, and manages to catch the tip of ${his} sword on the animal's leg. With a loud ${animal.type === 'canine' ? `yelp`: animal.type === 'hooved' ? `whinny` : `howl`}, the ${animal.species} stumbles back, giving the slave a chance to bring ${his} sword down in an overhead swing, nearly removing the ${animal.species}'s head.`); + r.push(`${winner.slaveName} is so massively muscular that ${he}'s actually impeded by ${his} lack of speed and flexibility. The ${animal.species} is suitably cautious, and it does its best to avoid ${his} sword. The two go back and forth for a while – the slave slashing and swinging, the animal leaping out of the way. ${winner.slaveName} finally manages to get the better of the ${animal.species}, though, and manages to catch the tip of ${his} sword on the animal's leg. With a loud ${animal.type === 'canine' ? `yelp` : animal.type === 'hooved' ? `whinny` : `howl`}, the ${animal.species} stumbles back, giving the slave a chance to bring ${his} sword down in an overhead swing, nearly removing the ${animal.species}'s head.`); if (V.pit.audience === 'paid') { r.push(`The audience is awestruck by the blind ${girl}'s triumph, and your`, App.UI.DOM.makeElement('span', `cut of the betting`, ["cash", "inc"]), ` is enormous.`); @@ -661,13 +659,13 @@ App.Facilities.Pit.lethalFight = function(fighters) { } } - App.Events.addNode(fightDiv, r); - - return fightDiv; + App.Events.addParagraph(parent, r); } - function postFight() { - const postFightDiv = document.createElement("div"); + /** + * @param {DocumentFragment} parent + */ + function postFight(parent) { const mindbrokenSpan = App.UI.DOM.makeElement("span", `no longer capable`, "red"); const experienceSpan = App.UI.DOM.makeElement("span", `learned basic combat skills.`, ["improvement"]); @@ -813,9 +811,7 @@ App.Facilities.Pit.lethalFight = function(fighters) { removeSlave(loser); } - App.Events.addNode(postFightDiv, r); - - return postFightDiv; + App.Events.addParagraph(parent, r); } diff --git a/src/events/scheduled/pitFightNonlethal.js b/src/events/scheduled/pitFightNonlethal.js index 7818d1d4784787579b04cdd10f91bbe33a373e5b..ade9a1abc3a04ca64252bd4c64a2b436c6b3b6ea 100644 --- a/src/events/scheduled/pitFightNonlethal.js +++ b/src/events/scheduled/pitFightNonlethal.js @@ -22,21 +22,24 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { console.log(winner, loser); } - frag.append( - intro(), - fighterDeadliness(getSlave(fighters[0])), - !V.pit.animal ? fighterDeadliness(getSlave(fighters[1])) : '', - fight(), - postFight(), - ); + intro(frag); + fighterDeadliness(frag, getSlave(fighters[0])); + if (!V.pit.animal) { + fighterDeadliness(frag, getSlave(fighters[1])); + } + fight(frag); + postFight(frag); return frag; - // TODO: update to use "run" if animal - function intro() { - const introDiv = document.createElement("div"); - + // + /** + * TODO: update to use "run" if animal + * + * @param {DocumentFragment} parent + */ + function intro(parent) { const fighterOne = getSlave(fighters[0]); const fighterTwo = getSlave(fighters[1]) || null; @@ -46,16 +49,15 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { const r = []; - introDiv.classList.add("pit-section"); - - App.Events.drawEventArt(introDiv, fighters.map(id => getSlave(id)), "no clothing"); + App.Events.drawEventArt(frag, fighters.map(id => getSlave(id)), "no clothing"); const anAnimal = animal ? `${animal.articleAn} ${animal.name}` : null; if (animal) { r.push(`This week ${anAnimal} is going to try to use ${fighterOne.slaveName}.`); } else { - r.push(`This week's fight is between`, App.UI.DOM.slaveDescriptionDialog(fighterOne), `and`, App.UI.DOM.combineNodes(contextualIntro(fighterOne, fighterTwo, "DOM"), ".")); + r.push(`This week's fight is between`, App.UI.DOM.slaveDescriptionDialog(fighterOne), `and`, + App.UI.DOM.combineNodes(contextualIntro(fighterOne, fighterTwo, "DOM"), ".")); } if (animal) { @@ -115,22 +117,19 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { r.push(`and earn two complete days of rest. You take a moment to look over your fighters before giving the word.`); } - App.Events.addNode(introDiv, r); - - return introDiv; + App.Events.addParagraph(parent, r); } - /** @param {App.Entity.SlaveState} fighter */ - function fighterDeadliness(fighter) { - const deadlinessDiv = document.createElement("div"); - + /** + * @param {DocumentFragment} parent + * @param {App.Entity.SlaveState} fighter + */ + function fighterDeadliness(parent, fighter) { const {he, his, him, himself, He, His} = getPronouns(fighter); const fighterDeadliness = deadliness(fighter); const r = []; - deadlinessDiv.classList.add("pit-section"); - r.push( confidence(), skill(), @@ -149,10 +148,7 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { willingness(), ); - App.Events.addNode(deadlinessDiv, r); - - return deadlinessDiv; - + App.Events.addParagraph(parent, r); function confidence() { if (fighter.fetish === "mindbroken") { @@ -345,9 +341,10 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { } } - function fight() { - const fightDiv = App.UI.DOM.makeElement("span", null, ["pit-section"]); - + /** + * @param {DocumentFragment} parent + */ + function fight(parent) { const r = []; if (animal) { @@ -397,7 +394,15 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { const loserDeadliness = deadliness(loser); const {he, his, him, himself, girl, He} = getPronouns(winner); - const {he: he2, his: his2, him: him2, himself: himself2, girl: girl2, He: He2, His: His2} = getPronouns(loser); + const { + he: he2, + his: his2, + him: him2, + himself: himself2, + girl: girl2, + He: He2, + His: His2 + } = getPronouns(loser); if (!canSee(winner) && !canSee(loser)) { r.push(`${winner.slaveName} and ${loser.slaveName} are both blind, making the fight a staredown. Neither slave wants to make the first move, especially with the drowning cacophony coming from the jeering crowd. Slowly, ${winner.slaveName} moves forward, waving feeling for ${his} opponent before ${he} ${himself} gets found. ${loser.slaveName}'s hand meets ${winner.slaveName}'s and the two move to grab each other in a headlock. The two slaves violently thrash against each other, suffering more and more strikes as the struggle goes on. Eventually, ${loser.slaveName} can take no more and releases ${his2} grip on ${winner.slaveName} neck. It takes a moment for ${winner.slaveName} to stop wrestling the submitting ${loser.slaveName} and accept ${his} victory.`); @@ -543,7 +548,7 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { r.push(`The fight starts slowly, with the two trading jabs. Just as the spectators are getting bored, ${loser.slaveName} takes a glancing blow to the eyebrow. ${His2} piercing catches on ${winner.slaveName}'s glove and tears out. ${loser.slaveName} goes after ${his2} tormentor in fury, streaming blood, the piercing forgotten on the mat. Any tendency ${winner.slaveName} might have had to feel badly about this is extinguished by the assault, and soon ${winner.slaveName} is even willing to follow up on the success by targeting pierced body parts. The fight ends with poor ${loser.slaveName} writhing in pain on the mat, `, App.UI.DOM.makeElement("span", `leaking blood,`, ["health", "dec"]), ` from several terribly shredded areas.`); if (V.pit.audience === "free") { - r.push(`The audience is `, App.UI.DOM.makeElement("span", `reasonably impressed`, ["reputation", "dec"]), ` by the gory spectacle.`); + r.push(`The audience is `, App.UI.DOM.makeElement("span", `reasonably impressed`, ["reputation", "inc"]), ` by the gory spectacle.`); repX(50, "pit", winner); } else if (V.pit.audience === "paid") { @@ -632,16 +637,14 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { } } - - App.Events.addNode(fightDiv, r); - - return fightDiv; + App.Events.addParagraph(parent, r); } - function postFight() { - const postFightDiv = document.createElement("div"); - - const r = []; + /** + * @param {DocumentFragment} parent + */ + function postFight(parent) { + let r = []; const anus = "anus"; const cunt = "cunt"; @@ -979,8 +982,11 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { } } - r.push(rape(), rapeEffects()); + App.Events.addParagraph(parent, r); + + App.Events.addParagraph(parent, [...rape(), ...rapeEffects()]); + r = []; if (winner.skill.combat === 0 && random(1, 100) < (20 + winner.devotion)) { const experienceSpan = App.UI.DOM.makeElement("span", `learned basic combat skills.`, ["improvement"]); @@ -997,12 +1003,9 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { V.pitFightsTotal++; - App.Events.addNode(postFightDiv, r); - - return postFightDiv; + App.Events.addParagraph(parent, r); function rape() { - const rapeDiv = document.createElement("div"); const repSpan = App.UI.DOM.makeElement("span", ``, ["reputation", "inc"]); const r = []; @@ -1084,32 +1087,24 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { winner.devotion -= 2; } - App.Events.addNode(rapeDiv, r); - - return rapeDiv; + return r; } function rapeEffects() { - const rapeEffectsDiv = document.createElement("div"); - const r = []; const {he, his, him, himself, He} = getPronouns(winner); const {he: he2, him: him2, He: He2} = getPronouns(loser); - r.push(winnerEffects(), loserEffects()); + r.push(...winnerEffects(), ...loserEffects()); if (loser.fetish !== "masochist" && loser.fetish !== "humiliation" && loser.sexualFlaw !== "self hating" && loser.relationship && loser.relationship < 5 && winner.ID === loser.relationshipTarget) { r.push(`Fighting and rape have `, App.UI.DOM.makeElement("span", `damaged`, ["relationship", "dec"]), ` the relationship between the slaves.`); } - App.Events.addNode(rapeEffectsDiv, r); - - return rapeEffectsDiv; + return r; function winnerEffects() { - const winnerEffectsDiv = document.createElement("div"); - const r = []; if (winner.rivalry && loser.ID === winner.rivalryTarget) { @@ -1152,13 +1147,10 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { winner.behavioralFlaw = "odd"; } - App.Events.addNode(winnerEffectsDiv, r); - - return winnerEffectsDiv; + return r; } function loserEffects() { - const loserEffectsDiv = document.createElement("div"); const trustSpan = App.UI.DOM.makeElement("span", `fears`, ["trust", "dec"]); const r = []; @@ -1219,9 +1211,7 @@ App.Facilities.Pit.nonlethalFight = function(fighters) { loser.behavioralFlaw = "odd"; } - App.Events.addNode(loserEffectsDiv, r); - - return loserEffectsDiv; + return r; } } } diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index a8440b431b9a41ccae01d7d162f0424da78235af..f8effd42e6c49e2081729bfb63195edbc0f3ec53 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -33,13 +33,17 @@ globalThis.DefaultRules = (function() { * @returns {string} */ function DefaultRules(slave) { - if (slave.useRulesAssistant === 0) { return r; } // exempted + if (slave.useRulesAssistant === 0) { + return r; + } // exempted r = ""; ({he, him, his} = pronouns = getPronouns(slave)); const slaveReadOnly = createReadonlyProxy(slave); const {rule, ruleIds} = runWithReadonlyProxy(() => ProcessSlaveRules(slaveReadOnly)); slave.currentRules = ruleIds; - if (ruleIds.length === 0) { return r; } // no rules apply + if (ruleIds.length === 0) { + return r; + } // no rules apply AssignJobToSlave(slave, rule); if (slave.fuckdoll === 0) { @@ -1196,7 +1200,7 @@ globalThis.DefaultRules = (function() { } /** @typedef {"lips" | "boobs" | "butt" | "dick" | "balls"} DrugTarget */ - // Asset Growth + // Asset Growth const growthDrugs = new Set(["breast injections", "breast redistributors", "butt injections", "butt redistributors", "hyper breast injections", "hyper butt injections", "hyper penis enhancement", "hyper testicle enhancement", "intensive breast injections", "intensive butt injections", "intensive penis enhancement", "intensive testicle enhancement", "lip atrophiers", "lip injections", "penis atrophiers", "penis enhancement", "testicle atrophiers", "testicle enhancement"]); // WARNING: property names in fleshFunc, growDrugs, and shrinkDrugs must be identical and this fact is used by the drugs() below @@ -1584,13 +1588,15 @@ globalThis.DefaultRules = (function() { if (rule.pitRules !== undefined && rule.pitRules !== null) { if (V.pit) { if (rule.pitRules === 0) { - removeJob(slave, Job.PIT, true); - r += `<br>${slave.slaveName} has been removed from the pit.`; + if (App.Entity.facilities.pit.isHosted(slave)) { + removeJob(slave, Job.PIT, true); + r += `<br>${slave.slaveName} has been removed from the pit.`; + } } else { if (App.Entity.facilities.pit.job().checkRequirements(slave).length !== 0) { removeJob(slave, Job.PIT, true); r += `<br>${slave.slaveName} is not eligible to fight.`; - } else { + } else if (!App.Entity.facilities.pit.isHosted(slave)) { assignJob(slave, Job.PIT); r += `<br>${slave.slaveName} has been automatically assigned to fight in the pit.`; } @@ -2985,7 +2991,7 @@ globalThis.DefaultRules = (function() { } } - // Brand location does NOT need to be split into a left and right, (and may or may not contain left OR right already.) + // 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 (slave.brand[rule.brandTarget] !== rule.brandDesign) { if ( (!hasLeftArm(slave) && ["left upper arm", "left lower arm", "left wrist", "left hand"].includes(rule.brandTarget)) || @@ -3113,7 +3119,7 @@ globalThis.DefaultRules = (function() { } function ProcessOther(slave, rule) { - if (typeof(rule.pronoun) === "number" && isFinite(rule.pronoun) && slave.pronoun !== rule.pronoun) { + if (typeof (rule.pronoun) === "number" && isFinite(rule.pronoun) && slave.pronoun !== rule.pronoun) { slave.pronoun = rule.pronoun; } }