From bcdd199385122795eaf1635679b93b09fe876eba Mon Sep 17 00:00:00 2001 From: DCoded <dicoded@email.com> Date: Sun, 27 Jun 2021 13:36:31 -0400 Subject: [PATCH] pFoodCrisis to JS --- js/003-data/gameVariableData.js | 1 + src/events/nonRandom/pFoodCrisis.js | 153 ++++++++++++++++++++ src/events/nonRandomEvent.js | 10 +- src/facilities/farmyard/food/pFoodCrisis.tw | 125 ---------------- 4 files changed, 155 insertions(+), 134 deletions(-) create mode 100644 src/events/nonRandom/pFoodCrisis.js delete mode 100644 src/facilities/farmyard/food/pFoodCrisis.tw diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index e21857e5e33..b4f8c54c422 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -806,6 +806,7 @@ App.Data.resetOnNGPlus = { propOutcome: 0, EliteSires: [], raped: -1, + foodCrisis: -1, missingParentID: -10000, /* animalParts: 0,*/ pregSpeedControl: 0, diff --git a/src/events/nonRandom/pFoodCrisis.js b/src/events/nonRandom/pFoodCrisis.js new file mode 100644 index 00000000000..c9c3c17e052 --- /dev/null +++ b/src/events/nonRandom/pFoodCrisis.js @@ -0,0 +1,153 @@ +App.Events.pFoodCrisis = class pFoodCrisis extends App.Events.BaseEvent { + constructor(actors, params) { + super(actors, params); + } + + eventPrerequisites() { + return [ + () => App.Events.effectiveWeek() > 48, + () => !!V.experimental.food, + () => V.foodCrisis !== 0, + ]; + } + + execute(node) { + let r = []; + const choices = []; + const discount = V.PC.skill.trading >= 50 && ["capitalist", "entrepreneur", "business kid"].includes(V.PC.career) || V.PC.skill.trading >= 100; + const price = discount ? 7500 : 10000; + + switch (V.foodCrisis) { + case 1: + r.push(`The region supplying much of the Free City's food had been battling a famine for quite some time now — between the deteriorating weather and the war raging on — but it had always seemed the situation was improving, and your arcology's citizens never really had to worry about going to bed hungry. Unfortunately, that all changed this week. A firefight had broken out near one of the region's largest farms, and one of the main reserves of food was caught in the crossfire.`); + App.Events.addParagraph(node, r); + r = []; + r.push(`Supplies steadily began to dwindle, and it wasn't long before the prices of food began to rise as a result. ${V.arcologyUpgrade.hydro ? `Even the hydroponics system you had installed earlier could barely put a dent in the needs of your citizens.` : ``} Now, the poorest in your arcology are facing starvation. Seeing no other choice, they turned to you to provide them with sustenance. <span class="bold">This is a unique opportunity.</span> It's unlikely your citizens would ask for your help again, should you choose not to help them.`); + App.Events.addParagraph(node, r); + + choices.push(new App.Events.Result(`Provide them with ample rations`, ample, `This will cost ${cashFormat(price * 2.5)} and ${discount ? `some upkeep, <span class="skill player">reduced by your knowledge of trading</span>` : `will incur significant upkeep costs`}`)); + choices.push(new App.Events.Result(`Give them enough to survive on`, enough, `This will cost ${cashFormat(price)} and ${discount ? `some upkeep, <span class="skill player">reduced by your knowledge of trading</span>` : `will incur significant upkeep costs`}`)); + choices.push(new App.Events.Result(`They can figure their problem out on their own`, refuse)); + + App.Events.addResponses(node, choices); + + break; + case 2: + r.push(`It's been a few weeks since your citizens had approached you asking for aid, and since then, the situation hasn't improved. In fact, it had gotten worse, and food prices have reached a record high. The tension in ${V.arcologies[0].name} is palpable, and small riots have broken out more than once over disputes about food. You are not surprised, then, when you receive a visit from some more of your citizens – not the poor, but not wealthy either. They state that they noticed that you have been giving out rations to the poorer citizens, and, now that the situation has become dire, were wondering if you would be willing to do the same for them.`); + App.Events.addParagraph(node, r); + + choices.push(new App.Events.Result(`Give them generous rations as well`, ample, `This will cost ${cashFormat(price * 2)} and ${discount ? `some upkeep, <span class="skill player">reduced by your knowledge of trading</span>` : `will incur significant upkeep costs`}`)); + choices.push(new App.Events.Result(`Give them enough to survive on`, enough, `This will cost ${cashFormat(price)} and ${discount ? `some upkeep, <span class="skill player">reduced by your knowledge of trading</span>` : `will incur significant upkeep costs`}`)); + choices.push(new App.Events.Result(`Change your mind about giving out any rations at all`, refuse)); + + App.Events.addResponses(node, choices); + + break; + case 3: + r.push(`Another few weeks has passed since your last meeting with your citizens regarding rationing, and things have only deteriorated further since then. It was only a matter of time, then, before the wealthier citizens of ${V.arcologies[0].name} paid you a visit one afternoon. While being able to afford food wasn't exactly difficult for them as of yet, they could read the writing on the wall, and knew it would only be a matter of time before the prices of food were so high that even they would be forced to beg for handouts.`); + App.Events.addParagraph(node, r); + r = []; + r.push(`Seeing the progress you had made since taking control of the arcology, they decided their best course of action was to come to you with a proposition. They would allow you to take full control of the food supply in ${V.arcologies[0].name}, and in return you would keep them well-fed. ''This is a unique opportunity.'' If you turn their offer down, the citizens of your arcology will find another way of surviving.`); + App.Events.addParagraph(node, r); + + choices.push(new App.Events.Result(`Set up a food market`, ample, `This will cost an initial investment of ${cashFormat(price * 15)}${discount ? `, <span class="skill player">reduced by your knowledge of trading</span>` : ``}`)); + choices.push(new App.Events.Result(`Politely decline their offer, but continue giving them rations`, enough, `This will cost ${cashFormat(price)} and ${discount ? `some upkeep, <span class="skill player">reduced by your knowledge of trading</span>` : `will incur significant upkeep costs`}`)); + choices.push(new App.Events.Result(`Turn down their offer and end rationing completely`, refuse)); + + App.Events.addResponses(node, choices); + + break; + } + + function ample() { + const el = new DocumentFragment(); + + switch (V.foodCrisis) { + case 1: + App.Events.addParagraph(el, [`You have enough to go around, so you decide to help the desperate citizens. You have a number of rationing stations set up throughout ${V.arcologies[0].name} and announce that each citizen is entitled to four full meals a day, more than enough to sate the hunger of even the most famished of men. Your citizens are <span class="reputation inc">thrilled</span> to hear that their leader is looking out for them.`]); + V.rations = 2; + V.foodCrisis = 2; + cashX(forceNeg(price * 2.5), "farmyard"); + repX(5000, "event"); + + break; + case 2: + App.Events.addParagraph(el, [`You still have more than enough to go around, so you inform the leaders that you have decided you will give them large rations, enough to feed even the hungriest citizen. The leaders are <span class="reputation inc">very pleased</span> to hear that you are taking care of them as well.`]); + V.rations = 4; + V.foodCrisis = 3; + cashX(forceNeg(price * 2), "farmyard"); + repX(5000, "event"); + + break; + case 3: + App.Events.addParagraph(el, [`You know that a proposition like this wouldn't have been easy for your citizens to make, and you also know that there is no one better suited to a task like this than you. You announce that you will be setting up a market to buy, sell, and store food in, and that you'll make sure that the citizens will continue to be well-fed. Your citizens are <span class="reputation inc">glad</span> to hear that you are looking out for their best interests.`]); + V.rations = 0; + V.foodMarket = 1; + V.foodCrisis = -1; + cashX(forceNeg(price * 15), "farmyard"); + repX(5000, "event"); + + break; + } + return el; + } + + function enough() { + const el = new DocumentFragment(); + + switch (V.foodCrisis) { + case 1: + App.Events.addParagraph(el, [`You have your own problems to deal with, but that doesn't mean you don't look out for your own. You have a number of rationing stations set up throughout ${V.arcologies[0].name} and announce that each citizen is entitled to two full meals a day, just enough for your citizens not to starve. Your citizens are <span class="reputation inc">happy</span> to hear that their leader is looking out for them.`]); + V.rations = 1; + V.foodCrisis = 2; + cashX(forceNeg(price), "farmyard"); + repX(1500, "event"); + + break; + case 2: + App.Events.addParagraph(el, [`As much as you'd like to provide them with all of the food in the world, it simply is not feasible in your current situation. Therefore, you announce to the leaders that you will provide them only enough rations to live off of. The leaders understand, and are <span class="reputation inc">pleased</span> to hear that you would provide for them at all.`]); + V.rations = 3; + V.foodCrisis = 3; + cashX(forceNeg(price), "farmyard"); + repX(1500, "event"); + + break; + case 3: + App.Events.addParagraph(el, [`Things have been going fairly well for you, but not <em>that</em> well — setting up an entirely new place to buy, sell, and store food would no doubt be an expensive undertaking. You tell the citizens that while you can't spare the resources to create a new market at the moment, you will honor your past agreement and continue giving them free rations. The people initially seem a bit disappointed that you don't seem to want to expand ${V.arcologies[0].name}, but are ultimately <span class="reputation inc">glad</span> to hear that you'll continue taking care of them.`]); + V.rations = 5; + V.foodCrisis = -1; + cashX(forceNeg(price), "farmyard"); + repX(1500, "event"); + + break; + } + return el; + } + + function refuse() { + const el = new DocumentFragment(); + + switch (V.foodCrisis) { + case 1: + App.Events.addParagraph(el, [`You have your own problems to deal with, and you simply can't afford to drop everything and solve theirs at the moment. That you can't take care of your arcology's citizen <span class="reputation dec">reflects poorly on you.</span>`]); + V.foodCrisis = 0; + repX(1500, "event"); + + break; + case 2: + App.Events.addParagraph(el, [`Having given the people rations at all was a mistake, you think to yourself. You have a great number of your own problems to deal with, and providing rations to everyone that can't afford food is putting an unnecessary strain on your own situation. With this is mind, you tell the leaders that you simply can't help them at this time, and have decided that you can't help anyone with food at all. The citizens are understandably <span class="reputation dec">angry</span> that you would go back on your word.`]); + V.foodCrisis = 0; + repX(1500, "event"); + + break; + case 3: + App.Events.addParagraph(el, [`While a new place to buy, sell, and store food in ${V.arcologies[0].name} would most likely come in quite handy in the future, you ultimately decide that you simply cannot spare the resources required. In fact, giving rations at all was a costly venture, and after not having seen any sort of return-on-investment, you decide that you are unable to continue giving out rations anymore. Your citizens are <span class="reputation dec">angry</span> at the fact that you seem not to care about them at all, but that's their problem.`]); + V.foodCrisis = 0; + repX(1500, "event"); + + break; + } + return el; + } + } +}; diff --git a/src/events/nonRandomEvent.js b/src/events/nonRandomEvent.js index f52230b08e3..c0682005bfc 100644 --- a/src/events/nonRandomEvent.js +++ b/src/events/nonRandomEvent.js @@ -92,6 +92,7 @@ App.Events.getNonrandomEvents = function() { new App.Events.MurderAttemptFollowup(), new App.Events.pRaped(), new App.Events.pAbducted(), + new App.Events.pFoodCrisis(), ]; }; @@ -252,17 +253,8 @@ globalThis.nonRandomEvent = function() { } else { setTimeout(() => Engine.play("Nonrandom Event"), Engine.minDomActionDelay); } - } else if (effectiveWeek === 48 && V.experimental.food === 1) { - V.foodCrisis = 1; - setTimeout(() => Engine.play("P food crisis"), Engine.minDomActionDelay); - } else if (effectiveWeek === 50 && V.rations > 0) { - V.foodCrisis = 2; - setTimeout(() => Engine.play("P food crisis"), Engine.minDomActionDelay); } else if (effectiveWeek === 54 && (V.peacekeepers) && V.peacekeepers.attitude >= 0) { setTimeout(() => Engine.play("P peacekeepers deficit"), Engine.minDomActionDelay); - } else if (effectiveWeek === 60 && V.rations > 0) { - V.foodCrisis = 3; - setTimeout(() => Engine.play("P food crisis"), Engine.minDomActionDelay); } else if (V.SF.Toggle && V.SF.Active === -1 && effectiveWeek >= 72) { setTimeout(() => Engine.play("Security Force Proposal"), Engine.minDomActionDelay); } else if (V.arcologies[0].FSRestart !== "unset" && V.failedElite > 300 && V.eugenicsFullControl !== 1) { diff --git a/src/facilities/farmyard/food/pFoodCrisis.tw b/src/facilities/farmyard/food/pFoodCrisis.tw deleted file mode 100644 index 1e34af8d9ea..00000000000 --- a/src/facilities/farmyard/food/pFoodCrisis.tw +++ /dev/null @@ -1,125 +0,0 @@ -:: P food crisis [nobr] - -/* feel free to move this into a different folder */ - -<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">> - -<<if ($PC.skill.trading >= 100) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>> - <<set _price = 2500>> -<<elseif ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>> - <<set _price = 5000>> -<<else>> - <<set _price = 10000>> -<</if>> - -<<switch $foodCrisis>> -<<case 1>> - - The region supplying much of the Free City's food had been battling a famine for quite some time now — between the deteriorating weather and the war raging on — but it had always seemed the situation was improving, and your arcology's citizens never really had to worry about going to bed hungry. Unfortunately, that all changed this week. A firefight had broken out near one of the region's largest farms, and one of the main reserves of food was caught in the crossfire. - - <br><br> - - Supplies steadily began to dwindle, and it wasn't long before the prices of food began to rise as a result. <<if $arcologyUpgrade.hydro == 1>>Even the hydroponics system you had installed earlier could barely put a dent in the needs of your citizens.<</if>> Now, the poorest in your arcology are facing starvation. Seeing no other choice, they turned to you to provide them with sustenance. ''This is a unique opportunity.'' It's unlikely your citizens would ask for your help again, should you choose not to help them. - - <br><br> - - <span id="result"> - <<link "Provide them with ample rations">> - <<replace "#result">> - You have enough to go around, so you decide to help the desperate citizens. You have a number of rationing stations set up throughout $arcologies[0].name and announce that each citizen is entitled to four full meals a day, more than enough to sate the hunger of even the most famished of men. Your citizens are @@.green;thrilled@@ to hear that their leader is looking out for them. - <<run repX(5000, "event")>> - <<set cashX(forceNeg(_price*2), "farmyard")>> - <<set $rations = 2>> - <</replace>> - <</link>> - <<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>>//This will cost <<print cashFormat(_price*2)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price*2)>> and incur significant upkeep costs//<</if>> - <br><<link "Give them enough to survive on">> - <<replace "#result">> - You have your own problems to deal with, but that doesn't mean you don't look out for your own. You have a number of rationing stations set up throughout $arcologies[0].name and announce that each citizen is entitled to two full meals a day, just enough for your citizens not to starve. Your citizens are @@.green;happy@@ to hear that their leader is looking out for them. - <<run repX(2500, "event")>> - <<set cashX(forceNeg(_price), "farmyard")>> - <<set $rations = 1>> - <</replace>> - <</link>> - <<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>>//This will cost <<print cashFormat(_price)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price)>> and incur significant upkeep costs//<</if>> - <br><<link "They can figure their problem out on their own">> - <<replace "#result">> - You have your own problems to deal with, and you simply can't afford to drop everything and solve theirs at the moment. That you can't take care of your arcology's citizen @@.red;reflects poorly on you.@@ - <<run repX(-500, "event")>> - <</replace>> - <</link>> - </span> - -<<case 2>> - - It's been a few weeks since your citizens had approached you asking for aid, and since then, the situation hasn't improved. In fact, it had gotten worse, and food prices have reached a record high. The tension in $arcologies[0].name is palpable, and small riots have broken out more than once over disputes about food. You are not surprised, then, when you receive a visit from some of the "middle class" /* TODO: still not really happy with this */ citizens. They state that they noticed that you have been giving out rations to the poorer citizens, and, now that the situation has become dire, were wondering if you would be willing to do the same for them. - - <br><br> - - <span id="result"> - <<link "Give them generous rations as well">> - <<replace "#result">> - You still have more than enough to go around, so you inform the leaders that you have decided you will give them large rations, enough to feed even the hungriest citizen. The leaders are @@.green;very pleased@@ to hear that you are taking care of them as well. - <<run repX(5000, "event")>> - <<set cashX(forceNeg(_price*2), "farmyard")>> - <<set $rations = 4>> - <</replace>> - <</link>> - <<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>>//This will cost <<print cashFormat(_price*2)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price*2)>> and incur significant upkeep costs//<</if>> - <br><<link "Provide them with enough sustenance to survive on too">> - <<replace "#result">> - As much as you'd like to provide them with all of the food in the world, it simply is not feasible in your current situation. Therefore, you announce to the leaders that you will provide them only enough rations to live off of. The leaders understand, and are @@.green;pleased@@ to hear that you would provide for them at all. - <<run repX(2500, "event")>> - <<set cashX(forceNeg(_price), "farmyard")>> - <<set $rations = 3>> - <</replace>> - <</link>> - <<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>>//This will cost <<print cashFormat(_price)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price)>> and incur significant upkeep costs//<</if>> - <br><<link "Change your mind about giving out any rations at all">> - <<replace "#result">> - Having given the people rations at all was a mistake, you think to yourself. You have a great number of your own problems to deal with, and providing rations to everyone that can't afford food is putting an unnecessary strain on your own situation. With this is mind, you tell the leaders that you simply can't help them at this time, and have decided that you can't help anyone with food at all. The citizens are understandably @@.red;angry@@ that you would go back on your word. - <<run repX(-1000, "event")>> - <<set $rations = 0>> - <</replace>> - <</link>> - </span> - -<<case 3>> - - Another few weeks has passed since your last meeting with your citizens regarding rationing, and things have only deteriorated further since then. It was only a matter of time, then, before the wealthier citizens of $arcologies[0].name paid you a visit one afternoon. While being able to afford food wasn't exactly difficult for them as of yet, they could read the writing on the wall, and knew it would only be a matter of time before the prices of food were so high that even they would be forced to beg for handouts. - - <br><br> - - Seeing the progress you had made since taking control of the arcology, they decided their best course of action was to come to you with a proposition. They would allow you to take full control of the food supply in $arcologies[0].name, and in return you would keep them well-fed. ''This is a unique opportunity.'' If you turn their offer down, the citizens of your arcology will find another way of surviving. - - <span id="result"> - <br> - <br><<link "Set up a food market">> - <<replace "#result">> - You know that a proposition like this wouldn't have been easy for your citizens to make, and you also know that there is no one better suited to a task like this than you. You announce that you will be setting up a market to buy, sell, and store food in, and that you'll make sure that the citizens will continue to be well-fed. Your citizens are @@.green;glad@@ to hear that you are looking out for their best interests. - <<run repX(5000, "event")>> - <<set cashX(forceNeg(_price*5), "farmyard")>> - <<set $foodMarket = 1>> - <<unset $rations>> - <</replace>> - <</link>> - <<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>>//This will cost an initial investment of <<print cashFormat(_price*5)>>, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost an initial investment of <<print cashFormat(_price*5)>>//<</if>> - <br><<link "Politely decline their offer, but continue giving them rations">> - <<replace "#result">> - Things have been going fairly well for you, but not //that// well — setting up an entirely new place to buy, sell, and store food would no doubt be an expensive undertaking. You tell the citizens that while you can't spare the resources to create a new market at the moment, you will honor your past agreement and continue giving them free rations. The people initially seem a bit disappointed that you don't seem to want to expand $arcologies[0].name, but are ultimately @@.green;glad@@ to hear that you'll continue taking care of them. - <<run repX(2500, "event")>> - <<set cashX(forceNeg(_price), "farmyard")>> - <<set $rations = 5>> - <</replace>> - <</link>> - <<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist" || $PC.career == "entrepreneur" || $PC.career == "business kid")>>//This will cost <<print cashFormat(_price)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price)>> and incur significant upkeep costs//<</if>> - <br><<link "Turn down their offer and end rationing completely">> - <<replace "#result">> - While a new place to buy, sell, and store food in $arcologies[0].name would most likely come in quite handy in the future, you ultimately decide that you simply cannot spare the resources required. In fact, giving rations at all was a costly venture, and after not having seen any sort of return-on-investment, you decide that you are unable to continue giving out rations anymore. Your citizens are @@.red;angry@@ at the fact that you seem not to care about them at all, but that's their problem. - <<run repX(-1000, "event")>> - <<unset $rations>> - <</replace>> - <</link>> - </span> - -<</switch>> \ No newline at end of file -- GitLab