using System;
using System.Collections.Generic;
using Domain.Input;

namespace Domain {
	public class CustomInput {
		private readonly Dictionary<Type, InputReader> _readers = new();
		private readonly KeyHistory _history;

		public CustomInput() {
			_history = new KeyHistory();

			_readers.Add(typeof(CedillaReader), new CedillaReader());
			_readers.Add(typeof(GeminadaReader), new GeminadaReader(_history));
			_readers.Add(typeof(TxReader), new TxReader(_history));
			_readers.Add(typeof(IxReader), new IxReader(_history));
			_readers.Add(typeof(NyReader), new NyReader(_history));
			_readers.Add(typeof(TgReader), new TgReader(_history));
			_readers.Add(typeof(TjReader), new TjReader(_history));
			_readers.Add(typeof(LlReader), new LlReader(_history));
			_readers.Add(typeof(SsReader), new SsReader(_history));
		}

		public void UpdateInput() {
			_history.CheckPresses();
			foreach (KeyValuePair<Type, InputReader> reader in _readers) {
				reader.Value.UpdateInput();
			}
		}

		public bool KeyDown(Type key) => _readers[key].KeyDown();
	}
}