using System;
using System.Collections.Generic;
using UnityEngine;

namespace Jovian.EncounterSystem {
    public interface IEncounter {
        EncounterDefinition EncounterDefinition { get; set; }
        EncounterProperties EncounterProperties { get; set; }
        EncounterVisuals EncounterVisuals { get; set; }
        EncounterDialogOptionSet EncounterDialogOptionSet { get; set; }
    }

    /// <summary>Default concrete encounter. Extend via a new <see cref="IEncounterKind"/>, not by subclassing.</summary>
    [Serializable]
    public class Encounter : IEncounter {
        [field: SerializeField] public EncounterDefinition EncounterDefinition { get; set; }
        [field: SerializeField] public EncounterProperties EncounterProperties { get; set; }
        [field: SerializeField] public EncounterVisuals EncounterVisuals { get; set; }
        [field: SerializeField] public EncounterDialogOptionSet EncounterDialogOptionSet { get; set; }
    }

    [Serializable]
    public class EncounterDefinition {
        /// <summary>Stable GUID assigned at creation. Never edit manually.</summary>
        [HideInInspector]
        public string internalId = Guid.NewGuid().ToString();

        public string id;
        public string name;
        public string description;
        [field: SerializeReference, SubclassSelector] public IEncounterKind Kind { get; set; }
    }

    [Serializable]
    public class EncounterDialogOption {
        public DialogLineRef text;

        [SerializeReference, SubclassSelector]
        public List<IEncounterEvent> events;
    }

    [Serializable]
    public class EncounterVisuals {
        public Sprite icon;
        public Color encounterColor;
        public Sprite encounterArt;
    }

     [Serializable]
    public class EncounterProperties {
        public int difficulty;
        public bool isRepeatable = true;
    }
}
