I need help with a mechanic i been working on

Godot Version

godot 4

Question

I am currently working on a mechanic that allows me to grab tiles the problem is checking the tile type I have 4 tile types red green blue and orange I want to check for a red tile and then insantiate a scene representing a grabbed tile

another problem i have is checking whether or not there is three of the same colored tile in the game if there is three in row horizontally vertically or diagonally in the game then the opponent losses health

im working on the tile grab script here is my code

extends Node
@onready var character_body_2d = $"."

var char_pos = get_node(character_body_2d).get_position
@onready var tile_map = $TileMap

var current_map = TileMap
var current_data = TileData

enum colors{red, blue, green , orange}
const  red = 8
const blue = 6
const green = 10
const orange = 9
	

	





# Called when the node enters the scene tree for the first time
func tilegrab():
	var tile_char_map = tile_map.local_to_map(char_pos)
	var cell_data = tile_map.get_cell_tile_data(1,tile_char_map)
	return cell_data
	

If you have stored the board colors in an array (which I recommend for this application), you can do a manual check:

# Check for diagonal line
if board[0][0] == colors.red and board[1][1] == colors.red and board[2][2] == colors.red:
   # Execute code here

or you can use bitmask and have better efficiency (It’s significantly more complicated so I won’t post it here)