diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index 8e3f968606f3d99ede9830cd5a3fcfbc4db32735..69221fb103e46ded4f0277487c749bd0f3ac63ac 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -300,7 +300,7 @@ App.Update.globalVariables = function(node) { // Pit if (V.pit) { - V.pit = typeof V.pit === "object" ? V.pit : {}; + V.pit = typeof V.pit === "object" ? V.pit : null; V.pit.name = V.pit.name || V.pitName || "the Pit"; V.pit.virginities = V.pit.virginities || V.pitVirginities || "neither"; diff --git a/src/endWeek/slaveAssignmentReport.js b/src/endWeek/slaveAssignmentReport.js index 3bd571da38efff428a1c7d5e8fc0bd153c1d6878..00cf24cf47754d67bb850e3bc10872a8551d99e2 100644 --- a/src/endWeek/slaveAssignmentReport.js +++ b/src/endWeek/slaveAssignmentReport.js @@ -775,7 +775,7 @@ App.EndWeek.slaveAssignmentReport = function() { } } - if (V.pit.fighterIDs.includes(slave)) { + if (V.pit && V.pit.fighterIDs.includes(slave.ID)) { if (!canWalk(slave)) { _printSlaveUnassignedNote(slave, "is no longer independently mobile", `and cannot fight any more. ${getPronouns(slave).he} has been removed from ${App.Entity.facilities.pit.name} roster`); diff --git a/src/events/scheduled/pitFight.js b/src/events/scheduled/pitFight.js index 1423df3bc4b9c0945e43d78c996ba8889a7c25bb..3a9f93c9b401ffd621397cdc34e4d7aa23062df0 100644 --- a/src/events/scheduled/pitFight.js +++ b/src/events/scheduled/pitFight.js @@ -5,9 +5,6 @@ App.Facilities.Pit.fight = function(lethal) { fighters = [], animal = V.pit.animal, - winner = getWinner(), - loser = getLoser(), - Audience = { NONE: "none", FREE: "free", @@ -26,9 +23,11 @@ App.Facilities.Pit.fight = function(lethal) { if (V.pit.bodyguardFights) { fighters.push(S.Bodyguard.ID, V.pit.fighterIDs.pluck()); } else { - V.pit.fighterIDs.includes(S.Bodyguard.ID) ? - V.pit.fighterIDs.splice(V.pit.fighterIDs.indexOf(S.Bodyguard.ID), 1) : - null; // make sure bodyguard isn't still in the fighters list + if (S.Bodyguard) { + V.pit.fighterIDs.includes(S.Bodyguard.ID) ? + V.pit.fighterIDs.splice(V.pit.fighterIDs.indexOf(S.Bodyguard.ID), 1) : + null; // make sure bodyguard isn't still in the fighters list + } if (animal) { fighters.push(V.pit.fighterIDs.pluck()); @@ -38,6 +37,10 @@ App.Facilities.Pit.fight = function(lethal) { } } + const + winner = getWinner(), + loser = getLoser(); + App.UI.DOM.appendNewElement("div", frag, intro()); App.UI.DOM.appendNewElement("div", frag, deadliness(getSlave(fighters[0]))); App.UI.DOM.appendNewElement("div", frag, deadliness(getSlave(fighters[1]))); @@ -169,7 +172,7 @@ App.Facilities.Pit.fight = function(lethal) { r.push( confidence(), - willingness(true), + lethal ? willingness(true) : ``, skill(), muscles(), height(), @@ -182,7 +185,7 @@ App.Facilities.Pit.fight = function(lethal) { sight(), hearing(), prosthetics(), - willingness(false), + lethal ? `` : willingness(false), ); mainDiv.append(r.join(' ')); @@ -205,8 +208,8 @@ App.Facilities.Pit.fight = function(lethal) { } } - function willingness(lethal) { - if (lethal) { + function willingness(_lethal) { + if (_lethal) { if (fighter.fetish === "mindbroken") { return `${he} is indifferent to the prospect of killing, as well.`; } else if (fighter.devotion > 95) { @@ -700,7 +703,7 @@ App.Facilities.Pit.fight = function(lethal) { cashX(2000, "pit", winner); } } else if (!canSee(winner)) { - mainDiv.append(`${winner.slaveName} centers ${himself} and hones in on ${loser.slaveName}'s rapid breath. ${He} readies ${himself}, knowing ${he} has a single chance to win. With heavy steps, ${loser.slaveName} rushes ${him}, fully prepared to tackle the helpless combatant. ${winner.slaveName} gambles everything on a single high punch, a strike that slams ${loser.slaveName}'s undefended neck. ${loser.slaveName} falls to the ground before the panicking ${winner.slaveName}, who quickly pins the coughing loser.`); + mainDiv.append(`${winner.slaveName} centers ${himself} and hones in on ${loser.slaveName}'s rapid breath. ${He} readies ${himself}, knowing ${he} has a single chance to win. With heavy steps, ${loser.slaveName} rushes ${him}, fully prepared to tackle the helpless combatant. ${winner.slaveName} gambles everything on a single high punch, a strike that slams ${loser.slaveName}'s undefended neck. ${loser.slaveName} falls to the ground before the panicking ${winner.slaveName}, who quickly pins the coughing loser. `); healthDamage(winner, 80); @@ -918,7 +921,7 @@ App.Facilities.Pit.fight = function(lethal) { cashX(500, "pit", winner); } } else { - mainDiv.append(`${winner.slaveName} wants to win badly enough that ${he} takes an extremely unpleasant shortcut to victory. The instant the fight starts, ${he} furiously goes for ${loser.slaveName}'s eyes, hands forming claws. ${loser.slaveName} defends ${himself2} with ${his2} arms, at which point ${winner.slaveName} delivers a clenched fist to ${loser.slaveName}'s throat. ${loser.slaveName} staggers back, wheezing for breath with tears leaking from ${his2} closed eyes. ${winner.slaveName} takes advantage of ${loser.slaveName}'s vulnerability to quickly trip and pin the coughing loser.`); + mainDiv.append(`${winner.slaveName} wants to win badly enough that ${he} takes an extremely unpleasant shortcut to victory. The instant the fight starts, ${he} furiously goes for ${loser.slaveName}'s eyes, hands forming claws. ${loser.slaveName} defends ${himself2} with ${his2} arms, at which point ${winner.slaveName} delivers a clenched fist to ${loser.slaveName}'s throat. ${loser.slaveName} staggers back, wheezing for breath with tears leaking from ${his2} closed eyes. ${winner.slaveName} takes advantage of ${loser.slaveName}'s vulnerability to quickly trip and pin the coughing loser. `); if (V.pit.audience === Audience.FREE) { const repSpan = App.UI.DOM.makeElement("span", `not very impressed`, ["reputation", "inc"]); @@ -1676,7 +1679,7 @@ App.Facilities.Pit.fight = function(lethal) { devotionSpan.classList.add("devotion", "dec"); devotionSpan.append(`embarrassed`); - mainDiv.append(`${He2} is `, devotionSpan, ` by losing to and being raped by ${winner.slaveName}, whom ${he2} dislikes, and `, trustSpan, ` that it will happen again.`); + mainDiv.append(`${He2} is `, devotionSpan, ` by losing to and being raped by ${winner.slaveName}, whom ${he2} dislikes, and `, trustSpan, ` that it will happen again. `); loser.devotion -= 10; loser.trust -= 10; diff --git a/src/facilities/pit/killSlave.js b/src/facilities/pit/killSlave.js index a775bb978dec83355c010f0b1df7ae7851ced98e..8ee1b04bfdb0f537b80eef7e734c7842a45bf3d3 100644 --- a/src/facilities/pit/killSlave.js +++ b/src/facilities/pit/killSlave.js @@ -41,7 +41,7 @@ App.Facilities.Pit.killSlave = function(slave) { frag.appendChild(intro()); - if (V.pit.slaveFightingBodyguard) { + if (V.pit && V.pit.slaveFightingBodyguard) { frag.appendChild(plannedFight()); } else { frag.appendChild(links()); @@ -225,8 +225,8 @@ App.Facilities.Pit.killSlave = function(slave) { mainDiv.append(`You change your mind, and with a wave of your hand, send ${slave.slaveName} back to $his duties. Maybe some other time.`); } - slave.devotion = slave.devotion < 30 ? 30 : slave.devotion += 30; - slave.trust -= 100; + getSlave(slave.ID).devotion = slave.devotion < 30 ? 30 : slave.devotion += 30; + getSlave(slave.ID).trust -= 100; return mainDiv; } diff --git a/src/js/assignJS.js b/src/js/assignJS.js index 6a5712d8feeb5b26bb2974fd8ba345ce169736d4..bd3bd331b856639273ad8ea45f91951c883e543f 100644 --- a/src/js/assignJS.js +++ b/src/js/assignJS.js @@ -390,7 +390,7 @@ globalThis.assignJob = function(slave, job) { if (V.dojo > 1) { slave.rules.living = LivingRule.LUXURIOUS; } - if (V.pit.bodyguardFights && V.pit.fighterIDs.includes(slave.ID)) { V.pit.fighterIDs.delete(slave.ID); } + if (V.pit && V.pit.bodyguardFights && V.pit.fighterIDs.includes(slave.ID)) { V.pit.fighterIDs.delete(slave.ID); } break; case Job.AGENT.toLowerCase(): diff --git a/src/js/removeSlave.js b/src/js/removeSlave.js index d99856d2fe16dc2b1b649a810d96606d1f8efcd3..6d1d188b57a548ab5379ea7795156e405e471ee8 100644 --- a/src/js/removeSlave.js +++ b/src/js/removeSlave.js @@ -4,8 +4,6 @@ */ globalThis.removeSlave = function(slave) { - "use strict"; - const AS_ID = slave.ID; let LENGTH = V.slaves.length; const INDEX = V.slaveIndices[AS_ID]; @@ -107,7 +105,7 @@ globalThis.removeSlave = function(slave) { }); /* remove from Pit fighters list, if needed */ - if (V.pit.fighterIDs) { + if (V.pit && V.pit.fighterIDs) { V.pit.fighterIDs.delete(AS_ID); } diff --git a/src/uncategorized/scheduledEvent.tw b/src/uncategorized/scheduledEvent.tw index a1a693ef51580eacbc092384d751c93da0a22eec..f02b8c77d1005f1ffa512c64de45782ff6bcacae 100644 --- a/src/uncategorized/scheduledEvent.tw +++ b/src/uncategorized/scheduledEvent.tw @@ -131,8 +131,10 @@ <<goto "SE coursing">> <<elseif $policies.raidingMercenaries == 1 && ($week > ($raided + 6))>> <<goto "SE raiding">> -<<elseif ($pit.fighterIDs.length > 1 && !$pit.bodyguardFights) || ($pit.fighterIDs.length > 0 && ($BodyguardID !== 0 && $pit.bodyguardFights || $pit.animalFights)) || $pit.slaveFightingBodyguard || !$pit.fought>> - <<if $pit.lethal == true>><<goto "SE lethal pit">><<else>><<goto "SE nonlethal pit">><</if>> +<<elseif $pit>> + <<if ($pit.fighterIDs.length > 1 && !$pit.bodyguardFights) || ($pit.fighterIDs.length > 0 && ($BodyguardID !== 0 && $pit.bodyguardFights || $pit.animalFights)) || $pit.slaveFightingBodyguard || !$pit.fought>> + <<if $pit.lethal>><<goto "SE lethal pit">><<else>><<goto "SE nonlethal pit">><</if>> + <</if>> <<elseif ($bioreactorPerfectedID != 0) && ($bioreactorsAnnounced != 1)>> <<goto "P bioreactor perfected">> <<elseif ($TSS.schoolPresent == 1) && ($TSS.schoolProsperity <= -10)>>