130 lines
3.5 KiB
GDScript
130 lines
3.5 KiB
GDScript
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 MAX_ELO = 2300
|
|
static var MIN_ELO = 500
|
|
|
|
static var VANILLA_ELO_STEP = 100
|
|
static var DEEPER_ELO_STEP = 250
|
|
|
|
|
|
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 BossType {
|
|
ZERG,
|
|
DOUBLETROUBLE,
|
|
WARLARD,
|
|
}
|
|
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
|
|
]
|
|
|
|
static var CardPrices = {
|
|
Card.Rank.RANK_0: 200, # Legendary (Rank 0)
|
|
Card.Rank.RANK_1: 100, # Rare (Rank 1)
|
|
Card.Rank.RANK_2: 50, # Uncommon (Rank 2)
|
|
Card.Rank.RANK_3: 25 # Common (Rank 3)
|
|
}
|
|
|
|
static var HandRankWhiteList = [Card.Rank.RANK_2, Card.Rank.RANK_3]
|
|
|
|
static var TokenCosts = {
|
|
Card.Rank.RANK_0: 15, # Most expensive (one-time use)
|
|
Card.Rank.RANK_1: 10, # Expensive (once per match)
|
|
Card.Rank.RANK_2: 5, # Medium (multiple uses)
|
|
Card.Rank.RANK_3: 3 # Cheapest (basic cards)
|
|
}
|
|
|
|
static var Fibonacci = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
|
|
|
|
# Calculate the token cost for increasing hand size
|
|
static func calculate_hand_size_cost(run_count: int) -> int:
|
|
var fib_index = run_count + 3
|
|
if fib_index >= Fibonacci.size():
|
|
fib_index = Fibonacci.size() - 1
|
|
|
|
return Fibonacci[fib_index]
|