Browse Source

overhaul `Bodydescription`

Stephan Fuchs 2 months ago
parent
commit
ba016ff226

+ 4 - 0
sugarcube/src/interfaces.d.ts

@@ -593,7 +593,11 @@ declare global {
 	}
 
 	export interface Character{
+		eyecolor:EEyeColor;
+		eyesize:EEyeSize;
+
 		hairColor:EHairColor;
+		hairLengthCategory:EHairLength;
 	}
 
 	export interface ConnectedLocation{

+ 2 - 2
sugarcube/src/locations/city/city_clinic.tw

@@ -1189,7 +1189,7 @@
 	<h3>Electrolysis (<<money 80000>>)</h3>
 	<p>
 		Your leg hair and pubes will be shaved off and, using laser technology, permanently prevented from growing again. This procedure can't be undone.
-		<<if $pc.legHairIsLasered && $pc.pubesAreLasered>>
+		<<if $pc.legHairState != 0 && $pc.pubesAreLasered>>
 			<<positive>>You already got this treatment.<</positive>>
 		<<else>>
 			<<act 'Electrolysis' undefined `{cost:{bank:80000}}`>>
@@ -1289,7 +1289,7 @@
 
 :: clinic_cosmeticSurgeon_electrolysis[event]
 	<<addtime 120>>
-	<<set $pc.legHairIsLasered = true>>
+	<<set $pc.legHairState = 2>>
 	<<set $pc.pubesAreLasered = true>>
 
 	<<image "locations/city/residential/clinic/electrolysis.jpg">>

+ 36 - 4
sugarcube/src/menu/characterOverview/characterOverview.tw

@@ -134,8 +134,8 @@
 
 	<h3>Head</h3>
 	<p>
-		<<set _hcolor = setup.BodyDescription.get('hairColor')>>
-		<<set _hLength = setup.BodyDescription.getCategoryIndex('hairLength')>>
+		<<set _hcolor = $pc.desc.hairColorString>>
+		<<set _hLength = $pc.hairLengthCategory>>
 		<<switch _hLength>>
 			<<case 0>>
 				<<textWithTooltip `'You have very short '+_hcolor+' hair.'`>><<image $pc.bodyImage('hair')>><</textWithTooltip>>
@@ -163,8 +163,8 @@
 				<<textWithTooltip `'You have extremely long '+_hcolor+' hair.'`>><<image $pc.bodyImage('hair')>><</textWithTooltip>>
 				Reaching all the way past your butt, even Rapunzel would be jealous.
 		<</switch>>
-
-		You have <<=setup.BodyDescription.get('eyes')>> eyes.
+		<<set  $pc.eyesize = 1>>
+		You have $pc.desc.eyesString eyes.
 		
 		<<set _earpiercing = $pc.decoGet('piercing','ears')>>
 		<<if _earpiercing > 0>>
@@ -200,6 +200,38 @@
 			Your nipples are <<textWithTooltip 'pierced'>><<piercingImage 'nipples' _piercing>><</textWithTooltip>>.
 		<</if>>
 	</p>
+	
+	<h3>Legs and feet</h3>
+	<p>
+		<<switch $pc.legHairState>>
+			<<case 1>>
+				Your legs have been waxed and are therefore completely smooth. At some point your hair will start growing again, though.
+			<<case 2>>
+				Your legs are completely smooth and free from any hair. You had a laser procedure to ensure that they stay this way.
+			<<default>>
+				<<switch $pc.legHairVisibility>>
+					<<case 0>>
+						Your legs feel smooth as silk. There is no hair to be found.
+					<<case 1>>
+						The hair on your legs isn't visible yet, but they already feel rather rough if you run your hand over them.
+					<<case 2>>
+						Being <<=Math.ceil($pc.legHair)>>&nbsp;mm long, the hair on your legs is long enough to be noticable.
+					<<case 3>>
+						Being <<=Math.ceil($pc.legHair)>>&nbsp;mm long, the hair on your legs is obvious.
+					<<default>>
+						Being <<=Math.ceil($pc.legHair)>>&nbsp;mm long, your hair on your legs makes them look rather manly.
+				<</switch>> 
+		<</switch>>
+		<<if $pc.outfit.clothes.bottomShortness == 1>>
+			Since they are completely covered by your
+			<<if $pc.outfit.clothes.pantsShortness>>
+				pants
+			<<else>>
+				skirt
+			<</if>>
+			nobody can see the difference.
+		<</if>>
+	</p>
 
 	/*
 

+ 46 - 43
sugarcube/src/playerCharacter/PlayerCharacter.ts

@@ -863,23 +863,8 @@ class PlayerCharacter implements Character{
 
 		//#region Eyes
 			
-			/**
-			 * 0: brown
-			 * 1: grey
-			 * 2: green
-			 * 3: blue
-			 * @type {(0|1|2|3)}
-			 */
-			eyecolor:0|1|2|3 = 3;
-
-			/**
-			 * 0: small
-			 * 1: medium
-			 * 2: large
-			 * 3: huge
-			 * @type {(0|1|2|3)}
-			 */
-			eyesize:0|1|2|3 = 1;
+			eyecolor:EEyeColor = EEyeColor.BLUE;
+			eyesize:EEyeSize = EEyeSize.MEDIUM;
 		//#endregion
 
 		faceGeneticAttractiveness = 0;
@@ -1029,6 +1014,18 @@ class PlayerCharacter implements Character{
 			get hairLength(){return this.pcs_hairlng;}
 			set hairLength(v){this.pcs_hairlng = v;}
 
+			get hairLengthCategory():EHairLength{
+				const categories = [
+					30,80,160,260,400,600,800
+				];
+				for(let index = 0; index < categories.length; index++){
+					let maxLengthOfCategory = categories[index];
+					if(this.hairLength <= maxLengthOfCategory)
+						return index;
+				}
+				return categories.length;
+			}
+
 			hairColor:EHairColor = 0;
 			hairColorNatural:EHairColor = 0;
 			hairDyeFade = 0;
@@ -1044,48 +1041,54 @@ class PlayerCharacter implements Character{
 			_leghair = 0;
 			/**
 			 * The length of the hair on the legs in mm.
-			 * @date 7/23/2023 - 9:25:25 AM
-			 *
 			 * @type {number}
 			 */
 			get legHair(){return this._leghair;}
 			set legHair(v){this._leghair = v;}
 
-			legHairState = 0;	//0: default, 1: lasered
-			get legHairGrowth(){
-				switch(this.legHairState){
-					case 0: return (this.age < 18 ? 0.14 : 0.21);
-					case 1: return 0;
-				}
+			_legHairState:ELegHairState = ELegHairState.DEFAULT;
+			_legHairWaxExpiration:Date;
+
+			get legHairState():ELegHairState{
+				if(this._legHairState == ELegHairState.WAXED && !this._legHairWaxExpiration.isFuture)
+					this._legHairState = ELegHairState.DEFAULT;
+				return this._legHairState;
 			}
-			get legHairIsLasered(){return (this.legHairState == 1);}
-			set legHairIsLasered(v){
-				if(v){
+			set legHairState(v:ELegHairState){
+				if(v != ELegHairState.DEFAULT)
 					this.legHair = 0;
-					this.legHairState = 1;
-				}else{
-					this.legHairState = 0;
+				if(v == ELegHairState.WAXED)
+					this._legHairWaxExpiration = State.variables.time.dayWithOffsetS(28);
+				this._legHairState = v;
+			}
+
+			get legHairGrowth(){
+				switch(this.legHairState){
+					case ELegHairState.DEFAULT: return (this.age < 18 ? 0.14 : 0.21);
+					case ELegHairState.WAXED: return 0;
+					case ELegHairState.LASERED: return 0;
 				}
 			}
 
-			get legHairVisibility(){
-				if(this.legHair <= 0)
-					return 0;
+
+			get legHairVisibility():ELegHairVisibility{
+				if(this.legHair <= 0.25)
+					return ELegHairVisibility.SMOOTH;
 				else if(this.legHair <= 0.5) // ~3 Days
-					return 1;
+					return ELegHairVisibility.INVISIBLE;
 				else if(this.legHair <= 1.5) // ~1 Week
-					return 2;
+					return ELegHairVisibility.NOTICABLE;
 				else if(this.legHair <= 6) // ~1 Month
-					return 3;
-				return 4;
+					return ELegHairVisibility.LONG;
+				return ELegHairVisibility.MANLY;
 			}
 			set legHairVisibility(v){
 				switch (v) {
-					case 0: this._leghair = 0; return;
-					case 1: this._leghair = 0.2; return;
-					case 2: this._leghair = 1; return;
-					case 3: this._leghair = 4; return;
-					default:this._leghair = 20; return;
+					case ELegHairVisibility.SMOOTH: 	this._leghair = 0; return;
+					case ELegHairVisibility.INVISIBLE: 	this._leghair = 0.2; return;
+					case ELegHairVisibility.NOTICABLE: 	this._leghair = 1; return;
+					case ELegHairVisibility.LONG: 		this._leghair = 4; return;
+					default:							this._leghair = 20; return;
 				}
 			}
 		//#endregion

+ 148 - 72
sugarcube/src/playerCharacter/body/descriptions/BodyDescription.ts

@@ -1,5 +1,66 @@
+const enum EEyeColor{
+	BROWN,
+	GREY,
+	GREEN,
+	BLUE
+}
+
+const enum EEyeSize{
+	SMALL,
+	MEDIUM,
+	LARGE,
+	HUGE
+}
+
 const enum EHairColor{
+	BLACK,
+	BROWN,
+	GINGER,
+	BLONDE,
+	SCARLET,
+	DARK_BLUE,
+	BLUE,
+	LIGHT_BLUE,
+	DARK_GREEN,
+	GREEN,
+	LIGHT_GREEN,
+	DARK_PINK,
+	PINK,
+	LIGHT_PINK,
+	DARK_PURPLE,
+	PURPLE,
+	LIGHT_PURPLE,
+	LIGHT_ORANGE,
+	DARK_RED,
+	CHERRY_RED,
+	TURQUOISE,
+	CARROT_ORANGE,
+	DARK_ORANGE
+}
+
+const enum EHairLength{
+	EXTREMLY_SHORT,
+	SHORT,
+	MEDIUM_LENGTH,
+	SHOULDER_LENGTH,
+	LONG,
+	VERY_LONG,
+	EXTREMELY_LONG,
+	INCREDIBLY_LONG
+}
+
+const enum ELegHairState{
+	DEFAULT,
+	WAXED,
+	LASERED
+}
 
+const enum ELegHairVisibility{
+	SMOOTH,
+	INVISIBLE,
+	NOTICABLE,
+	LONG,
+	MANLY
 }
 
 class BodyDescription{
@@ -8,7 +69,90 @@ class BodyDescription{
 		this.#character = character;
 	}
 
-	
+	static get eyesColorsString():string[]{
+		return [
+			'brown',
+			'grey',
+			'green',
+			'blue'
+		];
+	}
+
+	get eyesColorString():string{
+		const eyeColor = this.#character.eyecolor;
+		return BodyDescription.eyesColorsString[eyeColor];
+	}
+
+	static get eyesSizesString():string[]{
+		return [
+			'small',
+			null,
+			'large',
+			'huge'
+		]
+	}
+
+	get eyesSizeString():string{
+		const eyesize = this.#character.eyesize;
+		return BodyDescription.eyesSizesString[eyesize];
+	}
+
+	get eyesString():string{
+		return [this.eyesSizeString,this.eyesColorString].join(' ');
+	}
+
+	static get hairColorsString():string[]{
+		return [
+			'black',
+			'brown',
+			'ginger',
+			'blonde',
+			'scarlet',
+			'dark blue',
+			'blue',
+			'light blue',
+			'dark green',
+			'green',
+			'light green',
+			'dark pink',
+			'pink',
+			'light pink',
+			'dark purple',
+			'purple',
+			'light purple',
+			'light orange',
+			'dark red',
+			'cherry red',
+			'turquoise',
+			'carrot orange',
+			'dark orange',
+		];
+	}
+
+	get hairColorString():string{
+		const hairColor = this.#character.hairColor ?? 0;
+		return BodyDescription.hairColorsString[hairColor];
+	}
+
+	static get hairLengthsString():string[]{
+		return [
+				'extremly short',
+				'short',
+				'medium-length',
+				'shoulder-length',
+				'long',
+				'very long',
+				'extremely long',
+				'incredibly long'
+			]
+	}
+
+	get hairLengthString():string{
+		const hairLength = this.#character.hairLengthCategory ?? 0;
+		return BodyDescription.hairLengthsString[hairLength];
+	}
+
+
 
 	//#region  Deprecated
 		/*static get(bodypart:string,character:PlayerCharacter=undefined):string{
@@ -41,28 +185,12 @@ class BodyDescription{
 				];
 			}
 
-			static get eye_colors():string[]{
-				return [
-					'brown',
-					'grey',
-					'green',
-					'blue'
-				];
-			}
+			
 
 			static eye_color(eyeColor:number):string{
 				return this.eye_colors[eyeColor];
 			}
 
-			static get eye_sizes():string[]{
-				return [
-					'small',
-					null,
-					'large',
-					'huge'
-				];
-			}
-
 			static eye_size(eyesize:number):string{
 				return this.eye_sizes[eyesize];
 			}
@@ -77,33 +205,7 @@ class BodyDescription{
 				];
 			}
 
-			static get hair_colors():string[]{
-				return [
-					'black',
-					'brown',
-					'ginger',
-					'blonde',
-					'scarlet',
-					'dark blue',
-					'blue',
-					'light blue',
-					'dark green',
-					'green',
-					'light green',
-					'dark pink',
-					'pink',
-					'light pink',
-					'dark purple',
-					'purple',
-					'light purple',
-					'light orange',
-					'dark red',
-					'cherry red',
-					'turquoise',
-					'carrot orange',
-					'dark orange',
-				];
-			}
+			
 
 			static hair_color(hairColor:number):string{
 				const existingColors = this.hair_colors;
@@ -112,34 +214,8 @@ class BodyDescription{
 				return 'strangely-coloured';
 			}
 
-			static get hair_length_categories():number[]{
-				return [
-					30,80,160,260,400,600,800
-				];
-			}
-
-			static hair_length2category(length:number):number{
-				const categories = this.hair_length_categories;
-				for(let index = 0; index < categories.length; index++){
-					let maxLengthOfCategory = categories[index];
-					if(length <= maxLengthOfCategory)
-						return index;
-				}
-				return categories.length;
-			}
+			
 
-			static get hair_lengths():string[]{
-				return [
-					'extremly short',
-					'short',
-					'medium-length',
-					'shoulder-length',
-					'long',
-					'very long',
-					'extremely long',
-					'incredibly long'
-				]
-			}
 
 			static hair_length(length:number):string{
 				const lengthCategory = this.hair_length2category(length);