class_name NPC
extends RefCounted


var npc_name := "Nobody"
var patience := 3

var preferred_categories := 0
var desired: Array[Item]
var inventory: Array[Item]

var patience_remaining := patience


func dialogue_beginning() -> DialogueResult:
	assert(false, "%s not implemented for %s" % [get_stack()[0].function, str(self)])
	return DialogueResult.new()


func dialogue_offer(_item: Item) -> DialogueResult:
	assert(false, "%s not implemented for %s" % [get_stack()[0].function, str(self)])
	return DialogueResult.new()


func dialogue_judge(_item: Array[Item]) -> DialogueResult:
	assert(false, "%s not implemented for %s" % [get_stack()[0].function, str(self)])
	return DialogueResult.new()


func _response(string: String, value := true) -> DialogueResult:
	return DialogueResult.new(string, value)


func _items_have_any_categories(categories: int) -> bool:
	return GameState.fetch().player_inventory.items.any(
		func(item: Item) -> bool:
			return item.categories & categories
	)


func _items_have_all_categories(categories: int) -> bool:
	return GameState.fetch().player_inventory.items.all(
		func(item: Item) -> bool:
			return item.categories & categories
	)


class DialogueResult:
	var string: String
	var value: bool
	
	
	func _init(p_string := "", p_value := true) -> void:
		string = p_string
		value = p_value
