# cloakroom
$coat_list_line = {
	!! a single line in a clothing list (wardrobe, etc)
	!! ARGS 0 - clothing index

	$bgcolor = iif($bgcolor='#f3f4ee','#ffffff','#f3f4ee')

	$RESULT = '<TR bgcolor='+$bgcolor+'>'

	$RESULT +='<TD><a href="exec:gt ''clothing'', ''view_clothing_item'', ''wardrobe'', ''coat'', <<ARGS[0]>>"><img <<$set_imgh>> src="<<FUNC(''$clothing_image'', ''coat'', ARGS[0])>>" width="75"></a></TD>'

	$RESULT += '<TD>coat no.<<ARGS[0]>> (strength ' + dyneval '$RESULT += coatH[<<ARGS[0]>>]'+')</TD>'

	$RESULT += '<TD>' + FUNC('$clothing_name', 'coat', ARGS[0]) + '</TD>'

	$RESULT += '<TD><a href="exec:gt ''cloakroom'', ''view_coat_item'', <<ARGS[0]>>">View</a></TD>'

	if coatH[i] > 0:
		$RESULT += '<TD><a href="exec:defaultcoat = ''<<i>>'' & gt ''cloakroom'', ''view_coat_list''">Select</a></TD>'
	end

	$RESULT += '<TD>'
	if i = defaultcoat:
		$RESULT += '<font color="navy">Yes</font>'
	end
	$RESULT += '</TD>'

	$RESULT += '<TD>'
	if dyneval('RESULT = coatS[<<ARGS[0]>>]') = 0:$RESULT += ' <a href="exec:gt ''cloakroom'', ''dest'', <<ARGS[0]>>">Keep</a>'
	if dyneval('RESULT = coatS[<<ARGS[0]>>]') = 2:$RESULT += ' <a href="exec:gt ''cloakroom'', ''dest1'', <<ARGS[0]>>">Unwanted</a>'
	$RESULT += '</TD>'}

if $ARGS[0] = 'dest':
	*clr
	dynamic 'coatS[<<ARGS[1]>>] = 2'
	gt 'cloakroom', 'view_coat_list'
end

if $ARGS[0] = 'dest1':
	*clr
	dynamic 'coatS[<<ARGS[1]>>] = 0'
	gt 'cloakroom', 'view_coat_list'
end

if $ARGS[0] = 'view_coat_list':

	'<center><table border=1><TH>Cloakroom</TH></table></center>'

	if defaultcoat = 0:
		'<center>You have not chosen a coat to wear.</center>'
	else
		'<center>You will wear Coat<<defaultcoat>> when a coat is required.</center>'
	end

	$bgcolor='#f3f4ee'
	
	'<table><table border=0 cellspacing=0 cellpadding=5><TH></TH><TH>Item no.</TH><TH>Description</TH><TH>Large image</TH><TH>Set as default</TH><TH>Default</TH><TH>Set for sale</TH>'

	i = 1
	:loopcoat
		if coat[i] = 1:*p dyneval($coat_list_line, i)
		i += 1
	if i <= 19:jump 'loopcoat'
	
	act 'Don''t wear a coat':defaultcoat = 0

	'</table>'

	act 'Leave':gt $loc, $metka

end

if $ARGS[0] = 'view_coat_item':
	!! ARGS 0 - view_clothing_item
	!! ARGS 1 - clothing index

	cla
	'<center><img <<$set_imgh>> src="<<FUNC(''$clothing_image'', ''coat'', ARGS[1])>>"></center>'
	'coat no.<<ARGS[1]>>'
	FUNC('$attributes_coat', coat, ARGS[1])
	FUNC('$clothing_name', coat, ARGS[1])


	$RESULT = '(strength '
	dynamic '$RESULT += coatH[<<ARGS[1]>>]'
	$RESULT += ')'
	'<<$RESULT>>'


	act 'Return':gt 'cloakroom', 'view_coat_list'
	!! if the clothing is worn out
	if dyneval('RESULT = coatH[<<ARGS[1]>>]') <= 0:
		'This item is worn and is not suitable for further wear.'
		act 'Throw it away':
			dynamic 'coat[<<ARGS[1]>>] = 0'
			gt 'cloakroom', 'view_coat_list', 'coat'
		end
	end
	if defaultcoat ! '<<ARGS[1]>>':
		act 'Set as default':
			defaultcoat = '<<ARGS[1]>>'
		end
	end
end

--- cloakroom ---------------------------------

