*set on_planet true
*gosub_scene planet_count
*gosub_scene bar bar_names
*gosub_scene bar clothes
*gosub_scene cafe cafe_names
*gosub_scene bookstore library_namer
*gosub_scene wedding_chapel chapel_names
*gosub_scene karaoke karaoke_names



*rand fortune_fee 17 34

*if planet_level = 1
	*set bar_emoji "🏚️"
	
*if planet_level = 2
	*set bar_emoji"🍺"
	
*if planet_level = 3
	*set bar_emoji"🍺"
	
*if planet_level = 4
	*set bar_emoji"🍷"
	
*if planet_level = 5
	*set bar_emoji"🥃"

*label smart
*label start

🛃 [b]${planet_name} Spaceport[/b]

*if planet_level = 1
	*check_achievements
	*if choice_achieved_planet1 = false
		*achieve planet1
	*goto menu1

*if planet_level = 2
	*check_achievements
	*if choice_achieved_planet2 = false
		*achieve planet2
	*goto menu2

*if planet_level = 3
	*check_achievements
	*if choice_achieved_planet3 = false
		*achieve planet3
	*goto menu3

*if planet_level = 4
	*check_achievements
	*if choice_achieved_planet4 = false
		*achieve planet4
	*goto menu4

*if planet_level = 5
	*check_achievements
	*if choice_achieved_planet5 = false
		*achieve planet5
	*goto menu5

*label menu1

*temp dusty ""

*rand dieroll 1 3

*if dieroll = 1
	*set dusty "dusty"
	
*if dieroll = 2
	*set dusty "snowy"
	
*if dieroll = 3
	*set dusty "rainy"

You step out of your ship onto a ${dusty}, windswept tarmac.

*if rp
	${rp_emoji} "Jeez, this planet is a dump."

*gosub passenger_check

*label spaceport1

*if sound
	*sound minewind.mp3

*rand dieroll 27 601

A faded wooden sign reads, "Welcome to ${planet_name}.  Population: ${dieroll}"

In front of you is a large roofed structure, the only significant building in sight.

Off to one corner is a dilapidated wooden shack, a one-room church, and a multicolored tent with a the intergalactic pixograph "✋" scrawled on the front flap.

Nailed to a withered tree is a sign: "Miners Wanted"

[b]::: [/b]What do you want to do?

*fake_choice
	#🎪 Enter the large building
		*goto market
	#${bar_emoji} Enter the shack
		*goto_scene bar
	*selectable_if ((tent_available = true) and (story_mode = false)) #🔮 Enter the tent
		*goto_scene fortune
	#🙏 Enter the church
		*goto_scene wedding_chapel
	#⛏️ Visit the mine
		*goto_scene miner
	#🛫 Leave this planet
		*goto blastoff

*label menu2

You step out of your ship onto a small but neatly furnished spaceport.

*gosub passenger_check

*label spaceport2

*if sound
	*sound spaceport.wav

Along the single corridor of the spaceport is a day bar, from which a strong odor of cigarette smoke wafts.

A few steps beyond in the corridor is door, next to which is a handwritten sign that reads "Asteroid Colonists Employment Office."

At the far end of the corridor is a garishly lit sign that reads "CASINO"

In front of you through the exit, you see an elegant brick building with a large, sloping roof.

[b]::: [/b]What do you want to do, Captain?

*fake_choice
	#🎪 Exit the spaceport and enter the large building
		*goto market
	#${bar_emoji} Enter the day bar
		*goto_scene bar
	*selectable_if (story_mode = false) #🎰 Go to the casino
		*goto_scene casino
	#🧗 Enter the employment office
		*goto_scene colonists_hire
	#🛫 Leave this planet
		*goto blastoff

*label menu3

You step out of your ship into a small but bustling spaceport.

*gosub passenger_check

*label spaceport3

*if sound
	*sound spaceport.wav

Inside the spaceport, you see signs advertising a bar, a café, a karaoke club, a dice parlor, and a wedding chapel.

In front of you through the exit, you see a large industrial building with a steel-trussed roof.

[b]::: [/b]What do you want to do?

*fake_choice
	#🎪 Exit the spaceport and enter the large building
		*goto market
	#${bar_emoji} Enter the bar
		*goto_scene bar
	#☕ Visit the café
		*goto_scene cafe
	*selectable_if ((sound = true) and (story_mode = false)) #🎤 Go to the karaoke club
		*goto_scene karaoke
	*selectable_if (story_mode = false) #🎲 Enter the dice parlor
		*goto_scene dice
	#💒 Enter the wedding chapel
		*goto_scene wedding_chapel
	#🛫 Leave this planet
		*goto blastoff
	
*label menu4

You step out of your ship into a large, fully modern spaceport.

*gosub passenger_check

*label spaceport4

*if sound
	*sound spaceport.wav

Flashing lights and rotating video screens announce a host of different offerings in the spaceport, including a pub, a café, and a bookstore.

Directional signs above say "To Market" and point to an elegant, modern building that you can just glimpse sitting across from the spaceport.

[b]::: [/b]What do you want to do?

*fake_choice
	#🎪 Exit the spaceport and go to the market
		*goto market
	#${bar_emoji} Go to the pub
		*goto_scene bar
	#☕ Go to the café
		*goto_scene cafe
	*selectable_if (story_mode = true) #📚 Go to the bookstore
		*goto_scene bookstore
	#🛫 Leave this planet
		*goto blastoff

*label menu5

You step out of your ship into an enormous, gleaming white spaceport.

*gosub passenger_check

*label spaceport5

*if sound
	*sound spaceport.wav

Colorful messages are rotating and sliding across the walls of the spaceport, advertising a diverse arrange of facilities, including a ship recharging station, banking services, a bookstore, an inter-faith facility, a lounge, and an artisanal coffee station.

Intergalactic pixographs above you illuminate a moving walkway that leads directly to the trading market.

[b]::: [/b]What do you want to do?

*fake_choice
	#🎪 Take the walkway to the market
		*goto market
	#${bar_emoji} Step into the lounge
		*goto_scene bar
	#☕ Go to the artisanal coffee station
		*goto_scene cafe
	*selectable_if (story_mode = true) #📚 Go to the bookstore
		*goto_scene bookstore
	#🛐 Go to the inter-faith facility
		*goto_scene wedding_chapel
	#⚡ Get your ship's batteries recharged
		*goto batteries
	#🏦 Visit the bank
		*goto bank
	#🛫 Leave the planet
		*goto blastoff
	
*label market

*if (market_visits = 1) or (market_visits = 11)
	*if sound
		*sound market.mp3
		
*set market_visits + 1

*check_achievements
*if choice_achieved_market_trader = false
	*achieve market_trader

📈 [b]$!!{planet_name} MARKET REPORT[/b]

*rand dieroll 0.8 1.2

*set resource1_sellprice (resource1_sellprice * dieroll)
*set resource2_sellprice (resource2_sellprice * dieroll)
*set resource3_sellprice (resource3_sellprice * dieroll)
*set resource4_sellprice (resource4_sellprice * dieroll)
*set resource5_sellprice (resource5_sellprice * dieroll)
*set resource6_sellprice (resource6_sellprice * dieroll)
*set resource7_sellprice (resource7_sellprice * dieroll)
*set resource8_sellprice (resource8_sellprice * dieroll)
*set resource9_sellprice (resource9_sellprice * dieroll)
*set resource10_sellprice (resource10_sellprice * dieroll)
*set resource11_sellprice (resource11_sellprice * dieroll)

*set resource1_sellprice round(resource1_sellprice)
*set resource2_sellprice round(resource2_sellprice)
*set resource3_sellprice round(resource3_sellprice)
*set resource4_sellprice round(resource4_sellprice)
*set resource5_sellprice round(resource5_sellprice)
*set resource6_sellprice round(resource6_sellprice)
*set resource7_sellprice round(resource7_sellprice)
*set resource8_sellprice round(resource8_sellprice)
*set resource9_sellprice round(resource9_sellprice)
*set resource10_sellprice round(resource10_sellprice)
*set resource11_sellprice round(resource11_sellprice)

[b]For sale[/b]:
*line_break
*if resource1_level > 1
	$!{resource1}: ${resource1_level} units (¢${resource1_sellprice}/unit)
	*line_break
*if resource1_level = 1
	$!{resource1}: ${resource1_level} unit (¢${resource1_sellprice})
	*line_break
*if resource2_level > 1
	$!{resource2}	: ${resource2_level} units (¢${resource2_sellprice}/unit)
	*line_break
*if resource2_level = 1
	$!{resource2}	: ${resource2_level} unit (¢${resource2_sellprice})
	*line_break
*if resource3_level > 1
	$!{resource3}: ${resource3_level} units	 (¢${resource3_sellprice}/unit)
	*line_break
*if resource3_level = 1
	$!{resource3}: ${resource3_level} unit	 (¢${resource3_sellprice})
	*line_break
*if resource4_level > 1
	$!{resource4} : ${resource4_level} units (¢${resource4_sellprice}/unit)
	*line_break
*if resource4_level = 1
	$!{resource4} : ${resource4_level} unit (¢${resource4_sellprice})
	*line_break
*if resource5_level > 1
	$!{resource5}: ${resource5_level} units	 (¢${resource5_sellprice}/unit)
	*line_break
*if resource5_level = 1
	$!{resource5}: ${resource5_level} unit	 (¢${resource5_sellprice})
	*line_break
*if resource6_level > 1
	$!{resource6}: ${resource6_level} units (¢${resource6_sellprice}/unit)
	*line_break
*if resource6_level = 1
	$!{resource6}: ${resource6_level} unit (¢${resource6_sellprice})
	*line_break
*if resource7_level > 1
	$!{resource7}: ${resource7_level} units (¢${resource7_sellprice}/unit)
	*line_break
*if resource7_level = 1
	$!{resource7}: ${resource7_level} unit (¢${resource7_sellprice})
	*line_break
*if resource8_level > 1
	$!{resource8}: ${resource8_level} units (¢${resource8_sellprice}/unit)
	*line_break
*if resource8_level = 1
	$!{resource8}: ${resource8_level} unit (¢${resource8_sellprice})
	*line_break
*if resource9_level > 1
	$!{resource9}: ${resource9_level} units (¢${resource9_sellprice}/unit)
	*line_break
*if resource9_level = 1
	$!{resource9}: ${resource9_level} unit (¢${resource9_sellprice})
	*line_break
*if resource10_level > 1
	$!{resource10} : ${resource10_level} units (¢${resource10_sellprice}/unit)
	*line_break
*if resource10_level = 1
	$!{resource10} : ${resource10_level} unit (¢${resource10_sellprice})
	*line_break
*if resource11_level > 1
	$!{resource11}: ${resource11_level} cubes (¢${resource11_sellprice}/cube)
*if resource11_level = 1
	$!{resource11}: ${resource11_level} cube (¢${resource11_sellprice})
	
[b]Want to buy[/b]:
*line_break
*if (resource1_buyprice > 0) and (resource1_buyvolume > 1)
	$!{resource1}: ${resource1_buyvolume} units (¢${resource1_buyprice}/unit)
	*line_break
*if (resource1_buyprice > 0) and (resource1_buyvolume = 1)
	$!{resource1}: ${resource1_buyvolume} units (¢${resource1_buyprice})
	*line_break
*if (resource2_buyprice > 0) and (resource2_buyvolume > 1)
	$!{resource2}	: ${resource2_buyvolume} units (¢${resource2_buyprice}/unit)
	*line_break
*if (resource2_buyprice > 0) and (resource2_buyvolume = 1)
	$!{resource2}	: ${resource2_buyvolume} unit (¢${resource2_buyprice})
	*line_break
*if (resource3_buyprice > 0) and (resource3_buyvolume > 1)
	$!{resource3}: ${resource3_buyvolume} units	 (¢${resource3_buyprice}/unit)
	*line_break
*if (resource3_buyprice > 0) and (resource3_buyvolume = 1)
	$!{resource3}: ${resource3_buyvolume} unit (¢${resource3_buyprice})
	*line_break
*if (resource4_buyprice > 0) and (resource4_buyvolume > 1)
	$!{resource4} : ${resource4_buyvolume} units (¢${resource4_buyprice}/unit)
	*line_break
*if (resource4_buyprice > 0) and (resource4_buyvolume = 1)
	$!{resource4} : ${resource4_buyvolume} unit (¢${resource4_buyprice})
	*line_break
*if (resource5_buyprice > 0) and (resource5_buyvolume > 1)
	$!{resource5}: ${resource5_buyvolume} units	 (¢${resource5_buyprice}/unit)
	*line_break
*if (resource5_buyprice > 0) and (resource5_buyvolume = 1)
	$!{resource5}: ${resource5_buyvolume} unit (¢${resource5_buyprice})
	*line_break
*if (resource6_buyprice > 0) and (resource6_buyvolume > 1)
	$!{resource6}: ${resource6_buyvolume} units (¢${resource6_buyprice}/unit)
	*line_break
*if (resource6_buyprice > 0) and (resource6_buyvolume = 1)
	$!{resource6}: ${resource6_buyvolume} unit (¢${resource6_buyprice})
	*line_break
*if (resource7_buyprice > 0) and (resource7_buyvolume > 1)
	$!{resource7}: ${resource7_buyvolume} units (¢${resource7_buyprice}/unit)
	*line_break
*if (resource7_buyprice > 0) and (resource7_buyvolume = 1)
	$!{resource7}: ${resource7_buyvolume} unit (¢${resource7_buyprice})
	*line_break
*if (resource8_buyprice > 0) and (resource8_buyvolume > 1)
	$!{resource8}: ${resource8_buyvolume} units (¢${resource8_buyprice}/unit)
	*line_break
*if (resource8_buyprice > 0) and (resource8_buyvolume = 1)
	$!{resource8}: ${resource8_buyvolume} unit (¢${resource8_buyprice})
	*line_break
*if (resource9_buyprice > 0) and (resource9_buyvolume > 1)
	$!{resource9}: ${resource9_buyvolume} units (¢${resource9_buyprice}/unit)
	*line_break
*if (resource9_buyprice > 0) and (resource9_buyvolume = 1)
	$!{resource9}: ${resource9_buyvolume} unit (¢${resource9_buyprice})
	*line_break
*if (resource10_buyprice > 0) and (resource10_buyvolume > 1)
	$!{resource10} : ${resource10_buyvolume} units (¢${resource10_buyprice}/unit)
	*line_break
*if (resource10_buyprice > 0) and (resource10_buyvolume = 1)
	$!{resource10} : ${resource10_buyvolume} unit (¢${resource10_buyprice})
	*line_break
*if (resource11_buyprice > 0) and (resource11_buyvolume > 1)
	$!{resource11} : ${resource11_buyvolume} cubes (¢${resource11_buyprice}/cube)
*if (resource11_buyprice > 0) and (resource11_buyvolume = 1)
	$!{resource11} : ${resource11_buyvolume} cube (¢${resource11_buyprice})
	
*fake_choice
	#🔻 Buy products
		*goto buy_products
	#🔺 Sell products
		*goto sell_products
	#🚪 Leave the market
		*goto leave_market
	
*label buy_products

*if cargo_space_free = 0
	⚠️ You don't have any room to buy any more cargo.  
	
	Try selling some products or upgrading your ship!
	*page_break Okay
	*goto market

🎪 [b]$!!{planet_name} MARKET[/b]

*if cargo_space_free = 1
	You have ${cargo_space_free} cargo hold free and ¢${credits} available.
	
*if cargo_space_free > 1
	You have ${cargo_space_free} cargo holds free and ¢${credits} available.

[b]:::[/b] Which products do you want to buy?

*temp targetbuy 0
*temp targetprice 0
*temp targetmaxunits 0

*fake_choice
	*selectable_if (resource1_level > 0) #$!{resource1}: (¢${resource1_sellprice}/unit)
		*set targetbuy resource1
		*set targetprice resource1_sellprice
		*set targetmaxunits resource1_level
		*goto buy_units
	*selectable_if (resource2_level > 0) #$!{resource2}: (¢${resource2_sellprice}/unit)
		*set targetbuy resource2
		*set targetprice resource2_sellprice
		*set targetmaxunits resource2_level
		*goto buy_units
	*selectable_if (resource3_level > 0) #$!{resource3}: (¢${resource3_sellprice}/unit)
		*set targetbuy resource3
		*set targetprice resource3_sellprice
		*set targetmaxunits resource3_level
		*goto buy_units
	*selectable_if (resource4_level > 0) #$!{resource4}: (¢${resource4_sellprice}/unit)
		*set targetbuy resource4
		*set targetprice resource4_sellprice
		*set targetmaxunits resource4_level
		*goto buy_units
	*selectable_if (resource5_level > 0) #$!{resource5}: (¢${resource5_sellprice}/unit)
		*set targetbuy resource5
		*set targetprice resource5_sellprice
		*set targetmaxunits resource5_level
		*goto buy_units
	*selectable_if (resource6_level > 0) #$!{resource6}: (¢${resource6_sellprice}/unit)
		*set targetbuy resource6
		*set targetprice resource6_sellprice
		*set targetmaxunits resource6_level
		*goto buy_units
	*selectable_if (resource7_level > 0) #$!{resource7}: (¢${resource7_sellprice}/unit)
		*set targetbuy resource7
		*set targetprice resource7_sellprice
		*set targetmaxunits resource7_level
		*goto buy_units
	*selectable_if (resource8_level > 0) #$!{resource8}: (¢${resource8_sellprice}/unit)
		*set targetbuy resource8
		*set targetprice resource8_sellprice
		*set targetmaxunits resource8_level
		*goto buy_units
	*selectable_if (resource9_level > 0) #$!{resource9}: (¢${resource9_sellprice}/unit)
		*set targetbuy resource9
		*set targetprice resource9_sellprice
		*set targetmaxunits resource9_level
		*goto buy_units
	*selectable_if (resource10_level > 0) #$!{resource10}: (¢${resource10_sellprice}/unit)
		*set targetbuy resource10
		*set targetprice resource10_sellprice
		*set targetmaxunits resource10_level
		*goto buy_units
	*selectable_if (resource11_level > 0) #$!{resource11}: (¢${resource11_sellprice}/cube)
		*set targetbuy resource11
		*set targetprice resource11_sellprice
		*set targetmaxunits resource11_level
		*goto buy_units
	
*label buy_units

🎪 [b]$!!{planet_name} MARKET[/b]

Credits remaining: ¢${credits}
*line_break
📦 Cargo holds available: ${cargo_space_free}

[b]:::[/b] How many units of [b]${targetbuy}[/b] (¢${targetprice}/unit) do you want to buy?

*temp buyunits 0

*input_number buyunits 0 targetmaxunits

*if buyunits = 0
	*if sound
		*sound warningbleep.wav
	[i]Purchase order canceled...[/i]
	
	*goto market

🎪 [b]$!!{planet_name} MARKET[/b]

*check_achievements

*if choice_achieved_buy_badge = false
	*achieve buy_badge

*temp total_price 0
*set total_price (buyunits * targetprice)

*if total_price > credits
	*if sound
		*sound warningbleep.wav
		
	⚠️ You don't have enough credits for that.
	
	Onboard cash balance: ¢${credits}
	*goto market

*if buyunits > cargo_space_free
	*if sound
		*sound warningbleep.wav
		
	⚠️ You don't have enough cargo space to buy that much.
	
	Available cargo space: ${cargo_space_free} units
	*goto market

*set credits - total_price
*set cargo_space_free - buyunits

*if targetbuy = resource1
	*set resource1_carrying + buyunits
	*set resource1_level - buyunits
	
*if targetbuy = resource2
	*set resource2_carrying + buyunits
	*set resource2_level - buyunits
	
*if targetbuy = resource3
	*set resource3_carrying + buyunits
	*set resource3_level - buyunits
	
*if targetbuy = resource4
	*set resource4_carrying + buyunits
	*set resource4_level - buyunits
	
*if targetbuy = resource5
	*set resource5_carrying + buyunits
	*set resource5_level - buyunits
	
*if targetbuy = resource6
	*set resource6_carrying + buyunits
	*set resource6_level - buyunits
	
*if targetbuy = resource7
	*set resource7_carrying + buyunits
	*set resource8_level - buyunits
	
*if targetbuy = resource8
	*set resource8_carrying + buyunits
	*set resource8_level - buyunits
	
*if targetbuy = resource9
	*set resource9_carrying + buyunits
	*set resource9_level - buyunits
	
*if targetbuy = resource10
	*set resource10_carrying + buyunits
	*set resource10_level - buyunits
	
*if targetbuy = resource11
	*set resource11_carrying + buyunits
	*set resource11_level - buyunits

*if buyunits = 1
	✅ You purchased ${buyunits} unit of [b]${targetbuy}[/b] for ¢${total_price}.
	*set lastresource targetbuy
	*set lastbuyprice targetprice
	*set lasttotal total_price
	
*if buyunits != 1
	✅ You purchased ${buyunits} units of [b]${targetbuy}[/b] at ¢${targetprice} apiece for a total of ¢${total_price}.
	*set lastresource targetbuy
	*set lastbuyprice targetprice
	*set lasttotal total_price
	
*if sound
	*sound cashregister.wav
	
Onboard cash balance remaining: ¢${credits}

*if cargo_space_free = 1
	📦 Cargo space remaining: ${cargo_space_free} unit

*if cargo_space_free != 1
	📦 Cargo space remaining: ${cargo_space_free} units
	
[b]:::[/b] What do you want to do, Captain ${name}?

*fake_choice
	*selectable_if (cargo_space_free > 0) #🔻 Buy more products
		*goto buy_products
	#🔺 Sell products
		*goto sell_products
	#📈 View latest prices
		*goto market
	#🚪 Leave the market
		*goto leave_market

*label sell_products

🎪 [b]$!!{planet_name} MARKET[/b]

*if (cargo_space_free = cargo_holds)
	*if sound
		*sound warningbleep.wav
		
	⚠️ At the moment, you have nothing to sell. 
	
	Try buying or acquiring some resources first!
	*page_break Okay
	*goto market

*temp targetsell 0
*temp targetsellprice 0
*temp targetmaxunits 0
*temp targetmaxbuy 0

*fake_choice
	*selectable_if (resource1_carrying > 0) #$!{resource1} (${resource1_carrying}) Offer: ¢${resource1_buyprice}/unit
		*set targetsell resource1
		*set targetsellprice resource1_buyprice
		*set targetmaxunits resource1_carrying
		*set targetmaxbuy resource1_buyvolume
		*goto sell_units
	*selectable_if (resource2_carrying > 0) #$!{resource2} (${resource2_carrying}) Offer: ¢${resource2_buyprice}/unit
		*set targetsell resource2
		*set targetsellprice resource2_buyprice
		*set targetmaxunits resource2_carrying
		*set targetmaxbuy resource2_buyvolume
		*goto sell_units
	*selectable_if (resource3_carrying > 0) #$!{resource3} (${resource3_carrying})  Offer: ¢${resource3_buyprice}/unit
		*set targetsell resource3
		*set targetsellprice resource3_buyprice
		*set targetmaxunits resource3_carrying
		*set targetmaxbuy resource3_buyvolume
		*goto sell_units
	*selectable_if (resource4_carrying > 0) #$!{resource4} (${resource4_carrying})  Offer: ¢${resource4_buyprice}/unit
		*set targetsell resource4
		*set targetsellprice resource4_buyprice
		*set targetmaxunits resource4_carrying
		*set targetmaxbuy resource4_buyvolume
		*goto sell_units
	*selectable_if (resource5_carrying > 0) #$!{resource5} (${resource5_carrying}) Offer: ¢${resource5_buyprice}/unit
		*set targetsell resource5
		*set targetsellprice resource5_buyprice
		*set targetmaxunits resource5_carrying
		*set targetmaxbuy resource5_buyvolume
		*goto sell_units
	*selectable_if (resource6_carrying > 0) #$!{resource6} (${resource6_carrying}) Offer: ¢${resource6_buyprice}/unit
		*set targetsell resource6
		*set targetsellprice resource6_buyprice
		*set targetmaxunits resource6_carrying
		*set targetmaxbuy resource6_buyvolume
		*goto sell_units
	*selectable_if (resource7_carrying > 0) #$!{resource7} (${resource7_carrying}) Offer: ¢${resource7_buyprice}/unit
		*set targetsell resource7
		*set targetsellprice resource7_buyprice
		*set targetmaxunits resource7_carrying
		*set targetmaxbuy resource7_buyvolume
		*goto sell_units
	*selectable_if (resource8_carrying > 0) #$!{resource8} (${resource8_carrying}) Offer: ¢${resource8_buyprice}/unit
		*set targetsell resource8
		*set targetsellprice resource8_buyprice
		*set targetmaxunits resource8_carrying
		*set targetmaxbuy resource8_buyvolume
		*goto sell_units
	*selectable_if (resource9_carrying > 0) #$!{resource9} (${resource9_carrying}) Offer: ¢${resource9_buyprice}/unit
		*set targetsell resource9
		*set targetsellprice resource9_buyprice
		*set targetmaxunits resource9_carrying
		*set targetmaxbuy resource9_buyvolume
		*goto sell_units
	*selectable_if (resource10_carrying > 0) #$!{resource10} (${resource10_carrying}) Offer: ¢${resource10_buyprice}/unit
		*set targetsell resource10
		*set targetsellprice resource10_buyprice
		*set targetmaxunits resource10_carrying
		*set targetmaxbuy resource10_buyvolume
		*goto sell_units
	*selectable_if (resource11_carrying > 0) #$!{resource11} (${resource11_carrying}) Offer: ¢${resource11_buyprice}/cube
		*set targetsell resource11
		*set targetsellprice resource11_buyprice
		*set targetmaxunits resource11_carrying
		*set targetmaxbuy resource11_buyvolume
		*goto sell_units
	
*label sell_units

You currently have ${targetmaxunits} of ${targetsell} in your cargo hold.
	
[b]:::[/b] How many units of ${targetsell} do you want to sell?

*temp sellunits 0

*input_number sellunits 0 targetmaxunits

🎪 [b]$!!{planet_name} MARKET[/b]

*if sellunits = 0
	*if sound
		*sound warningbleep.wav
		
	[i]Sell order canceled...[/i]
	
	*goto market

*check_achievements
*if choice_achieved_sell_badge = false
	*achieve sell_badge

*if sellunits > targetmaxbuy
	*set sellunits targetmaxbuy

*label auto_sell

*temp total_price 0
*set total_price (sellunits * targetsellprice)

*set credits + total_price
*set cargo_space_free + sellunits

*if targetsell = resource1
	*set resource1_carrying - sellunits
	*set resource1_buyvolume - sellunits
	
*if targetsell = resource2
	*set resource2_carrying - sellunits
	*set resource2_buyvolume - sellunits
	
*if targetsell = resource3
	*set resource3_carrying - sellunits
	*set resource3_buyvolume - sellunits
	
*if targetsell = resource4
	*set resource4_carrying - sellunits
	*set resource4_buyvolume - sellunits
	
*if targetsell = resource5
	*set resource5_carrying - sellunits
	*set resource5_buyvolume - sellunits
	
*if targetsell = resource6
	*set resource6_carrying - sellunits
	*set resource6_buyvolume - sellunits
	
*if targetsell = resource7
	*set resource7_carrying - sellunits
	*set resource7_buyvolume - sellunits
	
*if targetsell = resource8
	*set resource8_carrying - sellunits
	*set resource8_buyvolume - sellunits
	
*if targetsell = resource9
	*set resource9_carrying - sellunits
	*set resource9_buyvolume - sellunits
	
*if targetsell = resource10
	*set resource10_carrying - sellunits
	*set resource10_buyvolume - sellunits
	
*if targetsell = resource11
	*set resource11_carrying - sellunits
	*set resource11_buyvolume - sellunits

*if sellunits = 1
	✅ You sold ${sellunits} unit of [b]${targetsell}[/b] for ¢${total_price}.
	
*if sellunits != 1
	✅ You sold ${sellunits} units of [b]${targetsell}[/b] at ¢${targetsellprice} apiece for a total of ¢${total_price}.
	
*if sound
	*sound cashregister.wav
	
*set lasttotalsale total_price
*set lastsaleprice targetsellprice
	
Onboard cash balance: ¢${credits}
		
[b]:::[/b] What do you want to do, Captain ${name}?

*fake_choice
	*selectable_if (cargo_space_free > 0) #🔻 Buy products
		*goto buy_products
	#🔺 Sell more products
		*goto sell_products
	#📈 View latest prices
		*goto market
	#🚪 Leave the market
		*goto leave_market
	
*label leave_market

🛃 [b]${planet_name} Spaceport[/b]

*if planet_level = 1
	*goto spaceport1

*if planet_level = 2
	*goto spaceport2

*if planet_level = 3
	*goto spaceport3

*if planet_level = 4
	*goto spaceport4

*if planet_level = 5
	*goto spaceport5

*label blastoff

*if fuel < 2
	*if sound
		*sound warningbleep.wav
	Making your way aboard the ${ship_name}, you see that you don't have don't have enough fuel to escape this planet's gravity.
	*page_break
	*goto start

*set priest_gone false
*set on_planet false
*set tent_available true
*set double_banned false
*set landing_cleared false
*set bar_banned false
*set your_drinks 0
*set customer_drinks 0
*set bar_chat 0
*set bank_balance (bank_balance * 1.03)
*set bank_balance round(bank_balance)
*set col_needed 0

*if sound
	*sound fuelburn.mp3
	
*temp fuely 2

*if story_mode = true
	*set fuely 1

*set fuel - fuely

*if visit_counter > 1
	*goto orbit_break

*set visit_counter 0

Quickly making your way aboard the ${ship_name}, you warm up her engines before running through your pre-flight checklist.

Verifying that all exterior hatches are sealed, you fire main engines.

*if rp
	${rp_emoji} "Blastoff!"

You remained pinned back in your seat until you break orbit.

Scanning the control board, you are relieved to see no incoming messages from Planetary Control.

*page_break 🌠 Explore the Galaxy

*label orbit_break

🔥 Fuel used to leave planet: 2 units
*line_break
🔥 Fuel remaining: ${fuel}

*goto_scene startrip_main

*label batteries

*if sound
	*sound briefchirp.wav

*temp recharge_cost 0
*temp units_needed 0

*rand dieroll 5 15

*set units_needed (battery_max - battery)

*set recharge_cost (units_needed * dieroll)

*if recharge_cost = 0
	*if sound
		*sound warningbleep.wav
		
	⚡ [i]${ship_name} batteries full![/i]
	
*temp recharge_cost 0
*temp units_needed 0

*rand dieroll 5 15

*set units_needed (battery_max - battery)

*set recharge_cost (units_needed * dieroll)

*if recharge_cost = 0
	⚡ [i]${ship_name} batteries full![/i]
	
	*page_break 😌
	*goto spaceport5

Approaching a gleaming kiosk, you uplink your public data key and then eyescroll through the menus until the screen reads:

⚡ [i]${ship_name} projected recharge cost: ${recharge_cost} galactic credits[/i]

[i]Recharge now, Y/N?[/i]

*fake_choice
	*selectable_if (credits >= recharge_cost) #Yes
	#No
		Instead of fussing around with recharging your ship's batteries, you decide it is better to explore other areas of the spaceport.
		
		*goto spaceport5
	
*if sound
	*sound droids2.wav
	
After palming over your payment authorization key, the screen blinks and then displays a new message:

⚡ [i]Recharge in progress.  Thank you for choosing ${planet_name} Spaceport for your recharging needs![/i]

Nodding to yourself, you turn around to explore the spaceport, confident in the knowledge that your ship's batteries will be fully charged by the time you leave.

*page_break Okay

*set battery battery_max

*goto spaceport5

*page_break Oops!
*goto spaceport5

Approaching a gleaming kiosk, you uplink your public data key and then eyescroll through the menus until the screen reads:

⚡ [i]${ship_name} projected recharge cost: ${recharge_cost} galactic credits[/i]

[i]Recharge now, Y/N?[/i]

*fake_choice
	*selectable_if (credits >= recharge_cost) #Yes
	#No
		Instead of fussing around with recharging your ship's batteries, you decide it is better to explore other areas of the spaceport.
		
		*goto spaceport5
	
After palming over your payment authorization key, the screen blinks and then displays a new message:

⚡ [i]Recharge in progress.  Thank you for choosing ${planet_name} Spaceport for your recharging needs![/i]

Nodding to yourself, you turn around to explore the spaceport, confident in the knowledge that your ship's batteries will be fully charged by the time you leave.

*page_break Okay

*set battery battery_max

*goto spaceport5

*label passenger_check

*if planet_name = passenger_destination
	*goto disembark

*if passengers_carrying = 1
	🧑‍🚀	" "Hey, I need to get to ${passenger_destination} in quadrant ${passenger_quadrant}, not ${planet_name}!"
	
	"I''ll just be a minute," you reply.
	
*if passengers_carrying > 1
	🧑‍🚀 "Why do we keep stopping all the time?  Hurry up and take us to ${passenger_destination}, already!  It's in quadrant ${passenger_quadrant}," mutters one of your passengers.
	
	"Relax.  I've just got to make a quick stop here," you inform your passengers.

*return

*label disembark

*temp pass_total 0

*set pass_total (passengers_bid_price * passengers_carrying)

*if passengers_carrying > 1
	👨‍🚀 	"Took you long enough," grumble the passengers as they disembark your ship.
	
*if passengers_carrying = 1
	👨‍🚀 "Thanks for the ride!" says the passenger as they make their way off your ship.
	
*set credits + pass_total
*set berths_available + passengers_carrying
*set passengers_carrying 0
*set passenger_destination ""

*return


*label bank

*if sound
	*sound cashier.wav

🏦 [b]${planet_name} branch of the Intergalactic Bank[/b]

*if (story_mode = true) and (married = false)
	You enter the bank, but then you remember your ${brother}'s warning that all your bank accounts are being monitored by the Syndicate.
	
	Therefore, there is no way for you to access your family's money!
	
	*page_break 😌
	*goto leave_market
	
*set bank_visited true

[i]Deposit money with us and earn 3% interest![/i]

*if married = false
	Your bank balance: ¢${bank_balance}
	
*if married = true
	Your spouse's bank balance: ¢${bank_balance}

Credits on hand: ¢${credits}

[b]:::[/b] What do you want to do, Captain ${name}?

*fake_choice
	*selectable_if (credits > 0) #🔺 Deposit money
		*goto deposit_money
	*selectable_if (bank_balance > 0) #🔻 Withdraw money
		*goto withdraw_money
	#↩️ Leave the bank
		*goto leave_market

*label deposit_money

🏦 [b]${planet_name} branch of the Intergalactic Bank[/b]

[i]Deposit money with us and earn 3% interest![/i]

Current cash balance: ¢${credits}

[b]:::[/b] How much money would you like to deposit with us today, Captain ${name}?

*temp deposit_amount 0

*input_number deposit_amount 0 credits

*if deposit_amount = 0
	[i]Perhaps another time, Captain![/i]
	*goto bank

🏦 [b]${planet_name} branch of the Intergalactic Bank[/b]

*if sound
	*sound cashregister.wav

✅ You deposited ${deposit_amount} credits.

*set credits - deposit_amount
*set bank_balance + deposit_amount

*page_break Acknowledged

*goto bank

*label withdraw_money

🏦 [b]${planet_name} branch of the Intergalactic Bank[/b]

[i]Deposit money with us and earn 3% interest![/i]

Current bank balance: ¢${bank_balance}

*if married = false
	[b]:::[/b] How much money would you like to withdraw from your account today, Captain ${name}?
	
*if married = true
	[b]:::[/b] How much money would you like to withdraw from ${rp_name}'s account today, Captain ${name}?

*temp withdraw_amount 0

*input_number withdraw_amount 0 bank_balance

*if withdraw_amount = 0
	*if sound
		*sound warningbleep.wav
		
	[i]Perhaps another time, Captain![/i]
	*goto bank

🏦 [b]${planet_name} branch of the Intergalactic Bank[/b]

*if sound
	*sound cashregister.wav

✅ You successfully withdrew ${withdraw_amount} credits.

*set credits + withdraw_amount
*set bank_balance - withdraw_amount

*page_break Acknowledged

*goto bank