using Blazored.LocalStorage;
namespace FWLAZ_Web.Objects
{


    public class SessionState
    {
        public GameState? LoadGame { get; set; }

        private ILocalStorageService localStorage;
        public SessionState(ILocalStorageService localStorage)
        {
            this.localStorage = localStorage;
        }


        public async Task LoadAsync()
        {
            try
            {
                LoadGame = await localStorage.GetItemAsync<GameState>(nameof(LoadGame));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error loading state: {ex.Message}");
            }
        }

        public async Task SaveAsync()
        {
            await localStorage.SetItemAsync(nameof(LoadGame), LoadGame);
        }
    }
}
