class_name ActionBox extends GridContainer

enum Action {
  ATTACK,
  MAGIC,
  ITEM,
  BACK
}

@export var btnAttack:Button
@export var btnMagic:Button
@export var btnItem:Button
@export var btnBack:Button

signal action(action:Action)

func _ready() -> void:
  btnAttack.pressed.connect(func():
    action.emit(Action.ATTACK)
  )
  btnMagic.pressed.connect(func():
    action.emit(Action.MAGIC)
  )
  btnItem.pressed.connect(func():
    action.emit(Action.ITEM)
  )
  btnBack.pressed.connect(func():
    action.emit(Action.BACK)
  )
  self.visible = false

func getAction(fighter:BattleFighter) -> Action:
  btnAttack.disabled = fighter.movePrimary == null || !fighter.movePrimary.canFighterUse(fighter)
  btnMagic.disabled = fighter.movesMagical.size() == 0
  btnItem.disabled = false # TODO: check if items available?

  var act = await action
  return act
