extends Window

@onready var levelLabel : Label = %LevelLabel
@onready var reputationLabel : Label = %ReputationLabel
@onready var membersLabel : Label = %MembersLabel
@onready var goldLabel : Label = %GoldLabel

func _ready() -> void:
	refresh()
	Guild.changed.connect(_on_guild_change)

func refresh() -> void:
	levelLabel.text = str(Guild.level)
	reputationLabel.text = "%d (%d to next level)" % [Guild.reputation, Guild.rep_tnl]
	membersLabel.text = str(len(Guild.members))
	goldLabel.text = str(Guild.gold)

func _on_guild_change() -> void:
	refresh()

func _on_close_requested() -> void:
	queue_free()


func _on_focus_exited() -> void:
	queue_free()
