using System;
using UnityEngine;

public class TurnSystem : MonoBehaviour {
    private int turnNumber = 1;
    public static TurnSystem Instance { get; private set; }
    public bool IsPlayerTurn { get; private set; } = true;

    public int TurnNumber {
        get => turnNumber;
        private set {
            turnNumber = value;
            OnTurnChanged?.Invoke(this, EventArgs.Empty);
        }
    }

    private void Awake() {
        if (Instance is not null) {
            Debug.LogError($"There is more than one TurnSystem! {transform} - {Instance}");
            Destroy(gameObject);
            return;
        }
        Instance = this;
    }

    public event EventHandler OnTurnChanged;

    public void NextTurn() {
        IsPlayerTurn = !IsPlayerTurn;
        TurnNumber++;
    }
}