using System;
using UnityEngine;

namespace pdinklag.CPW.Common
{
    /// <summary>
    /// A moveset entry of four moves from which the player can choose
    /// by using directional input. There is no "middle".
    /// </summary>
    [Serializable]
    public class StrictDirectionChoiceMovesetEntry : MovesetEntry<StrictDirectionChoiceMovesetEntry>
    {
        [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[] { Up, Right, Down, Left };

        public StrictDirectionChoiceMovesetEntry()
        {
        }

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

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