using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace eagle {
    public class ArmTroopsRowController : TableRowController {
        public RawImage battalionImage;
        public TMP_Text oldArmamentLabel;
        public TMP_Text newArmamentLabel;
        public TMP_Text sizeLabel;
        public TMP_Text costPerPointLabel;
        public TMP_Text nameLabel;

        public Button plusButton;
        public Button minusButton;
        public Button resetButton;
        public Button maxButton;

        public Action PlusButtonClickedCallback;
        public Action MinusButtonClickedCallback;
        public Action ResetButtonClickedCallback;
        public Action MaxButtonClickedCallback;

        public Texture BattalionImage { set => battalionImage.texture = value; }

        public double CostPerPoint { set => costPerPointLabel.text = value.ToString("0.##"); }

        public double OldArmament { set => oldArmamentLabel.text = Math.Floor(value).ToString(); }

        public double NewArmament { set => newArmamentLabel.text = Math.Floor(value).ToString(); }

        public int Size { set => sizeLabel.text = value.ToString(); }

        public string Name { set => nameLabel.text = value; }

        public bool AllowPlus { set => plusButton.interactable = value; }

        public bool AllowMinus { set => minusButton.interactable = value; }

        public bool AllowReset { set => resetButton.interactable = value; }

        public bool AllowMax { set => maxButton.interactable = value; }

        public void PlusButtonClicked() { PlusButtonClickedCallback(); }

        public void MinusButtonClicked() { MinusButtonClickedCallback(); }

        public void ResetButtonClicked() { ResetButtonClickedCallback(); }

        public void MaxButtonClicked() { MaxButtonClickedCallback(); }
    }
}
