load game model from file

This commit is contained in:
beo3000 2025-11-27 08:02:40 +01:00
parent 2e5892444d
commit 49be125e74
14 changed files with 40 additions and 2326 deletions

View File

@ -1,6 +1,5 @@
@using KoogleApp.Games.Training @using KoogleApp.Games.Training
@using KoogleApp.Model @using KoogleApp.Model
@using KoogleApp.Store.Game.GameState
@using KoogleApp.Store.Game.Setup @using KoogleApp.Store.Game.Setup
@using KoogleApp.Store.Game.ThrowTimer @using KoogleApp.Store.Game.ThrowTimer

View File

@ -2,7 +2,6 @@
using Fluxor; using Fluxor;
using KoogleApp.Games.Training; using KoogleApp.Games.Training;
using KoogleApp.Model; using KoogleApp.Model;
using KoogleApp.Store.Game.GameState;
using KoogleApp.Store.Game.ThrowPanel; using KoogleApp.Store.Game.ThrowPanel;
namespace KoogleApp.Games namespace KoogleApp.Games

View File

@ -1,4 +1,4 @@
namespace KoogleApp.Games.Training namespace KoogleApp.Games.Training
{ {
public record UpdateTrainingStateAction(TrainingState TrainingState); //public record UpdateTrainingStateAction(TrainingState TrainingState);
} }

View File

@ -1,9 +1,9 @@
using Fluxor; using Fluxor;
using KoogleApp.Store.Game.GameState;
using KoogleApp.Store.Game.Participants; using KoogleApp.Store.Game.Participants;
using KoogleApp.Store.Game.ThrowPanel; using KoogleApp.Store.Game.ThrowPanel;
using System; using System;
using KoogleApp.Model; using KoogleApp.Model;
using KoogleApp.Store.Game;
using Microsoft.Identity.Client; using Microsoft.Identity.Client;
namespace KoogleApp.Games.Training namespace KoogleApp.Games.Training
@ -65,8 +65,9 @@ namespace KoogleApp.Games.Training
var newModel = ((TrainingState)(progress.GameModel)) with { Throws = ts.Throws }; var newModel = ((TrainingState)(progress.GameModel)) with { Throws = ts.Throws };
res.Add(new UpdateTrainingStateAction(newModel)); //res.Add(new UpdateTrainingStateAction(newModel));
res.Add(new GameModelChanged(newModel));
foreach (var action in res) foreach (var action in res)
{ {
dispatcher.Dispatch(action); dispatcher.Dispatch(action);

View File

@ -1,17 +1,15 @@
using Fluxor; using Fluxor;
using KoogleApp.Store.Game.GameState; using KoogleApp.Store.Game;
namespace KoogleApp.Games.Training namespace KoogleApp.Games.Training
{ {
public static class Reducers public static class Reducers
{ {
[ReducerMethod] [ReducerMethod]
public static TrainingState OnTestActions(TrainingState state, UpdateTrainingStateAction action) public static TrainingState? OnGameModelChanged(TrainingState state, GameModelChanged action)
{ {
return action.TrainingState; return action.Model as TrainingState;
} }
} }
} }

View File

@ -1,5 +1,4 @@
using KoogleApp.Games; using KoogleApp.Games;
using KoogleApp.Store.Game.GameState;
using KoogleApp.Store.Game.Participants; using KoogleApp.Store.Game.Participants;
using KoogleApp.Store.Game.Setup; using KoogleApp.Store.Game.Setup;
using KoogleApp.Store.Game.ThrowPanel; using KoogleApp.Store.Game.ThrowPanel;
@ -8,10 +7,10 @@ namespace KoogleApp.Model
{ {
public class GameStatusSnapshot public class GameStatusSnapshot
{ {
public GameStatus Status { get; set; } public GameStatus? Status { get; set; }
public int Version { get; set; } public int Version { get; set; }
public DateTime LastModified { get; set; } public DateTime LastModified { get; set; }
public string LastModifiedBy { get; set; } public string? LastModifiedBy { get; set; }
} }

View File

@ -0,0 +1,8 @@
using KoogleApp.Games;
namespace KoogleApp.Store.Game
{
public record GameModelChanged(IGameModel Model);
public record LoadGameStatesFromDataServiceAction();
}

View File

@ -0,0 +1,20 @@
using Fluxor;
using KoogleApp.Services;
namespace KoogleApp.Store.Game
{
public class GameStateEffects(IGameStatusDataService dataService)
{
[EffectMethod]
public async Task HandeLoadGameStatesFromSessionAction(LoadGameStatesFromDataServiceAction action, IDispatcher dispatcher)
{
var current = dataService.GetCurrentData();
if (current.Status != null)
{
var gameModel = current.Status.GameModel;
dispatcher.Dispatch(new GameModelChanged(gameModel));
}
}
}
}

View File

@ -1,8 +0,0 @@
using KoogleApp.Games;
namespace KoogleApp.Store.Game.GameState
{
public record GameModelChanged(IGameModel Model);
//public record LoadGameStatesFromSessionAction();
}

View File

@ -1,23 +0,0 @@
using Fluxor;
using KoogleApp.Services;
namespace KoogleApp.Store.Game.GameState
{
public class GameStateEffects(IGameStatusDataService dataService)
{
//[EffectMethod]
//public async Task HandeLoadGameStatesFromSessionAction(
// LoadGameStatesFromSessionAction allStatesFromSessionAction, IDispatcher dispatcher)
//{
// var current = dataService.GetCurrentData();
// if (current != null && current.Status != null)
// {
// var gameState = current.Status.GameState;
// dispatcher.Dispatch(new GameStateChanged(gameState));
// }
//}
}
}

View File

@ -1,13 +0,0 @@
using Fluxor;
using KoogleApp.Games;
using System.Text.Json.Serialization;
namespace KoogleApp.Store.Game.GameState
{
//[FeatureState]
//public sealed record GameState
//{
// [JsonConverter(typeof(KnownGameJsonConverter))]
// public IKnownGame? CurrentGame { get; init; } = null;
//}
}

View File

@ -1,16 +0,0 @@
using Fluxor;
using KoogleApp.Store.Game.ThrowPanel;
namespace KoogleApp.Store.Game.GameState
{
//public static class Reducers
//{
// [ReducerMethod]
// public static GameState OnReceiveStateFromServer(GameState state, GameStateChanged action)
// {
// return action.State;
// }
//}
}

View File

@ -5,7 +5,6 @@ using KoogleApp.Model;
using KoogleApp.Model.EventMessages; using KoogleApp.Model.EventMessages;
using KoogleApp.Model.Framework; using KoogleApp.Model.Framework;
using KoogleApp.Services; using KoogleApp.Services;
using KoogleApp.Store.Game.GameState;
using KoogleApp.Store.Game.Participants; using KoogleApp.Store.Game.Participants;
using KoogleApp.Store.Game.Setup; using KoogleApp.Store.Game.Setup;
using KoogleApp.Store.Game.ThrowTimer; using KoogleApp.Store.Game.ThrowTimer;
@ -279,7 +278,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
dispatcher.Dispatch(new LoadThrowPanelStatesFromSessionAction()); dispatcher.Dispatch(new LoadThrowPanelStatesFromSessionAction());
dispatcher.Dispatch(new LoadParticipantsStatesFromSessionAction()); dispatcher.Dispatch(new LoadParticipantsStatesFromSessionAction());
dispatcher.Dispatch(new LoadSetupStatesFromSessionAction()); dispatcher.Dispatch(new LoadSetupStatesFromSessionAction());
//dispatcher.Dispatch(new LoadGameStatesFromSessionAction()); dispatcher.Dispatch(new LoadGameStatesFromDataServiceAction());
} }
[EffectMethod] [EffectMethod]

File diff suppressed because it is too large Load Diff