using Domain;
using Domain.Input;
using Presenter;
using TMPro;
using UnityEngine;

namespace View {
	public class CTrencadaInput : MonoBehaviour, ICTrencadaInput {
		[SerializeField] private TMP_Text text;
		private CTrencadaClick _click;
		private CustomInput _customInput;

		private void Start() {
			_click = FindObjectOfType<Dependencies>().CTrencadaClick;
			_customInput = FindObjectOfType<Dependencies>().CustomInput;
		}

		private void Update() {
			CheckInput();
		}

		private void CheckInput() {
			_customInput.UpdateInput();

			if (_customInput.KeyDown(typeof(GeminadaReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(CedillaReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(IxReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(LlReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(NyReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(SsReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(TgReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(TjReader)))
				_click.Execute();
			if (_customInput.KeyDown(typeof(TxReader)))
				_click.Execute();
		}

		public void UpdateView(int score) {
			text.text = score.ToString();
		}
	}
}