extends Node

@export var tank_set: AbilitySet
@export var damage_set: AbilitySet
@export var healer_set: AbilitySet

func _ready() -> void:
  EventBus.role_change_requested.connect(_on_role_change_requested)
  _apply_role.call_deferred(PlayerData.current_role)

func _on_role_change_requested(_player: Node, role: int) -> void:
  _apply_role(role)

func _apply_role(role: int) -> void:
  PlayerData.current_role = role
  match role:
    PlayerData.Role.TANK:
      PlayerData.ability_set = tank_set
    PlayerData.Role.DAMAGE:
      PlayerData.ability_set = damage_set
    PlayerData.Role.HEALER:
      PlayerData.ability_set = healer_set
  PlayerData.set_role(role)
