using Newtonsoft.Json;
using static GrizzenServer.AccessLevel;

namespace GrizzenServer
{
    public class ScoreCmd : Cmd
    {
        public ScoreCmd(Client client) : base(client)
        {
            AccessLevel = Guest;
        }

        public static void Notify(string actor, Score score)
        {
            Clients.TellBody(actor, "Score", JsonConvert.SerializeObject(score));
        }

        public override void Run()
        {
            if (HasAccess)
            {
                Notify(Actor, Db.Score(Actor));
            }
        }
    }
}
