extends Node2D

signal restart_game

var input_received = false
var timer_elapsed = false

func _ready() -> void:
	win()
	await $Timer.timeout
	timer_elapsed = true

func win():
	$MorshoReactManager/MorshoHappy.visible = true
	$MorshoReactManager/MorshoAngry.visible = false
	%WinLossAudioPlayer.stream = load("res://win.ogg")
	%WinLossAudioPlayer.play()

func lose():
	$MorshoReactManager/MorshoAngry.visible = true
	$MorshoReactManager/MorshoHappy.visible = false
	%WinLossAudioPlayer.stream = load("res://loss.ogg")
	%WinLossAudioPlayer.play()

func _input(event):
	if timer_elapsed == true:
		if input_received:
			return

		if event is InputEventKey or event is InputEventMouseButton:
			input_received = true
			emit_signal("restart_game")
