/// <reference path="../../../_system/_shared/Initializing.ts"/>
/// <reference path="OutfitItemEnums.ts" />
/// <reference path="../../wardrobe/itemImagePath.ts" />


class OutfitItem extends Initializing{
	id='';
	index:number=0;
	type:string='';
	vendor:string='';

	thinness?:EClothesThinness=EClothesThinness.REVEALING;
	quality:EOutfitQuality=EOutfitQuality.UNDEFINED;

	isValidItem=false;
	description:string;

	imagePath:string;

	static get(itemId:string):OutfitItem{
		let constantData = this.constantData(itemId);
		let item:OutfitItem;

		switch(constantData.type){
			case 'bodysuit':
				item = new OutfitItemBodyuit();	break;
			case 'bra':
				item = new OutfitItemBra();		break;
			case 'clothes':
				item = new OutfitItemClothes();	break;
			case 'coat':
				item = new OutfitItemCoat();	break;
			case 'panties':
				item = new OutfitItemPanties();	break;
			case 'purse':
				item = new OutfitItemPurse();	break;
			case 'shoes':
				item = new OutfitItemShoes();	break;
			case 'swimwear':
				item = new OutfitItemSwimwear();break;
		}

		item.init(constantData);
		item.isValidItem = true;
		item.id = itemId;
		return item;
	}

	static constantData(itemId:string):OutfitDefinition{
		return setup.outfits[itemId];
	}

	get desc():string{
		return this.description || '';
	}

	
	/**
	 * An image that can be displayed in the sidebar.
	 * @readonly
	 * @type {string}
	 */
	get icon():string{
		return '';
	}

	get image():string{
		if(this.imagePath)
			return this.imagePath;
		return this.imageLegacy;
	}

	get imageLegacy():string{
		return setup.outfitItemImagePath[this.type].formatUnicorn({vendor:this.vendor,id:this.index});
	}

	get inhibition(){
		return 0;
	}

	get inhibitionString():string{
		if(this.inhibition >= 50){
			return 'exhibitionist ';
		}else if(this.inhibition >= 40){
			return 'very revealing '
		}else if(this.inhibition >= 30){
			return 'revealing '		
		}else if(this.inhibition >= 25){
			return 'slightly revealing '
		}else{
			return 'normal '
		}
	}

	get qualityString():string{
		switch(this.quality){
			case EOutfitQuality.UNDEFINED:
				return 'undefined';
			case EOutfitQuality.CRAPPY:
				return 'crappy';
			case EOutfitQuality.VLOW:
				return 'very low';
			case EOutfitQuality.LOW:
				return 'low';
			case EOutfitQuality.AVERAGE:
				return 'average';
			case EOutfitQuality.REASONABLE:
				return 'reasonable';
			case EOutfitQuality.GOOD:
				return 'good';
			case EOutfitQuality.OUTSTANDING:
				return 'outstanding';
		}
	}

	get slots():string[]{
		return [this.type];
	}

	//PXCloBottomShortness
	get bottomShortness():EOutfitBottomShortness{
		return EOutfitBottomShortness.PRIVATE_EXPOSING;
	}
		
}

class OutfitItemBodyuit extends OutfitItem implements OutfitDefinitionBodysuit{
	type:'bodysuit' = "bodysuit";

	get slots():string[]{
		return ['bra','panties'];
	}
}

class OutfitItemBra extends OutfitItem implements OutfitDefinitionBra{
	type:'bra' = "bra";
	subtype?: number;
	fun?: number;
	material?: number;
	cover?: number;

}





class OutfitItemCoat extends OutfitItem implements OutfitDefinitionCoat{
	type:'coat' = "coat";
	warm: number;

}

class OutfitItemPanties extends OutfitItem implements OutfitDefinitionPanties{
	type:'panties' = "panties";
	subtype?: number;
	fun?: number;
	material?: number;
	coverBack?: number;
	coverFront?: number;

}

class OutfitItemSwimwear extends OutfitItem implements OutfitDefinitionSwimwear{
	type:'swimwear' = "swimwear";
	subtype: 'bikini'|'swimsuit';
	thinness:EClothesThinness=EClothesThinness.REVEALING;
	topcut: number;
	includesBra?:number;
	includesPanties: number;
	isOnepiece: number;
	inhib: number;
	coverTop?:number;

	get icon():string{
		let image : string;
		if(this.inhibition >= 50){
			image = 'swimsuit_e'
		}else if(this.inhibition >= 40){
			image = 'swimsuit_s'
		}else if(this.inhibition >= 30){			
			image = 'swimsuit_s'
		}else if(this.inhibition >= 25){
			image = 'swimsuit_s'
		}else{
			image = 'swimsuit'
		}
		return `system/icons/status/${image}.png`;
	}

	get imageLegacy():string{
		return setup.outfitItemImagePath.clothes[this.vendor][this.subtype].formatUnicorn({id:this.index});
	}

	get inhibition(){
		return this.inhib;
	}

	get slots(){
		return ['bra','panties','clothes'];
	}
}

setup.OutfitItem = OutfitItem;