extends Node
class_name CubeCoordinate

var x : int
var y : int
var z : int

func _init(_x : int, _y : int, _z : int) -> void:
	x = _x
	y = _y
	z = _z

func FromAxial(ac : AxialCoordinate) -> void:
	x = ac.q
	z = ac.r
	y = -x - z

func Rotate(steps : int) -> CubeCoordinate:
	steps = steps % 6;
	var _x : int = 0;
	var _y : int = 0;
	var _z : int = 0;

	match (steps):
		0:
			_x = x;
			_y = y;
			_z = z;
		1:
			_x = -z;
			_y = -x;
			_z = -y;
		2:
			_x = y;
			_y = z;
			_z = x;
		3:
			_x = -x;
			_y = -y;
			_z = -z;
		4:
			_x = z;
			_y = x;
			_z = y;
		5:
			_x = -y;
			_y = -z;
			_z = -x;

	x = _x;
	y = _y;
	z = _z;

	return self
