# coats
!!2021/04/15
!!gs 'coats', 'remove'
!!To remove coat and store them
!!gs 'coats', 'wear', 'type', 'number'
!!To wear coat - There is no previous worn stored as this is only specified through cloakroom/wardrobe

menu_off = 1

if $ARGS[0] = 'remove':
	$coatworntype = 'none'
	coatwornnumber = 0
	killvar 'PCoatWarm'
	killvar 'PCoatQuality'
end

if $ARGS[0] = 'wear':
	if $ARGS[1] = 'last_worn':
		$coatworntype = $lastworncoattype
		coatwornnumber = lastworncoatnumber
	else
		$coatworntype = $ARGS[1]
		coatwornnumber = ARGS[2]
	end

	gs 'coat_attributes', $ARGS[1], ARGS[2]
	PCoatWarm = CoatWarm
	PCoatQuality = CoatQuality

	dynamic $ARGS[1] + '_w[<<ARGS[2]>>] = 1'
end

if $ARGS[0] = 'view_coat_list':
	!! ARGS 0 - view_coat_list
	!! ARGS 1 - action type (clean, dirty, store, bathroom, wardrobe)


	act 'Return': 
		if $ARGS[1] = 'wardrobe':
			gt 'wardrobe', 'main'
		else
			gt $loc, $loc_arg
		end
	end

	if $ARGS[1] = 'wardrobe':
		coat_loc = 0
	end

	if $ARGS[1] = 'store':
		coat_loc = 1
	end

	if $ARGS[1] = 'unwanted':
		coat_loc = 2
	end

	'<center><table border=1><TH><a href="exec:gt ''coats'', ''view_coat_list'', ''wardrobe''">Draw</a></TH><TH><a href="exec:gt ''coats'', ''view_coat_list'', ''store''">Storage</a></TH><TH><a href="exec:gt ''coats'', ''view_coat_list'', ''unwanted''">Unwanted</a></TH></center>'

	if $coatworntype ! 'none':act 'Remove coat':gs 'coats', 'remove' & gt 'coats', 'view_coat_list', $ARGS[1]
	
	if $ARGS[1] = 'store':
		cloc = 1
	end

	if ARRSIZE('gm_coats') > 0:
		'<center><img src="images/locations/city/citycenter/mall/gm.png"></a></center>'

		i = 1
		:loopgmcoat 
		if gm_coats_s[i] = coat_loc and gm_coats[i] = 1:*p '<a href="exec:gt ''coats'', ''view_coat_item'', ''<<$ARGS[1]>>'', ''gm'', <<i>>"><img src="images/pc/items/gm/coats/<<i>>.jpg" 	height="150" /></a>'
		i += 1
		if i <= ARRSIZE('gm_coats'):jump 'loopgmcoat'
	end

	if ARRSIZE('cats_coats') > 0:
		'<center><img src="images/locations/city/citycenter/mall/pussycat.png"></center>'

		i = 1
		:loopcatscoat 
		if cats_coats_s[i] = coat_loc and cats_coats[i] = 1:*p '<a href="exec:gt ''coats'', ''view_coat_item'', ''<<$ARGS[1]>>'', ''cats'', <<i>>"><img src="images/pc/items/cats/coats/<<i>>.jpg" 	height="150" /></a>'
		i += 1
		if i <= ARRSIZE('cats_coats'):jump 'loopcatscoat'
	end

	if ARRSIZE('moncheri_coats') > 0:
		'<center><img src="images/locations/city/citycenter/mall/moncheri.png"></center>'

		i = 1
		:loopmonchericoat 
		if moncheri_coats_s[i] = coat_loc and moncheri_coats[i] = 1:*p '<a href="exec:gt ''coats'', ''view_coat_item'', ''<<$ARGS[1]>>'', ''moncheri'', <<i>>"><img src="images/pc/items/moncheri/coats/<<i>>.jpg" 	height="150" /></a>'
		i += 1
		if i <= ARRSIZE('moncheri_coats'):jump 'loopmonchericoat'
	end

	if ARRSIZE('dolls_coats') > 0:
		'<center><img src="images/locations/city/island/dolls/shop_name.png"></center>'

		i = 1
		:loopdollscoat 
		if dolls_coats_s[i] = coat_loc and dolls_coats[i] = 1:*p '<a href="exec:gt ''coats'', ''view_coat_item'', ''<<$ARGS[1]>>'', ''dolls'', <<i>>"><img src="images/pc/items/dolls/coats/<<i>>.jpg" 	height="150" /></a>'
		i += 1
		if i <= ARRSIZE('dolls_coats'):jump 'loopdollscoat'
	end

	if ARRSIZE('bomba_coats') > 0:
		'<center><img src="images/locations/pushkin/bomba/shop_name.png"></center>'

		i = 1
		:loopbombacoat 
		if bomba_coats_s[i] = coat_loc and bomba_coats[i] = 1:*p '<a href="exec:gt ''coats'', ''view_coat_item'', ''<<$ARGS[1]>>'', ''bomba'', <<i>>"><img src="images/pc/items/bomba/coats/<<i>>.jpg" 	height="150" /></a>'
		i += 1
		if i <= ARRSIZE('bomba_coats'):jump 'loopbombacoat'
	end

	if ARRSIZE('danilovich_coats') > 0:
		'<center><img src="images/locations/city/citycenter/mall/sports.png"></center>'

		i = 1
		:loopdanilovichcoat 
		if danilovich_coats_s[i] = coat_loc and danilovich_coats[i] = 1:*p '<a href="exec:gt ''coats'', ''view_coat_item'', ''<<$ARGS[1]>>'', ''danilovich'', <<i>>"><img src="images/pc/items/danilovich/coats/<<i>>.jpg" 	height="150" /></a>'
		i += 1
		if i <= ARRSIZE('danilovich_coats'):jump 'loopdanilovichcoat'
	end
end

if $ARGS[0] = 'view_coat_item':
	!! ARGS 0 - view_coat_item
	!! ARGS 1 = action type (draw, shop)
	!! ARGS 2 - coat type
	!! ARGS 3 - coat index
	!! ARGS 4 - price for shop
	cla
	'<center><img src="<<FUNC(''$coat_image'',  $ARGS[2], ARGS[3])>>"></center>'
	gs 'coat_attributes', $ARGS[2], ARGS[3]

	$coat_description

	if $ARGS[1] = 'shop':
		if dyneval('RESULT = <<$ARGS[2]>>_coats[<<ARGS[3]>>]') = 1:
			'You already own this item.'
			act 'Leave': gt $loc, $loc_arg
		else
			price = ARGS[4]
			'Price: <<ARGS[4]>> <b>₽</b>'
			act 'Leave': gt $loc, $loc_arg
			if money >= price:
				act 'Buy (cash)':
					money -= price
					dynamic $ARGS[2] + '_coats[<<ARGS[3]>>] = 1'
					dynamic $ARGS[2] + '_coats_s[<<ARGS[3]>>] = 0'
					dynamic $ARGS[2] + '_coats_h[<<ARGS[3]>>] = 240'
					gt $loc, $loc_arg
				end
			else
				'You do not have enough cash to buy these coat.'
			end
			if karta + bankDebtLimit >= price:
				act 'Buy (card)':
					karta -= price
					dynamic $ARGS[2] + '_coats[<<ARGS[3]>>] = 1'
					dynamic $ARGS[2] + '_coats_s[<<ARGS[3]>>] = 0'
					dynamic $ARGS[2] + '_coats_h[<<ARGS[3]>>] = 240'
					gt $loc, $loc_arg
				end
			else
				'You do not have enough money in your bank to buy these coat.'
			end
		end
	else
		if $ARGS[1] ! 'bathroom':
			if coat_loc ! 1:$RESULT += 'Move these coat to <a href="exec:gt ''coats'', ''dest1'', ''<<$ARGS[1]>>'', ''<<$ARGS[2]>>'', <<ARGS[3]>>">Storage</a><BR>'
			if coat_loc ! 0:$RESULT += 'Move these coat to  <a href="exec:gt ''coats'', ''dest0'', ''<<$ARGS[1]>>'', ''<<$ARGS[2]>>'', <<ARGS[3]>>">Wardrobe</a><BR>'
			if coat_loc ! 2:$RESULT += 'Move these coat to  <a href="exec:gt ''coats'', ''dest2'', ''<<$ARGS[1]>>'', ''<<$ARGS[2]>>'', <<ARGS[3]>>">Unwanted</a>'
		end
		
		act 'Return':gt 'coats', 'view_coat_list', $ARGS[1]
		
		if $ARGS[1] = 'store':
			'These coat are in storage.'
		elseif $ARGS[1] = 'unwanted':
			'These coat are unwanted.'
		else
			if $coatworntype = $ARGS[2] and coatwornnumber = ARGS[3]:
				'You are wearing this coat.'
			else
				if coat_loc = 0:
					act 'Wear':
						gs 'coats', 'wear', $ARGS[2], ARGS[3]

						if $ARGS[1] = 'wardrobe':
							gt 'wardrobe', 'main'
						else
							gt $loc, $loc_arg
						end
					end
				end
			end
		end
		if $ARGS[1] ! 'store':
			act 'Move to storage': gt 'coats', 'dest1', $ARGS[1], $ARGS[2], ARGS[3]
		end
		if $ARGS[1] ! 'unwanted':
			act 'Move to unwanted': gt 'coats', 'dest2', $ARGS[1], $ARGS[2], ARGS[3]
		end
		if $ARGS[1] ! 'wardrobe':
			act 'Move to wardrobe': gt 'coats', 'dest0', $ARGS[1], $ARGS[2], ARGS[3]
		end
	end
end

if $ARGS[0] = 'dest0':
	*clr
	dynamic '<<$ARGS[2]>>_coats_s[<<ARGS[3]>>] = 0'
	gt 'coats', 'view_coat_item', $ARGS[1], $ARGS[2], ARGS[3]
end

if $ARGS[0] = 'dest1':
	*clr
	dynamic '<<$ARGS[2]>>_coats_s[<<ARGS[3]>>] = 1'
	gt 'coats', 'view_coat_item', $ARGS[1], $ARGS[2], ARGS[3]
end

if $ARGS[0] = 'dest2':
	*clr
	dynamic '<<$ARGS[2]>>_coats_s[<<ARGS[3]>>] = 2'
	gt 'coats', 'view_coat_item', $ARGS[1], $ARGS[2], ARGS[3]
end

--- coats ---------------------------------

