extends Label

var cur_mask : Types.mask_types
var uses : int
var health : int

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	EventBus.mask_changed.connect(_on_mask_changed)
	EventBus.mask_uses_changed.connect(_on_uses_changed)
	EventBus.health_changed.connect(_on_health_changed)
	
func _process(delta: float) -> void:
	update_text()
	
func update_text():
	var enemies = len(get_tree().get_nodes_in_group("enemy"))
	text = "Mask: " + _get_mask_name(cur_mask) + "\n" + \
		"Uses: " + str(uses) + "\n" + \
		"Health: " + str(health) + "\n" + \
		"Enemies: " + str(enemies)

func _get_mask_name(type : Types.mask_types):
	if (type == 0): return "Melee"
	if (type == 1): return "Ranged"
	if (type == 2): return "Spit"
	return ""

func _on_mask_changed(new : Types.mask_types):
	cur_mask = new
	update_text()

func _on_uses_changed(new : int):
	uses = new
	update_text()

func _on_health_changed(new : int):
	health = new
	update_text()
