extends Node2D

var timer_card = 3
var timer_number = 10

func _on_JokCheck_pressed():
	$Card.add_jock = $JokCheck.pressed
	if $JokCheck.pressed:
		$RandNumber.max_ = 53
	else:
		$RandNumber.max_ = 52


func _on_CloseButton_pressed():
	$Panel.hide()


func _on_AboutButton_pressed():
	$Panel.show()


func _on_Button_pressed():
	$Card.reinit()
	$RandNumber.reinit()
	$CardSpin.hide()
	$NumberSpin.hide()
	timer_card = $CardSpin.value
	timer_number = $NumberSpin.value
	$CardTimerLabel.text = str(timer_card)
	$NumberTimerLabel.text = str(timer_number)
	$CardTimer.start()
	$NumberTimer.start()


func _on_CardTimer_timeout():
	timer_card -= 1
	$CardTimerLabel.text = str(timer_card)
	if timer_card <= 0:
		$CardTimer.stop()
		$Card.switch_card()
		$CardSpin.show()


func _on_NumberTimer_timeout():
	timer_number -= 1
	$NumberTimerLabel.text = str(timer_number)
	if timer_number <= 0:
		$NumberTimer.stop()
		$RandNumber.switch_number()
		$NumberSpin.show()

func _input(event):
	if event.is_action_pressed("ui_accept"):
		$Card.switch_card()
	if event.is_action_pressed("ui_cancel"):
		$RandNumber.switch_number()
	if event.is_action_pressed("ui_select"):
		$RandNumber.reinit()
		$Card.reinit()
