class BodyDescription{

	static get(bodypart:string,character:PlayerCharacter=undefined):string{
		character ??= State.variables.pc;
		let attributes:string[] = [];
		switch (bodypart) {
			case 'eyes':		attributes = this.#eye_attributes(character);						break;
			case 'hair':		attributes = this.#hair_attributes(character);						break;
			case 'hairColor':	attributes = [this.hair_color(character.hairColor)];				break;
			default:
				attributes =[`bodypart not found in BodyDescription.get(): ${bodypart}`];
		}

		return attributes.join(' ');
	}

	static getCategoryIndex(bodypart:string,character:PlayerCharacter=undefined):number{
		character ??= State.variables.pc;

		switch (bodypart) {
			case 'hairLength': return this.hair_length2category(character.hairLength);
		}
	}

	//#region Eyes
		static #eye_attributes(character:PlayerCharacter):string[]{
			return [
				this.eye_size(character.eyesize),
				this.eye_color(character.eyecolor),				
			];
		}

		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];
		}

	//#endregion

	//#region Hair
		static #hair_attributes(character:PlayerCharacter):string[]{
			return [
				this.hair_length(character.hairLength),
				this.hair_color(character.hairColor),				
			];
		}

		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;
			if(existingColors[hairColor])
				return existingColors[hairColor];	
			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);
			const existingLenghts = this.hair_lengths;
			if(existingLenghts[lengthCategory])
				return existingLenghts[lengthCategory];	
			return 'weird-lengthed';
			/*if(length <= 30){
				//<<set $result.adj = ['extremly short', 'boyishly short'].random()>>
				//<<set $result.adjLong = 'short, and altogether rather boyish'>>
				return 'extremly short';
			}else if(length <= 80){
				//<<set $result.adj = ['short', 'pixie-cut', 'androgynously short'].random()>>
				//<<set $result.adjLong = 'short, page-boy'>>
				return 'short';
			}else if(length <= 160){
				//<<set $result.adj = ['medium', 'average'].random()>>
				//<<set $result.adjLong = 'medium-length'>>
				return 'medium-length';
			}else if(length <= 260){
				//<<set $result.adj = 'moderate'>>
				//<<set $result.adjLong = 'shoulder-length'>>
				return 'shoulder-length';
			}else if(length <= 400){
				//<<set $result.adj = ['long', 'lengthy'].random()>>
				//<<set $result.adjLong = 'long, past the shoulders'>>
				return 'long';
			}else if(length <= 600){
				//<<set $result.adj = ['very long', 'rather lengthy', 'quite long', 'back-length'].random()>>
				//<<set $result.adjLong = 'very long, back-length'>>
				return 'very long';
			}else if(length <= 800){
				//<<set $result.adj = ['extremely long', 'waist-length'].random()>>
				//<<set $result.adjLong = 'extremely long and waist-length'>>
				return 'extremely long';
			}else{
				//<<set $result.adj = ['exceptionally long', 'incredibly lengthy'].random()>>
				//<<set $result.adjLong = 'exceptionally lengthy and princess-like'>>
				return 'incredibly long';
			}*/
		
		}
	//#endregion

}

setup.BodyDescription = BodyDescription;