using System;
using UnityEngine;

namespace pdinklag.CPW.Common
{
    /// <summary>
    /// A moveset entry of five moves from which the player can choose
    /// by using the analog stick.
    /// </summary>
    [Serializable]
    public class DirectionChoiceMovesetEntry : MovesetEntry<DirectionChoiceMovesetEntry>
    {
        [Tooltip("The move chosen if the analog stick is left in the middle.")]
        public AssetAddress Middle;

        [Tooltip("The move chosen if the analog stick is pointing up.")]
        public AssetAddress Up;

        [Tooltip("The move chosen if the analog stick is pointing right.")]
        public AssetAddress Right;

        [Tooltip("The move chosen if the analog stick is pointing down.")]
        public AssetAddress Down;

        [Tooltip("The move chosen if the analog stick is pointing left.")]
        public AssetAddress Left;

        public override AssetAddress[] Moves => new AssetAddress[] { Middle, Up, Right, Down, Left };

        public DirectionChoiceMovesetEntry()
        {
        }

        public DirectionChoiceMovesetEntry(DirectionChoiceMovesetEntry other)
        {
            Middle = other.Middle;
            Up = other.Up;
            Right = other.Right;
            Down = other.Down;
            Left = other.Left;
        }

        public override void Merge(DirectionChoiceMovesetEntry other)
        {
            Middle = OverrideIfValid(Middle, other.Middle);
            Up = OverrideIfValid(Up, other.Up);
            Right = OverrideIfValid(Right, other.Right);
            Down = OverrideIfValid(Down, other.Down);
            Left = OverrideIfValid(Left, other.Left);
        }
    }
}
