extends Resource class_name Prompt enum PromptType {TEXT, LONG_TEXT, NUMBER, MULTIPLE_CHOICE, COLOUR, PLAYER, CONFIRMATION, SHOW_TEAM, SHOW_ROLE} @export_multiline var text: String: set(val): text = val id = text.hash() @export_multiline var explaination: String @export var type: PromptType @export var options: Array[String] @export var interruptable: bool = false var id: int = randi() var context: Dictionary #[String, String] static func create(text: String, type: PromptType) -> Prompt: var prompt: Prompt = Prompt.new() prompt.text = text prompt.type = type return prompt func format_text() -> String: return text.format(context) func with_context(additional_context: Dictionary) -> Prompt: var ret: Prompt = duplicate(true) ret.context = context.merged(additional_context) return ret func save() -> Dictionary: return { "text" = text, "explaination" = explaination, "type" = type as int, "options" = options, "context" = context, "interruptable" = interruptable, "id" = id, } static func load(dict: Dictionary) -> Prompt: if dict.is_empty(): return null var ret: Prompt = Prompt.new() ret.text = dict.get("text", "") ret.explaination = dict.get("explaination", "") ret.type = dict.get("type", 0) as PromptType ret.options.assign(dict.get("options", [])) ret.context = dict.get("context", {}) #ret.context.assign(dict.get("context", {})) ret.id = dict.get("id", 0) ret.interruptable = dict.get("interruptable", false) return ret