using System;
using SlatedGameToolkit.Framework.Logging;

namespace SlatedGameToolkit.Tools.CommandSystem.Interaction
{
    public class ConsoleInteraction : IInteractable
    {
        private volatile bool listening;
        public bool Listening { get {return listening;}}
        string prefix;
        public string Prefix {get {return prefix;}}
        public bool Debug { get; set; }
        public LogLevel Level => Debug ? LogLevel.DEBUG : LogLevel.INFO;

        public ConsoleInteraction(string prefix) {
            this.prefix = prefix;
        }

        public void Separate()
        {
            listening = false;
            Console.WriteLine();
        }

        public string Listen()
        {
            listening = true;
            Console.Write(prefix + "> ");
            return Console.ReadLine();
        }

        public void Tell(string message)
        {
            listening = false;
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.WriteLine(message);
        }
    }
}