class_name Utils extends Object static func generate_guid() -> String: var guid = "" var time = Time.get_ticks_msec() var rng = RandomNumberGenerator.new() rng.randomize() # Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx guid += "%08x" % time guid += "-" guid += "%04x" % rng.randi() guid += "-" guid += "4" guid += "%03x" % rng.randi() guid += "-" guid += "%x" % (8 + rng.randi() % 4) guid += "%03x" % rng.randi() guid += "-" guid += "%012x" % rng.randi() return guid static func convert_algebraic_to_location(square: String, maxRank: int) -> String: var file = square[0] # letter (a-h) var rank = int(square[1]) # number (1-8) # Convert file letter to number (a=0, b=1, etc) var file_num = file.unicode_at(0) - 'a'.unicode_at(0) # Since we're working with black's moves and our board is oriented with white at bottom: # 1. Flip rank: 8 - rank to mirror vertically file_num = file_num var rank_num = maxRank - rank return "%d-%d" % [file_num, rank_num] static func location_to_algebraic(location: String, maxRank: int) -> String: # Convert from "x-y" format to algebraic notation var coords = location.split("-") var x = int(coords[0]) var y = int(coords[1]) # Convert x to file letter (0 = 'a', 1 = 'b', etc.) var file = char(97 + x) # 97 is ASCII 'a' # Convert y to rank number (flip since our board has 0 at top) var rank = str(maxRank - y) return file + rank static var LIGHT_CELL = Color(0.5, 0.5, 0.5, 1) static var DARK_CELL = Color(0.2, 0.2, 0.2, 1) static var GREEN_CELL = Color(0.36, 0.62, 0.43, 1) static var WALL_CELL = Color(0.59, 0.29, 0.0, 1) # Brown (#964B00) static var DOUBLE_WALL = Color(0.36, 0.17, 0.0, 1) # Dark Brown (#5C2B00) enum RoomType { STARTING, NORMAL, BOSS, FINAL, SHOP, EVENT } enum WinConditionType { CAPTURE_UNIT, # Default: King capture BOARD_CLEARED, # Clear the board of all opponent pieces TILE_REACHED, # Reach a specific tile with a specific unit TURN_NUMBER # Reach a specific turn number } # Loss condition types enum LossConditionType { UNIT_LOST, # Default: King loss TURN_NUMBER # Turn limit reached } static var CardTypes = [ HopscotchCard, FieryCapeCard, FieryTrailCard, ExplosiveBootsCard, DoubleTimeCard, DrunkDrivingCard, SupernovaCard ]