code:
:: REM fluctuations [nobr]

<<set $nextButton = "Continue">>
<<set $nextLink = "RIE Eligibility Check">>

<<if ($REM == 1)>>
	<<set $REM = either("antislavery terrorism", "medical breakthrough", "new free city", "revel", "speculation", "tainted drugs")>>
<<else>>
	<<set $REM = either("anti-slavery coup", "arcology change", "bankruptcy", "empty prisons", "hostilities ended", "refugee boat", "unemployment", "war")>>
<</if>>
<<setAssistantPronouns>>

<<if $assistant > 0>>
<<if $marketAssistantAnnounced>>
	The market assistant's avatar appears on a wallscreen as you're going about your business.
	<<switch $assistantAppearance>>
	<<case "monstergirl">>The regular monster<<= _girlA>> stands behind and prods the human _girlM forward.
	<<case "shemale">>You recognize _hisM function by _hisM glasses and because _hisM bimbo cock softens, halfway, while _heM addresses you on economic matters.
	<<case "amazon">>_HeM illustrates a small group of gossiping tribeswomen that fades away as _heM leaves them and approaches you.
	<<case "businesswoman">>The junior business<<= _womanM>> adopts a shy posture when addressing you directly, as if unsuccessfully concealing a workplace crush.
	<<case "goddess">>The demigoddess portrait arrives in a glittery cloud of dust, wearing winged shoes.
	<<case "schoolgirl">>Both <<if _girlA == _girlM>>school<<= _girlA>><<else>>student<</if>>s are sitting knee to knee; the nerdy one hands the other a folded note. "Pass it on," _heM stage whispers. <<if $assistantName == "your personal assistant">>Your regular assistant<<else>>$assistantName<</if>> rolls _hisA eyes.
	<<case "hypergoddess">>The demigoddess portrait arrives in a glittery cloud of dust, wearing winged shoes and a noticeable roundness in _hisM middle.
	<<case "loli">>The chubby, glasses-wearing _loliM arrives holding a neatly folded note addressed to you.
	<<case "preggololi">>The chubby, glasses-wearing _loliM arrives holding a hastily written note addressed to you. _HeM seems kind of winded, with a suspicious stain in _hisM panties under _hisM pussy.
	<<case "fairy" "pregnant fairy">>The older fairy flutters into view before, curtseys, and holds out a rolled piece of parchment addressed to you.
	<<case "normal">>_HisM symbol lights up in regular green pulses while _heM waits for your attention.
	<<case "angel">>The short haired angel lands before you, a rolled piece of parchment under _hisM arm.
	<<case "cherub">>The short haired cherub flutters before you holding a rolled piece of parchment in _hisM hands.
	<<case "incubus">>The regular incubus stands behind and prods the human _girlM forward with _hisA dick.
	<<case "succubus">>The regular succubus stands behind and pushes the human _girlM forward.
	<<case "imp">>The short haired imp flaps before you holding a rolled piece of parchment in _hisM hands.
	<<case "witch">>The apprentice's apprentice arrives before you; a message begins playing the moment _heM opens _hisM mouth.
	<<case "ERROR_1606_APPEARANCE_FILE_CORRUPT">>The creature finishes forcing eggs into the human _girlM, leaving _himM to stagger towards you clutching a crumpled letter in one hand and struggling to hold back the eggs with the other.
	<</switch>>
<<else>>
	<<if $assistantName == "your personal assistant">>Your personal assistant<<else>>$assistantName<</if>> appears on a wallscreen as you're going about your business.
	<<switch $assistantAppearance>>
	<<case "monstergirl">>_HeA's looking unusually businesslike, with _hisA tentacle hair restrained in a bun.
	<<case "loli">>_HeA's looking unusually businesslike, withdrawn deep in thought.
	<<case "preggololi">>_HeA's looking unusually businesslike, withdrawn deep in thought.
	<<case "shemale">>_HeA's looking unusually businesslike, with _hisA perpetually erect dick going untended, for once.
	<<case "amazon">>_HeA's looking unusually businesslike, and is doing sums on a primitive little abacus.
	<<case "businesswoman">>_HeA has a clipboard pressed against _hisA generous bosom, and peers at you over the tops of _hisA spectacles.
	<<case "fairy">>_HeA's looking unusually businesslike, wearing a tiny business suit with an opening in the back for _hisA wings to come out.
	<<case "pregnant fairy">>_HeA's looking unusually businesslike, wearing a tiny business suit open in the front to let _hisA swollen belly out and another opening in the back for _hisA wings to come out.
	<<case "goddess" "hypergoddess">>_HeA's looking unusually businesslike, with _hisA hands clasped behind _hisA back and pivoting one foot.
	<<case "schoolgirl">>_HeA's looking unusually businesslike, and has a scribbled note in _hisA hand.
	<<case "angel">>_HeA's looking unusually businesslike; deep in thought with _hisA hands together in front of _himA.
	<<case "cherub">>_HeA's looking unusually businesslike, reading a newspaper titled "Heaven's Post".
	<<case "incubus">>_HeA's looking unusually businesslike, with _hisA typically erect dick flaccid for once.
	<<case "succubus">>_HeA's looking unusually businesslike, wearing a slutty business suit, glasses and _hisA hair in a tight bun. A slight buzzing can be heard from under _hisA skirt.
	<<case "imp">>_HeA's looking unusually businesslike, reading a list titled "Hell's Holes".
	<<case "witch">>_HeA's looking unusually businesslike, nose first in an a book title "Economics and You".
	<<case "ERROR_1606_APPEARANCE_FILE_CORRUPT">>_HeA's looking unusually businesslike, wearing an ill-fitted business suit. _HisA blouse buttons pop off as _hisA belly swells grotesquely, before the object within _himA begins steadily moving upwards.
	<<default>>_HisA symbol spins for attention.
	<</switch>>
	"<<= properTitle()>>, I have a news item that may be of business interest," _heA
	<<switch $assistantAppearance>>
	<<case "monstergirl" "normal">>informs you.
	<<case "shemale">>says seriously.
	<<case "amazon">>says warmly.
	<<case "businesswoman">>says diffidently.
	<<case "goddess">>announces.
	<<case "schoolgirl">>reads aloud.
	<<case "hypergoddess">>announces between _hisA children's kicking.
	<<case "loli" "preggololi">>says cutely.
	<<case "fairy" "pregnant fairy">>says excitedly.
	<<case "angel">>calmly states.
	<<case "cherub" "imp">>says enthusiastically.
	<<case "incubus">>starts, pauses to play with _himselfA, and continues.
	<<case "succubus">>says between overly loud moans.
	<<case "witch">>states, finishes the page, and snaps _hisA fingers. _HeA grunts, reaches up _hisA skirt and pulls out a message for you. Seems it didn't arrive as planned.
	<<case "ERROR_1606_APPEARANCE_FILE_CORRUPT">>says, _hisA throat bulging as the egg containing the message passes out _hisA mouth.
	<</switch>>
<</if>>
<<else>>
Your <<if $marketAssistantAnnounced>>market<<else>>personal<</if>> assistant's symbol appears on a wallscreen as you're going about your business. _HeA spins for your attention. "<<= properTitle()>>, I have a news item that may be of business interest," _heA says.
<</if>>

/* The events reducing slave prices are all supply sided. Without events reducing demand this is a little unbalanced. A minor issue */

<<if $REM == "revel">>
	Something is happening in one of the Free Cities' richest arcologies. It's not clear what, exactly, it is, since its owner is making skillful use of the arcology's advanced surveillance and media systems to keep its internal affairs quite secret. The truth will get out eventually, and it's probably not going to do much for old world opinions of the Free Cities. After all, cheap slaves go into that arcology at a prodigious rate, and they don't seem to ever come out again. The unexpected demand for slaves, any slaves, has produced a temporary tightening of the entire slave market. Projections suggest price increases of up to five percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a great time to sell stock, and a bad time to buy. @@.yellow;The market price of slaves has increased.@@
	<<set $menialDemandFactor += 12000>>
	<<set $menialDemandFactor = Math.clamp($menialDemandFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "tainted drugs">>
	The Free Cities are anarcho-capitalist paradises — or 'paradises,' depending on one's station and assets. You can't complain personally, as one of the Free Cities' richest citizens, master of your own arcology and owner of sexual slaves. Unfortunately quite a few slaves in the markets are in a position to complain today, as are their owners. Many slave markets use long-lasting stimulants to pep their wares up for auction; dull-eyed slaves earn low bids. Corner-cutting at one of the major suppliers of these stimulants led to a number of slaves being prepared for auction being damaged today. Relatively few were permanently lost, but slaves are going to be a little scarce for a while, which will drive up the going rate. Projections suggest increases of up to five percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a great time to sell stock, and a bad time to buy. @@.yellow;The market price of slaves has increased.@@
	<<set $menialSupplyFactor -= 12000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "antislavery terrorism">>
	Antislavery activism in the old world has grown to match the spread of slavery in the Free Cities. Unfortunately for the activists, they are confronted with a fundamental problem: the independence of the Free Cities. There is very little they can do without resorting to violence, and so, predictably, they often do. A major slave induction center in one of the more open Free Cities has just suffered a suicide bombing. The actual damage was slight, but a wave of increased import security is sweeping the Free Cities in reaction to the incident. Slave prices will be driven up by the cost of checking imported merchandise for explosive devices until the market adjusts. Projections suggest price increases of up to five percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a great time to sell stock, and a bad time to buy. @@.yellow;The market price of slaves has increased.@@
	<<set $menialSupplyFactor -= 12000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "new free city">>
	New Free Cities arise unpredictably. They require either carving out a slice of the old world, emancipating it from whichever inattentive or corrupt country previously owned the land, or reclaiming new land from barren or uninhabitable areas, efforts which are often kept secret. The unpredictable happened today; the world has a new Free City. As usual, immigration rights are being offered cheaply to deserving persons. Many of the remaining rich and talented of the old world are staking claims in the new city, and they'll be buying slaves when they get to their new home. It's a sellers' market out there; projections show the price of slaves rising as much as ten percent in the short term. There will be no immediate impact on you or your slaves, but the coming weeks will be a great time to sell stock, and a bad time to buy. @@.yellow;The market price of slaves has increased.@@
	<<set $menialDemandFactor += 20000>>
	<<set $menialDemandFactor = Math.clamp($menialDemandFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "speculation">>
	The Free Cities are almost totally unregulated. Prices and interest rates can spike and plummet with speeds not seen since the South Sea Bubble, and for the most silly or corrupt of reasons. Today, it's the latter. A massive attempt to rig the slave market was uncovered this morning. Ultimately, the culprits were caught and much of the damage reversed, but confidence in the marketplace has been shaken. Many great slave vendors are holding onto their stock until they're sure the water's calm again. It's a sellers' market out there; projections show the price of slaves rising as much as ten percent in the short term. There will be no immediate impact on you or your slaves, but the coming weeks will be a great time to sell stock, and a bad time to buy. @@.yellow;The market price of slaves has increased.@@
	<<set $menialSupplyFactor -= 20000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "medical breakthrough">>
	There has been a breakthrough in gene therapy. More accurately, there was a breakthrough in gene therapy several years ago — you already knew all about it, and some of the more advanced slave medical upgrades available to you use the technology. However, it's finally gotten out of the prototype stage, and is becoming available to the Free Cities middle class, citizens with one or two slaves. The average citizen is more able today than he was yesterday to turn his chattel housekeeper into the girl he's always dreamed of. Aspirational stuff like this always causes a major price shock. It's a sellers' market out there; projections show the price of slaves rising as much as ten percent in the short term. There will be no immediate impact on you or your slaves, but the coming weeks will be a great time to sell stock, and a bad time to buy. @@.yellow;The market price of slaves has increased.@@
	<<set $menialDemandFactor += 20000>>
	<<set $menialDemandFactor = Math.clamp($menialDemandFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "bankruptcy">>
	The economy of the Free Cities is a rough-and-tumble place. The absence of old world regulations and institutions, and the often gold-rush atmosphere of the new cities, lead to fortunes being made and lost overnight. Last night, one of the Free Cities' greatest fortunes was lost. A great slave trading house unexpectedly went bankrupt, and its huge stable of slaves are being sold at fire-sale prices. The unforeseen sell off is driving down the market price of slaves all across the Free Cities. Projections show a short-term price drop of up to five percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialSupplyFactor += 12000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "refugee boat">>
	Periodic refugee crises sweep the old world, and sometimes the human flotsam shaken loose from its moorings in the old world is brought up on the shores of the Free Cities. This week, that was no metaphor. A floating Free City has been inundated by refugees in boats. Naturally, the boats have been discarded and the refugees enslaved. It is unclear whether they somehow did not know that this was their inevitable fate, or their lot in the old world was so desperate that they were willing to accept it. Projections show a short-term slave price drop of up to five percent as the market digests the influx. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialSupplyFactor += 12000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "arcology change">>
	All across the Free Cities, arcology owners are experimenting with new society models and new ways of enforcing them. A nearby arcology has just undergone a major internal struggle as its owner forced through a radical program of changes and harsh measures to enforce them. All but a handful of its inhabitants have been enslaved and placed under the control of a chosen few. With harems of hundreds and little experience or infrastructure to manage them, the new overlords are selling off stock to raise funds to make the transition. Projections show a short-term price drop of up to five percent as they flood the market with mediocre slaves. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialSupplyFactor += 12000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "war">>
	The old world outside the Free Cities took another step towards its final decline today. A relatively prosperous third world city fell to a regional warlord, and it seems the remaining great powers lack either the money or the will to do anything about it. The victors seem to be following the standard procedure for modern conquerors. Anything valuable, they steal. Among the population, they recruit the willing, shoot the unwilling, and enslave everyone else. The slave markets are going to be glutted with new stock soon. Projections show a short-term price drop of up to ten percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialSupplyFactor += 20000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "empty prisons">>
	A small, impoverished old world country defaulted on its currency today. Its beleaguered government is taking every available step to raise funds. Among other things, it has sold every inmate in its prisons who would fetch a price worth the trouble of sale into Free Cities slavery. Though most of the influx is going to be of abominably low quality, the sudden addition of so much new meat is going to have a big impact on the slave economy. Projections show a short-term price drop of up to ten percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialSupplyFactor += 20000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "unemployment">>
	A leading old world nation has just suffered a major economic downturn. Old world nations suffer economic downturns all the time, of course, but to those with interests in the slave market, news like this can be very important. Slave market shocks from catastrophes get all the headlines, but a change that affects millions will often be more impactful. As unemployment in the old world rises, the number of people faced with the choice between starvation and voluntary enslavement rises. Social safety nets just aren't what they used to be. Projections show a short-term slave price drop of up to ten percent due to the sharp increase in desperate people immigrating to the Free Cities for enslavement. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialSupplyFactor += 20000>>
	<<set $menialSupplyFactor = Math.clamp($menialSupplyFactor,-50000,50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "anti-slavery coup">>
	For months there were strong indications that an old world nation was quietly taking steps towards legalizing slavery. The market began to anticipate a serious increase in the demand for slaves in earnest but this week a month of protests against the country's leaders ended in a violent coup. The new government, claiming to only follow the will of the people, has made several promises, including a very vocal rebuke of even the slightest possibility of legal slavery within their borders. The slave market was shocked to find the previous government to be so weak and even more shocked at how unwilling the new one is to accept the times we live in. The panicked market quickly adjusted to greatly lowered slave demand and projections show a short-term price drop of up to ten percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialDemandFactor -= 20000>>
	<<set $menialDemandFactor = Math.clamp($menialDemandFactor, -50000, 50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<<elseif $REM == "hostilities ended">>
	The Free Cities make a real effort to avoid armed conflict, especially amonst themselves, as such endeavors almost never have any real winners. But tensions grew so high in their trade conflict that the likelihood of a full blown war between two Free Cities became not just a possibility but a near certainty for months. As skirmishes commenced and slave armies were quickly drilled for action on both sides, the slave market anticipated a boost to demand as soon as the fighting intensified. Miraculously, cooler heads prevailed and the Free Cities agreed to disband their armies. While many people sighed with relief the slave market was forced into a shock adjustment, projections show a short-term price drop of up to five percent. There will be no immediate impact on you or your slaves, but the coming weeks will be a fine time to buy new stock, and a terrible time to sell. @@.yellow;The market price of slaves has dropped.@@
	<<set $menialDemandFactor -= 12000>>
	<<set $menialDemandFactor = Math.clamp($menialDemandFactor, -50000, 50000)>>
	<<set $slaveCostFactor = menialSlaveCost()/1000>>
<</if>>


code:
:: REM merger [nobr]

<<set $nextButton = "Continue">>
<<set $nextLink = "RIE Eligibility Check">>

<<set _slaveCompany = App.Corporate.divisionList
								   .filter(div => div.founded && div.hasMergers)
								   .map   (div => div.mergerChoices.map((merger, index) => ({merger, index, division:div})))
								   .flat  ()>>
<<set _maxCompanies = Math.trunc(Math.log2(App.Corporate.divisionList.filter(div => div.founded).length)) + 1>>
<<set _numCompanies = random(1, _maxCompanies)>>

<<set _companies = []>>
<<for _index = 0; _index < _numCompanies; ++_index>>
	<<run _companies.push(_slaveCompany.pluck())>>
<</for>>

<<set _assistant = $assistantName>>
<<if $marketAssistantAnnounced>><<set _assistant = "your market assistant">><</if>>

<<= capFirstChar(_assistant) >> constantly combs business records, tax receipts and the media for leads on opportunities for your corporation to take advantage of. Small businesses go under all the time, and with a large amount of cash on hand, your corporation can afford to step in and acquire them. This week, _assistant has found <<= numberWithPlural(_numCompanies, "troubled organization") >> you could easily fold into your corporation.

<<if _companies.length == 1>>
	<<set _company = _companies[0]>>

This week you come across <<= _company.merger.text.trouble >>

<<else>>
	<<for _index, _company range _companies>>

The <<= ordinalSuffixWords(_index + 1)>> is <<= _company.merger.text.trouble >>

	<</for>>
<</if>>

<<for _company range _companies>>
	<<capture _company>>

	<<set _absorbName = "Absorb the " + _company.merger.name>>
	<<link _absorbName>>
		<<replace "#result">>
			You quickly acquire the <<= _company.merger.name>><<= _company.merger.text.acquire >>
			<<set _devCount = _company.merger.result.development,
				  _slaveCount = _company.merger.result.slaves>>
			<<if _devCount != null>>
				<<set _company.division.developmentCount += _devCount>>
			<</if>>
			<<if _slaveCount != null>>
				<<set _company.division.activeSlaves += _slaveCount>>
			<</if>>
			<<set _cost = (_company.merger.cost || 50) * 1000 >>
			<<if _devCount != null && _slaveCount != null>>
				<<set App.Corporate.chargeAsset(_cost / 2, "development")>>
				<<set App.Corporate.chargeAsset(_cost / 2, "slaves")>>
			<<elseif _devCount != null>>
				<<set App.Corporate.chargeAsset(_cost, "development")>>
			<<elseif _slavecount != null>>
				<<set App.Corporate.chargeAsset(_cost, "slaves")>>
			<<else>>
				@@.red;ERROR! No changes to the corporation are made!@@
			<</if>>
		<</replace>>
	<</link>>

	<</capture>>
<</for>>

repo_name: IchthysdeKilt/fc

license: mit