class_name Quest
extends RefCounted
## An active-quest row. Owns the status enum {active, complete, failed}.

const STATUSES := ["active", "complete", "failed"]

var id: String
var name: String
var status: String
var objective: String


func _init(p_id := "", p_name := "", p_status := "active", p_objective := "") -> void:
	id = p_id
	name = p_name
	objective = p_objective
	set_status(p_status)


func set_status(v: String) -> bool:
	if v not in STATUSES:
		push_error("invalid quest status: %s" % v)
		return false
	status = v
	return true


func to_dict() -> Dictionary:
	return {"id": id, "name": name, "status": status, "objective": objective}


static func from_dict(d: Dictionary) -> Quest:
	return Quest.new(d.get("id", ""), d.get("name", ""), d.get("status", "active"), d.get("objective", ""))
