extends Node2D

onready var global: Node = get_node("/root/Global")

onready var timer: Timer = $Timer
onready var digits_group: Node2D = $Digits
onready var can_quit: Node = $CanQuit
var digits: Array

var answer: Array = [119, 36, 46, 107]

func _ready():
	digits = digits_group.get_children()
	print(digits)

func _on_GreenButton_pressed():
	global.play_sound("button_click")
	var right: bool = true
	for i in digits.size():
		if answer[i] != digits[i].get_answer():
			right = false
			print("wrong!")
			break
	if !right:
		return
	
	if !global.game_vars.has("the_word_done"):
		global.game_vars["the_word_done"] = true
		global.play_sound("door_open2")
		can_quit.queue_free()
		timer.start()

func _on_Timer_timeout():
	global.player.animation_player.play("Victory")
	global.return_to_room()
	global.change_room("res://Rooms/Basement2/Basement2.tscn")
	global.inventory_input = true
