class_name LogPlayer
extends RefCounted
## A canon-log player row. Carries ONLY name, class_id, luck_descriptor (§7):
## no numeric Luck, no stats — those live in GameState and never reach the AI.

const CLASSES := ["sellsword", "assassin", "priest"]

var name: String
var class_id: String
var luck_descriptor: String


func _init(p_name := "", p_class_id := "", p_luck_descriptor := "") -> void:
	name = p_name
	luck_descriptor = p_luck_descriptor
	if p_class_id != "":
		set_class_id(p_class_id)


func set_class_id(v: String) -> bool:
	if v not in CLASSES:
		push_error("invalid class_id: %s" % v)
		return false
	class_id = v
	return true


func to_dict() -> Dictionary:
	return {"name": name, "class_id": class_id, "luck_descriptor": luck_descriptor}


static func from_dict(d: Dictionary) -> LogPlayer:
	return LogPlayer.new(d.get("name", ""), d.get("class_id", ""), d.get("luck_descriptor", ""))
