extends Node

var points = 0

enum SPEED {MIN=20, MAX=80}

var currentSpeed := SPEED.MIN

var hasSelectedSpeed = false

const GRID := 64

enum BLOCKTYPES {LIGHT=1, HEAVY=3}

var blockStopped = false

var testingPhase = false

var rowRemoved = false

const BLOCKS : Dictionary = {
	#"1x1": "res://scenes/NewBlocks/1x1/1x1.tscn",
	"1x3": "res://scenes/NewBlocks/1x3/1x3.tscn",
	#"1x4": "res://scenes/NewBlocks/1x4/1x4.tscn",
	"2x2": "res://scenes/NewBlocks/2x2/2x2.tscn",
	"L": "res://scenes/NewBlocks/L/L.tscn",
	"L_Reverse": "res://scenes/NewBlocks/L_Reverse/L_Reverse.tscn",
	"Z": "res://scenes/NewBlocks/Z/Z.tscn",
	"Z_Reverse": "res://scenes/NewBlocks/Z_Reverse/Z_Reverse.tscn",
}
enum Direction {BOTTOM, LEFT, RIGHT, TOP}

var currentUID : int = 0

var currentID : int = 0

var time = 60

var lost = false

enum MODES {INFINITE, TIME}

var currentMode = MODES.INFINITE


func getNewUID() -> int:
	currentUID += 1
	return currentUID
	
func getNewID() -> int:
	currentID += 1
	return currentID

func resetGame():
	currentSpeed = SPEED.MIN
	rowRemoved = false
	blockStopped = false
	testingPhase = false
	lost = false
	points = 0
	currentUID = 0
	resetTime()
	lost = false

func _ready() -> void:
	resetGame()

func lose():
	lost = true

func resetTime():
	time  = 0


func setTimeModeTimer():
	time = 60

func convertIntToTime(value) -> String:
	var time = str(value)
	var seconds = value % 60
	var minutes = value / 60
	if seconds < 10:
		seconds = "0"+ str(seconds)
	return str(minutes) + ":" + str(seconds)

func speedUp():
	if currentSpeed + 1 <= SPEED.MAX:
		currentSpeed += 1
	else:
		currentSpeed = SPEED.MAX
