extends Control class_name MonsterCardUI signal left_clicked signal right_clicked signal un_right_clicked signal hovering(delta: float) @export var name_label : Label @export var health_label : Label @export var energy_pip_container :Container @export var icon_texture_rect : TextureRect @export var paper_damage : Label @export var scissors_damage : Label @export var rock_damage : Label func show_monster(monster: MatchMonster): if !monster: name_label.text = "" health_label.text = "HP" icon_texture_rect.texture = null return name_label.text = monster.card.id health_label.text = "HP %d/%d" % [monster.health, monster.card.base_health] icon_texture_rect.texture = monster.card.icon paper_damage.text = str(monster.card.paper) scissors_damage.text = str(monster.card.scissors) rock_damage.text = str(monster.card.rock) var shown_stars = 0 for child in energy_pip_container.get_children(): var tr = child as TextureRect tr.visible = shown_stars < monster.card.energy_cost shown_stars += 1 func _process(delta): var mouse_position = get_global_mouse_position() var rect = get_global_rect() if rect.has_point(mouse_position) and get_window().has_focus(): hovering.emit(delta) func _input(event): if event is InputEventMouseButton: var mouse_position = get_global_mouse_position() var rect = get_global_rect() if rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() and get_window().has_focus(): left_clicked.emit() elif rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_RIGHT and event.is_pressed() and get_window().has_focus(): right_clicked.emit() elif event.button_index == MOUSE_BUTTON_RIGHT and !event.is_pressed(): un_right_clicked.emit()