using System.Globalization;

namespace Decal.Filters;

public sealed class SpellSchool
{
	private static SpellSchool[] sSchools = new SpellSchool[5]
	{
		new SpellSchool(1, "War Magic"),
		new SpellSchool(2, "Life Magic"),
		new SpellSchool(3, "Item Enchantment"),
		new SpellSchool(4, "Creature Enchantment"),
		new SpellSchool(5, "Void Magic")
	};

	private int mId;

	private string mName;

	public int Id => mId;

	public string Name => mName;

	public static SpellSchool GetById(int id)
	{
		for (int i = 0; i < sSchools.Length; i++)
		{
			if (sSchools[i].Id == id)
			{
				return sSchools[i];
			}
		}
		return null;
	}

	public static SpellSchool GetByName(string name)
	{
		for (int i = 0; i < sSchools.Length; i++)
		{
			if (string.Compare(sSchools[i].Name, name, ignoreCase: true, CultureInfo.InvariantCulture) == 0)
			{
				return sSchools[i];
			}
		}
		return null;
	}

	private SpellSchool(int id, string name)
	{
		mId = id;
		mName = name;
	}

	public override string ToString()
	{
		return mName;
	}
}
