extends Control

const MenuScene = "res://ui/main_menu.tscn"

var wintext = ["All clemmings have retired from cliff diving forever.","All clemmings have taken an extended vacation to Clemming Land, where cliff-diving is strictly prohibited!","All clemmings have decided to take a permanent nap... at the bottom of the cliff.
","All clemmings have officially joined the 'Stay Grounded Society’.","All clemmings have thrown in the towel and decided to pursue a career in underground tunneling.
","All clemmings have embarked on a one-way trip to a banana banquet in the sky. 
","All clemmings have embarked on their final journey to the Happy Hunting Grounds.
","All clemmings will stay grounded forever."]
var rng = RandomNumberGenerator.new()

# Called when the node enters the scene tree for the first time.
func _ready():
	var Text = get_node("Panel/Container/VBoxContainer/Label")
	
	var last_level_won: bool = false
	if GameConstants.nextScene == "res://ui/main_menu.tscn":
		last_level_won = true
	
	if last_level_won:
		Text.text = "[center]Congratulations!\nYou completed all levels.\nThank you for playing![/center]"
		$Panel/Container/VBoxContainer/VBoxContainer/Continue.hide()
	else:
		$Panel/Container/VBoxContainer/VBoxContainer/Continue.show()
		var randomindex = rng.randi_range(0,6)
		Text.text = "[center]" + wintext[randomindex] + "[/center]"



func _on_continue_pressed():
	get_tree().change_scene_to_file(GameConstants.nextScene)

func _on_quit_pressed():
	get_tree().change_scene_to_file(MenuScene)
