From d62d27bf45f4fdb5350387aeae4aab81acda5021 Mon Sep 17 00:00:00 2001 From: DCoded <dicoded@email.com> Date: Sat, 3 Jul 2021 20:53:18 -0400 Subject: [PATCH] Replaced single event file with multiple event files --- .../foodCrisis/pFoodCrisisLowerClass.js | 85 ++++++++++ .../foodCrisis/pFoodCrisisMiddleClass.js | 78 +++++++++ .../foodCrisis/pFoodCrisisUpperClass.js | 82 ++++++++++ src/events/nonRandom/pFoodCrisis.js | 153 ------------------ src/events/nonRandomEvent.js | 2 +- 5 files changed, 246 insertions(+), 154 deletions(-) create mode 100644 src/events/nonRandom/foodCrisis/pFoodCrisisLowerClass.js create mode 100644 src/events/nonRandom/foodCrisis/pFoodCrisisMiddleClass.js create mode 100644 src/events/nonRandom/foodCrisis/pFoodCrisisUpperClass.js delete mode 100644 src/events/nonRandom/pFoodCrisis.js diff --git a/src/events/nonRandom/foodCrisis/pFoodCrisisLowerClass.js b/src/events/nonRandom/foodCrisis/pFoodCrisisLowerClass.js new file mode 100644 index 00000000000..912154eb8c7 --- /dev/null +++ b/src/events/nonRandom/foodCrisis/pFoodCrisisLowerClass.js @@ -0,0 +1,85 @@ +App.Events.pFoodCrisisLowerClass = class PFoodCrisis extends App.Events.BaseEvent { + constructor(actors, params) { + super(actors, params); + } + + actorPrerequisites() { + return []; + } + + eventPrerequisites() { + return [ + () => App.Events.effectiveWeek() >= 48, + () => !!V.experimental.food, + () => !V.eventResults.foodCrisis, + ]; + } + + execute(node) { + let r = []; + + 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; + + 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.addResponses(node, [ + 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`}`), + new App.Events.Result(`Give them enough to survive on`, enough, `This will cost ${cashFormat(price * 1.5)} and ${discount ? `some upkeep, <span class="skill player">reduced by your knowledge of trading</span>` : `will incur significant upkeep costs`}`), + new App.Events.Result(`They can figure their problem out on their own`, refuse) + ]); + + V.eventResults.foodCrisis = 1; // don't repeat this event + + function ample() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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; + cashX(forceNeg(price * 2.5), "farmyard"); + repX(3500, "event"); + + App.Events.queueEvent(2, new App.Events.pFoodCrisisMiddleClass()); + App.Events.addParagraph(el, r); + + return el; + } + + function enough() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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; + cashX(forceNeg(price * 1.5), "farmyard"); + repX(2000, "event"); + + App.Events.queueEvent(2, new App.Events.pFoodCrisisMiddleClass()); + App.Events.addParagraph(el, r); + + return el; + } + + function refuse() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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.rations = 0; + repX(-1500, "event"); + + App.Events.addParagraph(el, r); + + return el; + } + } +}; diff --git a/src/events/nonRandom/foodCrisis/pFoodCrisisMiddleClass.js b/src/events/nonRandom/foodCrisis/pFoodCrisisMiddleClass.js new file mode 100644 index 00000000000..f4ade4e633b --- /dev/null +++ b/src/events/nonRandom/foodCrisis/pFoodCrisisMiddleClass.js @@ -0,0 +1,78 @@ +App.Events.pFoodCrisisMiddleClass = class PFoodCrisis extends App.Events.BaseEvent { + constructor(actors, params) { + super(actors, params); + } + + actorPrerequisites() { + return []; + } + + eventPrerequisites() { + return [ + () => !!V.experimental.food, + ]; + } + + execute(node) { + const r = []; + + 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; + + 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); + + App.Events.addResponses(node, [ + 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`}`), + 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`}`), + new App.Events.Result(`Change your mind about giving out any rations at all`, refuse) + ]); + + function ample() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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; + cashX(forceNeg(price * 2), "farmyard"); + repX(3000, "event"); + + App.Events.queueEvent(2, new App.Events.pFoodCrisisUpperClass()); + App.Events.addParagraph(el, r); + + return el; + } + + function enough() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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; + cashX(forceNeg(price), "farmyard"); + repX(1500, "event"); + + App.Events.queueEvent(2, new App.Events.pFoodCrisisUpperClass()); + App.Events.addParagraph(el, r); + + return el; + } + + function refuse() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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.rations = 0; + repX(-1500, "event"); + + App.Events.addParagraph(el, r); + + return el; + } + } +}; diff --git a/src/events/nonRandom/foodCrisis/pFoodCrisisUpperClass.js b/src/events/nonRandom/foodCrisis/pFoodCrisisUpperClass.js new file mode 100644 index 00000000000..39049ac261b --- /dev/null +++ b/src/events/nonRandom/foodCrisis/pFoodCrisisUpperClass.js @@ -0,0 +1,82 @@ +App.Events.pFoodCrisisUpperClass = class PFoodCrisis extends App.Events.BaseEvent { + constructor(actors, params) { + super(actors, params); + } + + actorPrerequisites() { + return []; + } + + eventPrerequisites() { + return [ + () => !!V.experimental.food, + ]; + } + + execute(node) { + let r = []; + + 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; + + 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. <span class="bold">This is a unique opportunity.</span> If you turn their offer down, the citizens of your arcology will find another way of surviving.`); + + App.Events.addParagraph(node, r); + + App.Events.addResponses(node, [ + new App.Events.Result(`Set up a food market`, foodMarket, `This will cost an initial investment of ${cashFormat(price * 15)}${discount ? `, <span class="skill player">reduced by your knowledge of trading</span>` : ``}`), + 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`}`), + new App.Events.Result(`Turn down their offer and end rationing completely`, refuse), + ]); + + function foodMarket() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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.foodMarket = 1; + V.rations = 0; + cashX(forceNeg(price * 15), "farmyard"); + repX(5000, "event"); + + App.Events.addParagraph(el, r); + + return el; + } + + function enough() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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; + cashX(forceNeg(price), "farmyard"); + repX(1500, "event"); + + App.Events.addParagraph(el, r); + + return el; + } + + function refuse() { + const el = new DocumentFragment(); + const r = []; + + r.push(`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.rations = 0; + repX(-1500, "event"); + + App.Events.addParagraph(el, r); + + return el; + } + } +}; diff --git a/src/events/nonRandom/pFoodCrisis.js b/src/events/nonRandom/pFoodCrisis.js deleted file mode 100644 index c9c3c17e052..00000000000 --- a/src/events/nonRandom/pFoodCrisis.js +++ /dev/null @@ -1,153 +0,0 @@ -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 6b79693d25d..1d3fe25284e 100644 --- a/src/events/nonRandomEvent.js +++ b/src/events/nonRandomEvent.js @@ -92,7 +92,7 @@ App.Events.getNonrandomEvents = function() { new App.Events.MurderAttemptFollowup(), new App.Events.pRaped(), new App.Events.pAbducted(), - new App.Events.pFoodCrisis(), + new App.Events.pFoodCrisisLowerClass(), // secExp new App.Events.secExpSmilingMan0(), -- GitLab