# Copyright (c) 2022 by Hurleveur
#
# Endless Sky is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later version.
#
# Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.

test-data "quarg rescue save"
	category "savegame"
	contents
		pilot Bobbi Bughunter
		date 16 11 3013
		system "Terra Incognita"
		planet Ruin
		clearance
		ship "Star Barge"
			name "Buggy Barge"
			sprite "ship/star barge"
			attributes
				category "Light Freighter"
				cost 190000
				mass 70
				bunks 3
				"cargo space" 50
				drag 2.1
				"engine capacity" 40
				"fuel capacity" 300
				"heat dissipation" 0.8
				hull 1000
				"outfit space" 130
				"required crew" 1
				shields 600
				"turret mounts" 1
				"weapon capacity" 20
				"thrust" 50
				"turn" 1000
				"energy generation" 10
			outfits
				Hyperdrive
			crew 1
			fuel 300
			shields 600
			hull 1000
			position 0 0
			engine -9 38 1
			engine 9 38 1
			system "Terra Incognita"
			planet Ruin
		account
			credits 100000000
			score 400
			history
		visited "Terra Incognita"
		"visited planet" Ruin
		"available mission" "%TEST%: Wardragon Scanning You!"
			name "%TEST%: Wardragon Scanning You!"
			uuid 9ba505d8-e565-4632-8c7a-c74072b85b5a
			priority
			to offer
				"%TEST%: SCANNING ILLEGALS" != 0
			destination Ruin
			npc
				uuid 01a921d2-b477-4d80-a19e-11aefb2a6464
				succeed 1
				government Quarg
				personality derelict target
				ship "Quarg Wardragon"
					name Scanner
					sprite ship/wardragon
					thumbnail thumbnail/wardragon
					uuid 7cc5c522-858d-419c-88a7-f240fc5799d7
					attributes
						category "Heavy Warship"
						cost 5900000
						mass 360
						automaton 1
						drag 9.3
						"heat dissipation" 0.5
						hull 50000
						"outfit scan power" 1e+09
						"outfit scan efficiency" 1e+09
						"energy generation" 10
						shields 160000
					fuel 0
					shields 0
					hull 1000
					position 0 0
					explode "huge explosion" 1
					system "Terra Incognita"
			on offer
				conversation
					label 0
					"You must be scanned or be killed."
						accept
		conditions
			"%TEST%: SCANNING ILLEGALS"

test-data "quarg scanning save"
	category "savegame"
	contents
		pilot Bobbi Bughunter
		date 16 11 3013
		system "Terra Incognita"
		planet Ruin
		clearance
		ship "Star Barge"
			name "Buggy Barge"
			sprite "ship/star barge"
			attributes
				category "Light Freighter"
				cost 190000
				mass 70
				bunks 3
				"cargo space" 50
				drag 2.1
				"engine capacity" 40
				"fuel capacity" 300
				"heat dissipation" 0.8
				hull 1000
				"outfit space" 130
				"required crew" 1
				shields 600
				"turret mounts" 1
				"weapon capacity" 20
				"thrust" 50
				"turn" 1000
				"energy generation" 10
			outfits
				Hyperdrive
				"Nerve Gas"
			crew 1
			fuel 300
			shields 600
			hull 1000
			position 0 0
			engine -9 38 1
			engine 9 38 1
			system "Terra Incognita"
			planet Ruin
		account
			credits 100000000
			score 400
			history

		event "illegal stuff"
			government "Quarg"
				illegals
					ignore "Nerve Gas"
					Hyperdrive 1
				# they enforce all currently but to be sure
				remove "enforces"
		visited "Terra Incognita"
		"visited planet" Ruin
		"available mission" "%TEST%: Wardragon Scanning You!"
			name "%TEST%: Wardragon Scanning You!"
			uuid 9ba505d8-e565-4632-8c7a-c74072b85b5a
			priority
			to offer
				"%TEST%: SCANNING ILLEGALS" != 0
			destination Ruin
			npc
				uuid 01a921d2-b477-4d80-a19e-11aefb2a6464
				succeed 1
				government Quarg
				personality derelict surveillance target
				ship "Quarg Wardragon"
					name Scanner
					sprite ship/wardragon
					thumbnail thumbnail/wardragon
					uuid 7cc5c522-858d-419c-88a7-f240fc5799d7
					attributes
						category "Heavy Warship"
						cost 5900000
						mass 360
						automaton 1
						drag 9.3
						"heat dissipation" 0.5
						hull 50000
						"outfit scan power" 1e+09
						"outfit scan efficiency" 1e+09
						"energy generation" 10
						shields 160000
					fuel 0
					shields 0
					hull 1000
					position 0 0
					explode "huge explosion" 1
					system "Terra Incognita"
			on offer
				conversation
					label 0
					"You must be scanned or be killed."
						accept
		conditions
			"%TEST%: SCANNING ILLEGALS"


test-data "quarg atrocity save"
	category "savegame"
	contents
		pilot Bobbi Bughunter
		date 16 11 3013
		system "Terra Incognita"
		planet Ruin
		clearance
		"reputation with"
			Quarg 1000
		ship "Star Barge"
			name "Buggy Barge"
			sprite "ship/star barge"
			attributes
				category "Light Freighter"
				cost 190000
				mass 70
				bunks 3
				"cargo space" 50
				drag 2.1
				"engine capacity" 40
				"fuel capacity" 300
				"heat dissipation" 0.8
				hull 1000
				"outfit space" 130
				"required crew" 1
				shields 600
				"turret mounts" 1
				"weapon capacity" 20
				"thrust" 50
				"turn" 1000
				"energy generation" 10
			outfits
				Hyperdrive
			crew 1
			fuel 300
			shields 600
			hull 1000
			position 0 0
			engine -9 38 1
			engine 9 38 1
			system "Terra Incognita"
			planet Ruin
		account
			credits 100000000
			score 400
			history

		event "atrocity stuff"
			government "Quarg"
				atrocities
					Hyperdrive
				remove "enforces"
				remove "death sentence"
		visited "Terra Incognita"
		"visited planet" Ruin
		"available mission" "%TEST%: Wardragon Scanning You!"
			name "%TEST%: Wardragon Scanning You!"
			uuid 9ba505d8-e565-4632-8c7a-c74072b85b5a
			priority
			to offer
				"%TEST%: SCANNING ILLEGALS" != 0
			destination Ruin
			npc
				uuid 01a921d2-b477-4d80-a19e-11aefb2a6464
				succeed 1
				government Quarg
				personality derelict surveillance target
				ship "Quarg Wardragon"
					name Scanner
					sprite ship/wardragon
					thumbnail thumbnail/wardragon
					uuid 7cc5c522-858d-419c-88a7-f240fc5799d7
					attributes
						category "Heavy Warship"
						cost 5900000
						mass 360
						automaton 1
						drag 9.3
						"heat dissipation" 0.5
						hull 50000
						"outfit scan power" 1e+09
						"outfit scan efficiency" 1e+09
						"energy generation" 10
						shields 160000
					fuel 0
					shields 0
					hull 1000
					position 0 0
					explode "huge explosion" 1
					system "Terra Incognita"
			on offer
				conversation
					label 0
					"You must be scanned or be killed."
						accept
		conditions
			"%TEST%: SCANNING ILLEGALS"

# just so the mission actually works
mission "%TEST%: Wardragon Scanning You!"

test "Launch Quarg Scanning Mission And Board"
	status partial
	description "Starts the mission, accepts it, boards the quarg ship to repair it and skips the dialog."
	sequence
		# accept the mission and launch
		input
			key p
		input
			key d
		call "Depart"
		# board the ship so we're sure we get close to it to get scanned
		input
			command board
		label "floating"
		# wait for it to become hostile from the scanning
		branch "floating"
			"reputation: Quarg" >= 0
			"unpaid fines" == 0
		input
			key "return"

test "Illegal Test - Ignore and New Illegal"
	status active
	description "Test if a Quarg ship spawning disabled in the system will give you a fine for an illegal outfit and ignore the fine for another, after you repaired it."
	sequence
		inject "quarg scanning save"
		call "Load First Savegame"
		assert
			"unpaid fines" == 0
		call "Launch Quarg Scanning Mission And Board"
		# land back with a fine of 1 for the hyperdrive, nothing from the gas
		navigate
			"travel destination" Ruin
		call "Land"
		# copy the test-data in the temporary conditions for debugging when an issue happens
		assert
			"unpaid fines" == 1

test "Atrocity Test - New Atrocity"
	status active
	description "Test if a Quarg ship spawning disabled in the system will consider an outfit an atrocity when specified by an event."
	sequence
		inject "quarg atrocity save"
		call "Load First Savegame"
		assert
			"reputation: Quarg" == 1000
		call "Launch Quarg Scanning Mission And Board"
		# land back with atrocity having been in effect (should nuke the reputation?)
		navigate
			"travel destination" Ruin
		call "Land"
		assert
			# it'll be 0 from the atrocity and then minus whatever the atrocity reputation hit it
			"reputation: Quarg" < 1
