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

namespace eagle {
    public class OrganizeTroopsComponentRow : MonoBehaviour {
        public TMP_Text sizeField;
        public TMP_Text armamentField;
        public TMP_Text trainingField;

        public Image sizeBackground;
        public Image armamentBackground;
        public Image trainingBackground;

        public BattalionComponent BattalionComponent {
            set {
                armamentField.text = Math.Floor(value.armament).ToString();
                trainingField.text = Math.Floor(value.training).ToString();
                sizeField.text = value.count.ToString();

                Color color = Color.black;
                switch (value.source) {
                    case BattalionComponent.ComponentSource.originalTroops:
                        color = Color.black;
                        break;

                    case BattalionComponent.ComponentSource.mergedTroops: color = Color.blue; break;

                    case BattalionComponent.ComponentSource.newTroops: color = Color.green; break;
                }

                color.a = 0.25f;

                sizeBackground.color = color;
                armamentBackground.color = color;
                trainingBackground.color = color;
            }
        }
        // Start is called before the first frame update
        void Start() {}
    }
}