code:
Assay Functions:

isSlim(slave) - Returns if slave is considered slim or not by arcology standards.

isStacked(slave) - Returns if slave is considered stacked (big T&A) or not.

isModded(slave) - Tallies a slave's tats and piercings and returns if slave is considered heavily modded or not.

isUnmodded(slave) - Returns if slave is (relatively) unmodded. Some leeway.

isXY(slave) - Returns if a slave has a dick. (This needs review, it's far outdated for what it is used for.)

isPreg(slave) - Returns if a slave looks pregnant.

isNotPreg(slave) - Returns if slave has no sizable belly.

isPure(slave) - Returns if slave has not been surgically enhanced (to a noticeable degree).

isSurgicallyImproved(slave) - Returns if slave has been surgically enhanced with boob, butt and lip implants and also has a small waist.

PiercingScore(slave) - Returns int representing degree of piercings. Higher means more piercings.

TatScore(slave) - Returns int representing degree of tattooing. Higher means more tattoos.

sameAssignmentP(slave, slave) - Returns if slaves are on the same assignment.

haveRelationP(slave1, slave2) - Returns if slave1 is related to second slave2. (NOT extended family mode compliant).

haveRelationshipP(slave1, slave2) - Returns if slave1 is in a relationship with slave2.

isRivalP(slave1, slave2) - Returns if slave1 is in a rivalry with slave2.

supremeRaceP(slave) - Returns if slave is of the superior race. (Should only be used in conjunction with racial supremacy.)

inferiorRaceP(slave) - Returns if slave is of the inferior race. (Should only be used in conjunction with racial subjugation.)

isLeaderP(slave) - Returns if slave is in a leadership assignment.

isMotherP(slave1, slave2) - Returns if slave2 is slave1's mother.

isFatherP(slave1, slave2) - Returns if slave2 is slave1's father.

isParentP(slave1, slave2) - Returns if slave2 is either of slave1's parents.

sameDad(slave1, slave2) - Returns if slave1 and slave2 have the same father.

sameMom(slave1, slave2) - Returns if slave1 and slave2 have the same mother.

areTwins(slave1, slave2) - Returns if slave1 and slave2 are twins.

areSisters(slave1, slave2) - Returns sister status of slave1 and slave2 (1 - twins, 2 - sisters, 3 - half-sisters)

areRelated(slave1, slave2) - Returns if slave1 and slave2 are related.

totalRelatives(slave) - Returns the number of relatives slave has.

mutualChildren(slave1, slave2) - Returns if slave1 and slave2 have children together.

isSlaveAvailable(slave) - Returns if slave is available and not confined someplace.

randomRelatedSlave(slave) - Returns a random relative of slave if possible.

randomRelatedAvailableSlave(slave) - Returns a random available relative of slave if possible.

randomSister(slave) - Returns a random sister of slave if possible.

randomTwinSister(slave) - Returns a random available twin of slave if possible.

randomAvailableSister(slave) - Returns a random available sister of slave if possible.

randomDaughter(slave) - Returns a random child of slave if possible.

randomDaughter(slave) - Returns a random available child of slave if possible.

randomParent(slave) - Returns a random parent of slave if possible.

randomAvailableParent(slave) - Returns a random available parent of slave if possible.

totalPlayerRelatives(PC) - Returns the number of relatives the player has.

isSexuallyPure(slave) - Returns if the slave has (possibly) never had sex.

canGetPregnant(slave) - If the slave is fucked right now, could she get pregnant?

canBreed(slave1, slave2) - Returns if slave1 and slave2 are capable of breeding with each other.

canImpreg(slave1, slave2) - Returns if slave2 can impregnate slave1. PC works as an argument as well.

isFertile(slave) - Returns if the slave is capable of having children.

isPlayerFertile(PC) - Returns if the player can get pregnant.

canAchieveErection(slave) - Returns if the slave can get an erection. (Not blocked by chastity.)

canPenetrate(slave) - Returns if the slave can penetrate successfully.

canSee(slave) - Returns if the slave can see.

canHear(slave) - Returns if the slave can hear.

canWalk(slave) - Returns if the slave can walk.

canTalk(slave) - Returns if the slave can talk.

canDoAnal(slave) - Returns if the slave can currently have anal sex.

canDoVaginal(slave) - Returns if the slave can currently have vaginal sex.

tooFatSlave(slave) - Returns if the slave is too fat to move.

tooBigBreasts(slave) - Returns if the slave's breasts are too big for her to move.

tooBigBelly(slave) - Returns if the slave's belly is too big for her to move.

tooBigBalls(slave) - Returns if the slave's balls are too big for her to move.

tooBigDick(slave) - Returns if the slave's dick is too big for her to move.

tooBigButt(slave) - Returns if the slave's butt is too big for her to move.

milkAmount(slave) - Returns the slave's expected milk output in liters.

foodAmount(slave) - Returns the slave's expected food output in kilograms.

cumAmount(slave) - Returns the slave's expected cum output in deciliters.

isVegetable(slave) - Returns if the slave is mindbroken.

overpowerCheck(slave, PC) - Returns an integer that represents the chance of a slave overpowering the player.

Display Functions:

properTitle() - Returns the player's proper title. (customTitle, Sir, Ma'am)

properMaster() - Returns the slave's title for Master when WrittenMaster() is inappropriate. (customTitle, Master, Mistress)

SlaveFullName(slave) - Returns the slave's full name.

PlayerName() - Returns the player's full name.

PCTitle() - Returns the player's full title.

PoliteRudeTitle(slave) - Returns the slave's title for the player they hate.

SlaveTitle(slave) - Returns the slave's descriptive title.

relativeTerm(slave1, slave2) - Returns the term for slave2's relation to slave1. (daughter, mother, etc)

relationshipChecks [script] All work as expected with <<if X.rivalryTarget == $slaves[$i].ID>> preceding them.
	rivalryTerm(id) - Returns the rivalry term for the input. e.g. lines 99-100 of brothelReport.
		<<if $Madam.rivalryTarget == $slaves[$i].ID>>
			She forces her <<print rivalryTerm($Madam)>>, to service all the men in the brothel.
		Would print 'She forces her growing rival, to service all the men in the brothel.'

	relationshipTerm(id) Returns the long form relationship term for the input. e.g. lines 147-148 of saRules.
		<<if $slaves[$i].relationship > 0>>
			$He often asks to save these breaks so $he can spend them with $his <<print relationshipTerm($slaves[$i])>>.
		Would print '$He often asks to save these breaks so $he can spend them with $his friend.'

	relationshipTermShort(id) Prints the short form of the above. e.g. line 321 of slaveInteract.
		`"Fuck $him with $his <<print relationshipTermShort($activeSlave)>> <<= SlaveFullName($slaves[_si])>>"`
		Would print 'Fuck $him with $his BFF <<= SlaveFullName($slaves[_si])>>'

bellyAdjective(slave) - Returns a string describing her belly size.

lispReplace(string) - Returns the string lispified.

nippleColor(slave) - Returns the slave's nipple color.

UtilJS [script]
	num() - Returns the value thousand separated with ',' if $formatNumbers > 0 else provides the raw value. Returns an integer if $showNumbers == 0, numbers up to a preset max as words if $showNumbers == 1, or only words if $showNumbers == 2.
		line 138 of src/SpecialForce/Report.tw, '...focused their <<print num($SFUnit.Troops)>> troops'
		if $formatNumbers > 0 'focused their 1,589 troops' else 'focused their 1589 troops'
		if $showNumbers == 0 'focused their 1,589 troops', if $showNumbers == 1 'focused their 1,589 troops' (unless the max is set to more than 1,589), else 'focused their one thousand five hundred eighty-nine troops'

	cashFormat() - uses the above function to return the value thousand separated with ',' if $formatNumbers > 0 else provides the raw value. either way prepends ¤ (the fc domination) symbol.
		line 157 of the previously listed file, '...totaling @@.yellowgreen;<<print cashFormat(_SFIncome)>>@@'
		if $formatNumbers > 0 'totaling @@.yellowgreen;¤1,500,000@@' else 'totaling @@.yellowgreen;¤1500000@@'

		isFloat() - Checks if value is float.

		isInt() - Checks if value is an integer.

		numberWithCommas() - Currently unused.

		jsRandom() - JS equivalent of sugarcube's random().

		jsRandomMany() - JS equivalent of sugarcube's randomMany().

		jsEither() - This function wants an array - which explains why it works like array.random(). Give it one or you'll face a NaN. JS equivalent of sugarcube's either() and array.random().

		deepCopy() - This function is alternative to clone - usage needed if nested objects present. Slower but result is separate object tree, not with reference to source object.

		hashChoice() - hashes provided input.

		hashSum() - totals provided input and then hashes.

		arr2obj() - Converts an array to an object. e.g. line 250 of :: init Nationalities [silently]
			<<set $nationalities = arr2obj(setup.baseNationalities)>>

		hashPush() //Note really sure where input is being pushed to.

		weightedArray2HashMap()

		between(a, low, high) - outputs the value down the middle of two inputs e.g.
			between($trees, 1, 3) returns $trees = 2

Core Slave Functions:

newSlave(slave) - Adds slave object to main slave array. Do not use without care!

getSlave(ID) - Returns the slave object with the matching ID.

getPronouns(slave) - Returns an object containing a slave's pronouns.

SlavePronouns(slave) - Sets global pronoun variables to a slave's pronouns. ($he, $He, $His, $his, $him) (obsolete?)

WrittenMaster(slave) - Returns a slave's title for the player and sets lisping. Returns $activeSlave if not given an argument.

Enunciate(slave) - Syncs lisp widgets with slave.

fetishChangeChance(slave) - Returns an int between 0,100 as the chance of a slave's fetish shifting to a new one.

SlaveSort(slaveArray) - Sorts the slaveArray array and sets indices.

slaveSortMinor(slaveArray) - Alphabetically sorts the slaveArray array and returns it.

faceIncrease(slave, amount) - Increases slave's .face by amount and returns a comment if it passes a threshold.

assignJob(slave, assignment) - Assigns slave to assignment. Mandatory for assigning to facilities.

removeJob(slave, assignment) - Removes slave from assignment to "rest". Mandatory for removing from facilities.

GenerateNewSlave(sex) - Generates a new slave of sex. Replaces <<include "Generate __ Slave">>

setPregType(actor) - Returns a random ovum count based off actor values and other factors to be set as .pregType.

removeActiveSlave() - Removes $activeSlave from $slaves. Do not use without care!

SetBellySize(slave) - Sets slave's belly size.(pregnancy+inflation+implant)

generatePronouns(slave) - Sets slave's pronouns.

SoftenBehavioralFlaw(slave) - Replaces the slave's behavioral flaw with the corresponding quirk.

SoftenSexualFlaw(slave) - Replaces the slave's sexual flaw with the corresponding quirk.

UtilJS [script]
	Height.mean(nationality, race, genes, age) - returns the mean height for the given combination and age in years (>=2).
 Height.mean(nationality, race, genes) - returns the mean adult height for the given combination.
 Height.mean(slave) - returns the mean (expected) height for the given slave.

 Height.random(nationality, race, genes, age) - returns a random height using the skew-normal distribution around the mean height for the given arguments.
 Height.random(nationality, race, genes) - returns a random height for the given combination of an adult, as above.
 Height.random(slave[, options]) - returns a random height for the given slave, as above.

 Height.forAge(height, age, genes) - returns the height adapted to the age and genes.
 Height.forAge(height, slave) - returns the height adapted to the slave's age and genes.

 heightToEitherUnit() - takes an int in centimeters e.g. $activeSlave.height, returns a string in the format of either `200cm (6'7")`, `6'7"`, or `200cm`

 Height.config(configuration) - configures the random height generator globally and returns the current configuration.

 Intelligence.random(options) - returns a random intelligence. If no options are passed, the generated number will be on a normal distribution with mean 0 and standard deviation 45.

 getSlaveDevotionClass(slave) - returns the trust of the target as text. e.g. if ('mindbroken' == slave.fetish) return 'mindbroken';

 getSlaveTrustClass(slave) - returns the trust of the target as text. e.g. if (slave.trust < -95) return 'extremely-terrified';

Sex Functions:

knockMeUp(actor, chance, hole, fatherID, displayOverride) - Attempts to impregnate actor.

AnalVCheck(count) - Increments $activeSlave's anal count by count and attempts to take virginity. Defaults to 1.

VaginalVCheck(count) - Increments $activeSlave's vaginal count by count and attempts to take virginity. Defaults to 1.

VaginalVCheck(countAnal, countBoth) - Attempts to increment $activeSlave's anal count by countAnal and attempts to increment vaginal by countBoth. Defaults to 1. Attempts to take virginities.

SimpleVCheck(count) - Calls either VaginalVCheck or AnalVCheck count times.

PartnerVCheck(countAnal, countBoth) - Attempts to increment $partner's anal count by countAnal and attempts to increment vaginal by countBoth. Defaults to 1. Attempts to take virginities.

SimpleSexAct(slave, count) - Runs a player on slave sex act count times. (randomly chooses hole based off availability.)

SimpleSlaveFucking(slave, count) - Runs a slave on slave sex act count times. (randomly chooses hole based off availability.)

SimpleSlaveSlaveFucking(slave1, slave2, count) - Runs a slave2 on slave1 sex act count times. (randomly chooses hole based off availability.)

UtilJS [script]

	dickToInchString() - takes a dick value e.g. $activeSlave.dick, returns a string in the format 6 inches

	dickToCM() - takes a dick value e.g. $activeSlave.dick, returns an int of the dick length in cm

	ballsToInchString() - takes a ball value e.g. $activeSlave.balls, returns a string in the format 3 inches

	ballsToCM() - takes a ball value e.g. $activeSlave.balls, returns an int of the ball size in cm

	dickToEitherUnit() - takes a dick value e.g. $activeSlave.dick, returns a string in the format of either `20cm (8 inches)`, `8 inches`, or `20cm`

	ballsToEitherUnit() - takes a ball value e.g. $activeSlave.balls, returns a string in the format of either `20cm (8 inches)`, `8 inches`, or `20cm`

Pregnancy Functions:

WombInit($slave) - before first pregnancy, at slave creation, of as backward compatibility update.

WombImpregnate($slave, $fetus_count, $fatherID, $initial_age) - should be added after normal impregnation code, with already calculated fetus count. ID of father - can be used in future for processing children from different fathers in one pregnancy. Initial age normally 1 (as .preg normally set to 1), but can be raised if needed. Also should be called at time as broodmother implant add another fetus(es), or if new fetuses added from other sources in future (transplanting maybe?)

WombProgress($slave, $time_to_add_to_fetuses) - after code that update $slave.preg, time to add should be the same.

$isReady = WombBirthReady($slave, $birth_ready_age) - how many children ready to be birthed if their time to be ready is $birth_ready_age (40 is for normal length pregnancy). Return int - count of ready to birth children, or 0 if no ready exists.

$children = WombBirth($slave, $birth_ready_age) - for actual birth. Return array with fetuses objects that birthed (can be used in future) and remove them from womb array of $slave. Should be called at actual birth code in sugarcube. fetuses that not ready remained in womb (array).

WombFlush($slave) - clean womb (array). Can be used at broodmother birthstorm or abortion situations in game. But birthstorm logically should use WombBirth($slave, 35) or so before - some children in this event is live capable, others is not.

$slave.bellyPreg = WombGetWolume($slave) - return double, with current womb volume in CC - for updating $slave.bellyPreg, or if need to update individual fetuses sizes.

findFather(ID) - searches for the ID given and returns an object or undefined

Other Functions:

isItemAccessible(itemName) - Returns if the string is available for use. Defaults to true.

UtilJS [script]
	arraySwap() - swaps inputted array.

	html5passage(passage_function) - circumvents sugarcube, allowing a plain HTML5 UI within it

	capFirstChar() - Capitalizes the first character of a given string.

	cmToInchString() - takes an integer e.g. $activeSlave.hLength, returns a string in the format 10 inches

	cmToFootInchString() - takes an integer e.g. $activeSlave.height, returns a string in the format 6'5"

	lengthToEitherUnit() - takes an int in centimeters e.g. $activeSlave.hLength, returns a string in the format of either `30cm (12 inches)`, `12 inches`, or `30cm`

	ValidateFacilityDecoration() - checks the value of the associated variable and it if it infinite i.e. NA the text description is reset back to standard.
		/* decoration should be passed as "facilityDecoration" in quotes. For example, ValidateFacilityDecoration("brothelDecoration"). The quotes are important, do not pass it as a story variable. */

	FSChangePorn() - //Currently unused, widget version routes directly through FSChange()

	ordinalSuffix(i) - takes a value as an input and then appends the appropriate suffix. e.g.$Day === 1 "today is the <<print ordinalSuffix($Day)>> of the month"
		would print "today is the 1st of the month"

	removeDuplicates() - Takes an array and returns a new array without duplicate entries

	HackingSkillMultiplier() - outputs a value based off of the PC's hacking skill.

	upgradeMultiplierArcology() - outputs a value based off of the PC's engineering skill.

	upgradeMultiplierMedicine() - outputs a value based off of the PC's medicine skill.

	upgradeMultiplierTrade() - outputs a value based off of the PC's trading skill.

	passageLink() - Creates a HTML element with custom SugarCube attributes which works as a passage link

	SkillIncrease() - Depreciates the sugarcube functions.

	jsNdef - A .js port of sugarcube's ndef.

	jsDef - A .js port of sugarcube's def.

path: devNotes/Useful JS Function Documentation.txt