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

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

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

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

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

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

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

	$RESULT += '<TD><a href="exec:defaultcoat = ''<<i>>'' & gt ''cloakroom'', ''view_coat_list''">Select</a></TD>'

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

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

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

if $ARGS[0] = 'dest1':
	*clr
	dynamic '<<$ARGS[1]>>S[<<ARGS[2]>>] = 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.</a>'
	else
		'<center>You will wear Coat<<defaultcoat>> when a coat is required.</a>'
	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, 'coat', i)
		i += 1
	if i <= 12: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 type
	!! ARGS 2 - clothing index

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


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


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

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

