using System.Linq;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.Moves;

namespace PkmnLibSharpTests.Library
{
    public class LearnableMovesTests
    {
        private static MoveData CreateTestMove(string name)
        {
            return new MoveData(name, 0, MoveCategory.Physical, 100, 100, 5, MoveTarget.Any,
                0, 0, "", new EffectParameter[0], new string[0]);
        }
        
        [Test]
        public void AddLevelMoves()
        {
            var moves = new LearnableMoves(100);
            moves.AddLevelMove(1, CreateTestMove("foo"));
            moves.AddLevelMove(5, CreateTestMove("bar"));
            moves.Dispose();
        }
        
        [Test]
        public void AddAndGetLevelMoves()
        {
            var moves = new LearnableMoves(100);
            var fooMove = CreateTestMove("foo");
            var barMove = CreateTestMove("bar");
            moves.AddLevelMove(1, fooMove);
            moves.AddLevelMove(1, barMove);
            moves.AddLevelMove(5, barMove);
            
            
            Assert.AreEqual(2, moves.GetMovesForLevel(1).Count);
            Assert.AreEqual("foo", moves.GetMovesForLevel(1)[0].Name);
            Assert.AreEqual("bar", moves.GetMovesForLevel(1)[1].Name);
            Assert.AreEqual(1, moves.GetMovesForLevel(5).Count);
            Assert.AreEqual(0, moves.GetMovesForLevel(2).Count);
            
            moves.Dispose();
        }

        [Test]
        public void GetDistinctLevelMoves()
        {
            var moves = new LearnableMoves(100);
            var fooMove = CreateTestMove("foo");
            var barMove = CreateTestMove("bar");
            moves.AddLevelMove(1, fooMove);
            moves.AddLevelMove(1, barMove);
            moves.AddLevelMove(5, barMove);

            var distinctMoves = moves.DistinctLevelMoves;
            Assert.AreEqual(2, distinctMoves.Count);
            Assert.AreEqual("foo", distinctMoves[0].Name);
            Assert.AreEqual("bar", distinctMoves[1].Name);
            
            moves.Dispose();
        }

    }
}