class_name ErrorCode

## 错误码定义
## 用于统一管理登录系统中的所有错误码和错误消息

# 成功
const SUCCESS: int = 0

# 网络相关错误 (1000-1999)
const NETWORK_ERROR: int = 1001
const TIMEOUT: int = 1002
const SERVER_ERROR: int = 1003

# 输入验证错误 (2000-2999)
const INVALID_INPUT: int = 2001
const INVALID_USERNAME: int = 2002
const INVALID_PASSWORD: int = 2003
const PASSWORDS_NOT_MATCH: int = 2004

# 认证相关错误 (3000-3999)
const WRONG_CREDENTIALS: int = 3001
const USER_NOT_FOUND: int = 3002
const ACCOUNT_DISABLED: int = 3003
const TOKEN_EXPIRED: int = 3004
const TOKEN_INVALID: int = 3005

# 错误消息映射
const MESSAGES: Dictionary = {
	NETWORK_ERROR: "网络连接失败，请检查网络设置",
	TIMEOUT: "请求超时，请稍后重试",
	SERVER_ERROR: "服务器错误，请稍后重试",
	INVALID_INPUT: "用户名或密码不能为空",
	INVALID_USERNAME: "用户名格式不正确（3-16个字符）",
	INVALID_PASSWORD: "密码格式不正确（6-20个字符）",
	PASSWORDS_NOT_MATCH: "两次输入的密码不一致",
	WRONG_CREDENTIALS: "用户名或密码错误",
	USER_NOT_FOUND: "用户不存在",
	ACCOUNT_DISABLED: "账号已被禁用",
	TOKEN_EXPIRED: "登录已过期，请重新登录",
	TOKEN_INVALID: "登录状态无效，请重新登录"
}

## 获取错误消息
static func getMessage(errorCode: int) -> String:
	return MESSAGES.get(errorCode, "未知错误 (代码: %d)" % errorCode)
