# agentned

if $ARGS[0] = 'start':
	CLOSE ALL
	
	*clr & cla
	$loc = $curloc
	$metka = $ARGS[0]
	$location_type = 'indoors'
	$menu_loc = 'agentned'
	$menu_arg = 'start'
	menu_off = 0
	
	gs'stat'
	gs'dina'
	gs 'housing', 'rent'
	'<center><b><font color = maroon>Kirsanova Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
	*nl
	'This is the head office of the largest real estate agency in the Leningrad Oblast.'
	*nl
	'At the reception you notice a large print banner,'
	'"Please be aware that all sales transactions are made exclusively through your bank account. Rent payments excluded from this policy."'

	if home_owned[1] = 1 and ArendHouseSL > 0:
		*nl
		'You have <B><<ArendHouseSL>> days</B> rental on your St. Petersburg apartment remaining. '+iif(money >= home_rent[1],'You can make a rent <a href="exec:money -= home_rent[1] & home_owned[1] = 1 & ArendHouseSL += ArendHouseSL_due & gs ''$menu_obnovit''">payment</a> in cash.','You can''t afford to pay your rent at the moment')+''
	end
	if home_owned[4] > 0 and ArendHouseSL4 > 0:
		*nl
		'You have <B><<ArendHouseSL4>> days</B> rental on your Pushkin apartment. '+iif(money >= home_rent[4],'You can make a rent <a href="exec:money -= home_rent[4] & home_owned[1] = 1 & ArendHouseSL4 += ArendHouseSL_due & gs ''$menu_obnovit''">payment</a> in cash.','You can''t afford to your pay rent at the moment')+''
	end

	if home_owned[1] = 2 or home_owned[3] > 0 or home_owned[5] = 1:
		*nl
		'You own the following property:'
		*nl
		if home_owned[1] = 2: 'An apartment in St. Petersburg residential area'
		if home_owned[1] = 3: 'An apartment in St. Petersburg residential area which is currently occupied by your tenants'
		if home_owned[3] > 0: 'An cottage located in the cooperative village'
		if home_owned[5] = 1: 'A plot of land in the St. Petersburg suburbs'
		*nl
		'We are at your service if you decide to <a href="exec:gt ''agentned'',''sell''">sell</a>.'
	end

	act 'Leave': minut += 5 & gt 'city_center'
	
	act 'View rentals': gt 'agentned', 'rent'
	act 'View properties for sale': gt 'agentned', 'buy'
	if (home_owned[1] = 1 or home_owned[1] = 2) and home_owned[4] = 1: 
		if home_owned[1] = 1:
			act 'Cancel the lease of the city apartment':
				cla & *nl
				'Attention: You won''t be able to return to your apartment when you cancel the lease.'
				
				act 'Return': gt'agentned', 'start'
				act 'Cancel it': home_owned[1] = 0 & gs 'set_home', 4 & gt'agentned', 'start'
			end
		end
		act 'Cancel the lease of the apartment in Pushkin':
			cla & *nl
			'Attention: You won''t be able to return to your apartment when you cancel the lease.'
			
			act 'Return': gt'agentned', 'start'
			act 'Cancel it': home_owned[4] = 0 & gs 'set_home', 1 & gt'agentned', 'start'		
		end
	end
end

if $ARGS[0] = 'buy':
	*clr & cla
	$loc = $curloc
	$metka = $ARGS[0]
	$location_type = 'indoors'
	$menu_loc = 'agentned'
	$menu_arg = 'buy'
	menu_off = 0
	gs 'housing', 'sale'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
	*nl
	minut += 5
	gs 'stat'
	
	act 'Return':gt'agentned', 'start'
	
	if home_owned[1] = 0 or home_owned[3] = 0 or home_owned[4] = 0 or home_owned[5] = 0:
		if home_owned[1] = 0:
			'There is an apartment in the city residential area available for <<$home_value_txt[1]>> <b>₽</b>.'
			*nl
			if karta + bankDebtLimit >= home_value[1]:act 'Buy the city residential apartment': gt 'agentned', 'buy_cityres'
		elseif home_owned[1] = 1:
			'You could buy your current rental apartment for <<$home_value_txt[1]>> <b>₽</b>.'
			*nl
			if karta + bankDebtLimit >= home_value[1]:act 'Buy the city residential apartment': gt 'agentned', 'buy_cityres'
		end

		if home_owned[3] = 0:
			'There is a holiday cottage with an adjacent allotment in the village for <<$home_value_txt[3]>> <b>₽</b>.'
			*nl
			if karta + bankDebtLimit >= home_value[3]:act 'Buy the cottage in the village': gt 'agentned','buy_dacha'
		end

		if home_owned[5] = 0:
			'There is a plot of land in the suburbs with planning permission for a mansion for <<$home_value_txt[5]>> <b>₽</b>.'
			*nl
			if karta + bankDebtLimit >= home_value[5]:act 'Buy the land plot in the suburbs': gt 'agentned','buy_Mansion'
		end
	else
		'We currently have no properties listed for sale.'
	end
end

if $ARGS[0] = 'sell':
	*clr & cla
	$loc = $curloc
	$metka = $ARGS[0]
	$location_type = 'indoors'
	$menu_loc = 'agentned'
	$menu_arg = 'sell'
	menu_off = 0
	gs 'housing', 'sale'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
	*nl
	
	act 'Return':gt'agentned', 'start'
	
	if home_owned[1] = 2 and rembedr = 1 and remsitr = 1 and remkorr = 1 and remvanr = 1 and remkuhr = 1:
		!Renovated city residential apartment
		home_value1 = ((home_value[1] + 250000) + rand(-100000, 100000)) 
		'We have found a buyer for your renovated apartment in the city residential area. They will offer <<home_value1>> <b>₽</b>, minus 5% for fees and taxes, bringing the total to <<home_value1/100*95>>'
		act 'Sell the renovated apartment':
			*clr
			menu_off = 1
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			minut += 30
			'You spend thirty minutes filling out the paperwork for the sale of your renovated apartment. You will suffer a loss of around 5% for fees and taxes. <<home_value1/100*95>> <b>₽</b> has been paid into your bank account.'
			home_owned[1] = 0
			ArendHouseSL = 0
			if bankaccount = 1:
				karta += home_value1/100*95
			else
				money += home_value1/100*95
			end
			delact 'Sell the renovated apartment'
			gs 'stat'
		end
	end
	if home_owned[1] = 2:
		!City residential apartment
		home_value1 = (home_value[1] + rand(-100000, 100000))
		'We have found a buyer for your apartment in the city residential area. They will offer <<home_value1>> <b>₽</b>, minus 5% for fees and taxes, bringing the total to <<home_value1/100*95>>'
		act 'Sell the city apartment':
			*clr
			menu_off = 1
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			minut += 30
			'You spend thirty minutes filling out the paperwork for the sale of your apartment. You will suffer a loss of around 5% for fees and taxes. <<home_value1/100*95>> <b>₽</b> has been paid into your bank account.'
			home_owned[1] = 0
			ArendHouseSL = 0
			if bankaccount = 1:
				karta += home_value1/100*95
			else
				money += home_value1/100*95
			end
			delact 'Sell the city apartment'
			gs 'stat'
		end
	end
	if home_owned[3] = 1:
		!Communal cottage
		home_value3 = (home_value[3] + rand(-5000, 5000))
		'We have found a buyer for your small communal cottage. They will offer <<home_value3>> <b>₽</b>, minus 5% for fees and taxes, bringing the total to <<home_value3/100*95>>'
		act 'Sell the holiday cottage':
			*clr
			menu_off = 1
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			minut += 30
			'You spend thirty minutes filling out the paperwork for the sale of your small cottage. You will suffer a loss of around 5% for fees and taxes. <<home_value3/100*95>> <b>₽</b> has been paid into your bank account.'
			home_owned[3] = 0
			if bankaccount = 1:
				karta += home_value3/100*95
			else
				money += home_value3/100*95
			end
			delact 'Sell the holiday cottage'
			gs 'stat'
		end
	end
	if home_owned[3] = 2:
		!Renovated communal cottage
		home_value3 = ((home_value[3] + 200000) + rand(-10000, 10000))
		'We have found a buyer for your small renovated communal cottage. They will offer <<home_value3>> <b>₽</b>, minus 5% for fees and taxes, bringing the total to <<home_value3/100*95>>'
		act 'Sell the renovated cottage':
			*clr
			menu_off = 1
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			minut += 30
			'You spend thirty minutes filling out the paperwork for the sale of your small cottage. You will suffer a loss of around 5% for fees and taxes. <<home_value3/100*95>> <b>₽</b> has been paid into your bank account.'
			home_owned[3] = 0
			if bankaccount = 1:
				karta += home_value3/100*95
			else
				money += home_value3/100*95
			end
			delact 'Sell the renovated cottage'
			gs 'stat'
		end
	end
	if home_owned[5] = 1:
		!Suburban land only - currently too many variables for selling upgraded mansion - might do later - 3xpurt.
		home_value5 = (home_value[5] + rand(-50000, 50000))
		'We have found a buyer for your vacant plot of land in the suburbs. They will offer <<home_value5>> <b>₽</b>, minus 5% for fees and taxes, bringing the total to <<home_value5/100*95>>'
		act 'Sell the vacant plot':
			*clr
			menu_off = 1
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			minut += 30
			'You spend thirty minutes filling out the paperwork for the vacant plot. You will suffer a loss of around 5% for fees and taxes. <<home_value5/100*95>> <b>₽</b> has been paid into your bank account.'
			home_owned[5] = 0
			if bankaccount = 1:
				karta += home_value5/100*95
			else
				money += home_value5/100*95
			end
			delact 'Sell the vacant plot'
			gs 'stat'
		end
	end
	if home_owned[5] = 2:
		!Suburban land only - currently too many variables for selling upgraded mansion - might do later - 3xpurt.
		'Sorry, we are unable to find a buyer for your property at this time.'
	end
	if home_owned[5] = 3:
		!Suburban land only - currently too many variables for selling upgraded mansion - might do later - 3xpurt.
		'Sorry, we are unable to find a buyer for your property at this time.'
	end
	if home_owned[1] = 0 and home_owned[3] = 0 and home_owned[4] = 0 and home_owned[5] = 0:
		'You don''t currently own any property.'
	end
end

if $ARGS[0] = 'rent':
	*clr & cla
	$loc = $curloc
	$metka = $ARGS[0]
	$location_type = 'indoors'
	$menu_loc = 'agentned'
	$menu_arg = 'rent'
	menu_off = 0
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
	*nl
	minut += 5
	gs 'stat'
	
	act 'Return':gt'agentned', 'start'
	
	if home_owned[1] > 0 and home_owned[4] > 0:
		'We currently have no properties listed for rent.'
	elseif home_owned[1] = 0 and home_owned[4] = 0:
		*nl
		'There are two properties available for rent.'
		*nl
		'There are two apartments for available to rent. They are located in the city residential area and in Pushkin.'
		act 'View the city apartment details': gt 'agentned', 'rent_cityres'
		act 'View the Pushkin apartment details': gt 'agentned', 'rent_pushkin'
	elseif home_owned[1] = 0:
		'There is a property for rent in the city residential area'
		act 'View the city apartment details': gt 'agentned', 'rent_cityres'
	elseif home_owned[4] = 0:
		'There is a property for rent in the old town of Pushkin'
		act 'View the Pushkin apartment details': gt 'agentned', 'rent_pushkin'
	end
end

if $ARGS[0] = 'rent_cityres':
	*clr & cla
	menu_off = 1
	gs 'housing', 'rent'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
	*nl
	'"We have a flat available right now in the St. Petersburg residential area." The receptionist says as he starts pulling out the paperwork, "Rent is <<$home_rent_txt[1]>> ₽ and leases have to be renewed every 30 days. Payment will be automatically deducted from your account or you can come into the office to pay. When you sign for the lease you must make your first month''s rental payment upfront."'
	'<br>He pulls out a pen and slides the paperwork onto the counter. "Interested? You can move in right away," he calmly says.'

	if money >= home_rent[1] or karta >= home_rent[1]:
		act 'Agree and pay':
			*clr & cla
			cls
			minut += 30
			if money >= home_rent[1]: 
				money -= home_rent[1]
			else
				karta -= home_rent[1]
			end
			home_owned[1] = 1
			if ARRSIZE('home_owned') = 0:
				gs 'set_home', 1
			else
				$set_homeyn = input("Would you like to set this as your new home? (yes/no)")
				if $set_homeyn = 'yes': gs 'set_home', 1
				killvar '$set_homeyn'
			end
			ArendHouseSL += ArendHouseSL_due
			gs'stat'
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			*nl
			'You take the pen then start filling out the paperwork. After writing for half an hour, you hand over the money and receive the keys to your new apartment.'

			act 'Return':gt'agentned', 'start'
		end
	else
		*nl
		'You do not have enough money with you or in your bank account to pay the rent.'
	end
	
	act 'Decline':
		*clr & cla
		minut += 5
		'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
		'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
		*nl
		'You shake your head, "Actually, I need more time to think about this."'
		'<br>The receptionist seems a bit miffed, but says nothing as he takes back the paperwork and stuffs it back into his desk drawer.'

		act 'Return':gt'agentned', 'start'
	end
end

if $ARGS[0] = 'rent_pushkin':
	*clr & cla
	menu_off = 1
	gs 'housing', 'rent'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
	*nl
	'"We have a small apartment available right now that is in Pushkin’s city center. It’s a little bit pricey, but it’s been recently renovated to be more modern. It looks quite nice, so you won’t find a place like that outside of Pushkin." The receptionist says as he starts pulling out the paperwork. "Rent is <<$home_rent_txt[4]>> ₽ and leases have to be renewed every 30 days, which can be taken automatically from your account or you can come in and pay directly. Last, but not least, you have to make your first payment up front at signing."'
	'<br>He pulls out a pen and slides the paperwork onto the counter. "Interested? You can move in right away," he calmly says.'
	
	if money >= home_rent[4] or karta >= home_rent[4]:
		act 'Agree and pay':
			*clr & cla
			minut += 30
			if money >= home_rent[4]: 
				money -= home_rent[4]
			else
				karta -= home_rent[4]
			end
			home_owned[4] = 1
			if ARRSIZE('home_owned') = 0:
				gs 'set_home', 4
			else
				$set_homeyn = input("Would you like to set this as your new home? (yes/no)")
				if $set_homeyn = 'yes': gs 'set_home', 4
				killvar '$set_homeyn'
			end
			ArendHouseSL4 += ArendHouseSL_due
			gs'stat'
			'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
			'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
			*nl
			'You take the pen and start filling out the paperwork. After writting for an hour, you hand over the money and receive the keys to your new apartment.'

			act 'Return':gt'agentned', 'start'
		end
	else
		*nl
		'You do not have enough money with you or in your bank account to rent this.'
	end
	
	act 'Decline':
		*clr & cla
		minut += 5
		gs 'stat'
		'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
		'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo.jpg"></center>'
		*nl
		'You shake your head, "Actually, I need more time to think about this."'
		'<br>The receptionist seems a bit miffed, but says nothing as he takes back the paperwork and stuffs it back into his desk drawer.'

		act 'Return':gt'agentned', 'start'
	end
end

if $ARGS[0] = 'buy_cityres':
	*clr & cla
	menu_off = 1
	gs 'housing', 'sale'
	minut += 30
	karta -= home_value[1]
	home_owned[1] = 2
	if ARRSIZE('home_owned') = 0:
		gs 'set_home', 1
	else
		$set_homeyn = input("Would you like to set this as your new home? (yes/no)")
		if $set_homeyn = 'yes': gs 'set_home', 1
		killvar '$set_homeyn'
	end
	gs'stat'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
	*nl
	'You spend half an hour filling in the paperwork to buy the apartment in the residential area. <<$home_value_txt[1]>> <b>₽</b> has been removed from your bank account.'

	act 'Return':gt'agentned', 'start'
end

if $ARGS[0] = 'buy_dacha':
	*clr & cla
	menu_off = 1
	gs 'housing', 'sale'
	minut += 30
	karta -= home_value[3]
	home_owned[3] = 1
	if ARRSIZE('home_owned') = 0:
		gs 'set_home', 3
	else
		$set_homeyn = input("Would you like to set this as your new home? (yes/no)")
		if $set_homeyn = 'yes': gs 'set_home', 3
		killvar '$set_homeyn'
	end
	etoexhib = 0
	gs'stat'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
	*nl
	'You spend half an hour filling in the paperwork for the purchase of a cottage with a garden in the co-op. It''s located 5km away from St. Petersburg. <<$home_value_txt[3]>> <b>₽</b> has been removed from your bank account.'

	act 'Return':gt'agentned', 'start'
end

if $ARGS[0] = 'buy_Mansion':
	*clr & cla
	menu_off = 1
	gs 'housing', 'sale'
	minut += 30
	karta -= home_value[5]
	home_owned[5] = 1
	if ARRSIZE('home_owned') = 0:
		gs 'set_home', 5
	else
		$set_homeyn = input("Would you like to set this as your new home? (yes/no)")
		if $set_homeyn = 'yes': gs 'set_home', 5
		killvar '$set_homeyn'
	end
	gs'stat'
	'<center><b><font color = maroon>Real Estate Agency</font></b></center>'
	'<center><img <<$set_imgh>> src="images/locations/city/citycenter/realestate/agenstvo_paperwork.jpg"></center>'
	*nl
	'You spend half an hour filling in the paperwork for the purchase of a lot for building a mansion 1km up the north road. <<$home_value_txt[5]>> <b>₽</b> has been removed from your bank account.'

	act 'Return':gt'agentned', 'start'
end

--- agentned ---------------------------------

