using System;
using System.Collections.Generic;
using Godot;

public static partial class Globals
{
    public static bool _animationRunning;
    public static Random _rng = new();
    public static List<string> _addressTranslation = new(){"NW","N","NE","W","C","E","SW","S","SE"};

    public static List<T> ShiftList<T>(List<T> LIST, int SHIFT_BY)
    {
        if (LIST.Count <= SHIFT_BY || LIST.Count == 0 || SHIFT_BY ==0)
        {
            return LIST;
        }
        int getRangeStart = SHIFT_BY < 0 ? -SHIFT_BY : LIST.Count - SHIFT_BY;
        int getRangeEnd = SHIFT_BY < 0 ? LIST.Count + SHIFT_BY : SHIFT_BY;
        int addRangeEnd = SHIFT_BY < 0 ? -SHIFT_BY : LIST.Count - SHIFT_BY;
        var result = LIST.GetRange(getRangeStart, getRangeEnd);
        result.AddRange(LIST.GetRange(0, addRangeEnd));
        return result;
    }

    public static void Shuffle<T>(IList<T> LIST)
    {
        int n = LIST.Count;
        while (n > 1) {
            n--;
            int k = _rng.Next(n + 1);
            T value = LIST[k];
            LIST[k] = LIST[n];
            LIST[n] = value;
        }
    }

    public static void LoadSeed(int SEED)
    {
        _rng = new(SEED);
    }
}