created daystate
This commit is contained in:
parent
99505c1cb4
commit
df85efcfd2
|
|
@ -8,6 +8,7 @@
|
||||||
@using KoogleApp.Components.Dialogs
|
@using KoogleApp.Components.Dialogs
|
||||||
@using KoogleApp.Model.EventMessages
|
@using KoogleApp.Model.EventMessages
|
||||||
@using KoogleApp.Model.Framework
|
@using KoogleApp.Model.Framework
|
||||||
|
@using KoogleApp.Store.Day
|
||||||
@using KoogleApp.Store.Game
|
@using KoogleApp.Store.Game
|
||||||
@using KoogleApp.Store.Game.ThrowPanel
|
@using KoogleApp.Store.Game.ThrowPanel
|
||||||
@using KoogleApp.Store.Game.UndoRedo
|
@using KoogleApp.Store.Game.UndoRedo
|
||||||
|
|
@ -23,7 +24,7 @@
|
||||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||||
@inject IMyEventAggregator EventAggregator
|
@inject IMyEventAggregator EventAggregator
|
||||||
@inject IState<ThrowPanelState> ThrowPanelState
|
@inject IState<ThrowPanelState> ThrowPanelState
|
||||||
@inject IState<UndoRedoState> UndoRedoState
|
@inject IState<DayState> DayState
|
||||||
@inject IDispatcher Dispatcher
|
@inject IDispatcher Dispatcher
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
|
|
||||||
|
|
@ -56,7 +57,14 @@
|
||||||
@switch (_gameView)
|
@switch (_gameView)
|
||||||
{
|
{
|
||||||
case GameView.Throw:
|
case GameView.Throw:
|
||||||
<ThrowPanel />
|
if (DayState.Value.Status == DayStatus.New)
|
||||||
|
{
|
||||||
|
<p>todo</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<ThrowPanel />
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GameView.Board:
|
case GameView.Board:
|
||||||
<BoardPanel />
|
<BoardPanel />
|
||||||
|
|
@ -89,6 +97,8 @@
|
||||||
// if (!ThrowPanelState.Value.IsConnected)
|
// if (!ThrowPanelState.Value.IsConnected)
|
||||||
{
|
{
|
||||||
Dispatcher.Dispatch(new ConnectToHubAction());
|
Dispatcher.Dispatch(new ConnectToHubAction());
|
||||||
|
Dispatcher.Dispatch(new InitializeDayAction());
|
||||||
|
|
||||||
Dispatcher.Dispatch(new UpdateUndoRedoStateAction());
|
Dispatcher.Dispatch(new UpdateUndoRedoStateAction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Fluxor.Blazor.Web" Version="6.8.0" />
|
<PackageReference Include="Fluxor.Blazor.Web" Version="6.8.0" />
|
||||||
|
<PackageReference Include="Fluxor.Blazor.Web.ReduxDevTools" Version="6.8.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="9.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="9.0.10" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.10" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.10" />
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using KoogleApp.Data;
|
||||||
using KoogleApp.Data.Repository;
|
using KoogleApp.Data.Repository;
|
||||||
using KoogleApp.Hub;
|
using KoogleApp.Hub;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Fluxor.Blazor.Web.ReduxDevTools;
|
||||||
|
|
||||||
namespace KoogleApp.Services
|
namespace KoogleApp.Services
|
||||||
{
|
{
|
||||||
|
|
@ -11,7 +12,8 @@ namespace KoogleApp.Services
|
||||||
public static IServiceCollection AddAppServices(this IServiceCollection services)
|
public static IServiceCollection AddAppServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddFluxor(x =>
|
services.AddFluxor(x =>
|
||||||
x.ScanAssemblies(typeof(ServiceExtension).Assembly));
|
x.ScanAssemblies(typeof(ServiceExtension).Assembly)
|
||||||
|
.UseReduxDevTools());
|
||||||
|
|
||||||
services.AddScopedEventAggregator();
|
services.AddScopedEventAggregator();
|
||||||
services.AddScoped<SessionStorage>();
|
services.AddScoped<SessionStorage>();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
namespace KoogleApp.Store.Day
|
||||||
|
{
|
||||||
|
public record InitializeDayAction();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Fluxor;
|
||||||
|
using Fluxor.Blazor.Web;
|
||||||
|
using KoogleApp.Data;
|
||||||
|
|
||||||
|
namespace KoogleApp.Store.Day
|
||||||
|
{
|
||||||
|
public class DayStateEffects
|
||||||
|
{
|
||||||
|
private readonly SharedDataService _dataService;
|
||||||
|
|
||||||
|
public DayStateEffects(SharedDataService dataService)
|
||||||
|
{
|
||||||
|
_dataService = dataService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[EffectMethod]
|
||||||
|
public async Task HandleInitializeDayAction(InitializeDayAction action, IDispatcher dispatcher)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using Fluxor;
|
||||||
|
using KoogleApp.Data;
|
||||||
|
|
||||||
|
namespace KoogleApp.Store.Day
|
||||||
|
{
|
||||||
|
public class DayStateFeature : Feature<DayState>
|
||||||
|
{
|
||||||
|
private readonly SharedDataService _dataService;
|
||||||
|
|
||||||
|
public DayStateFeature(SharedDataService dataService)
|
||||||
|
{
|
||||||
|
_dataService = dataService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetName() => "DayState";
|
||||||
|
|
||||||
|
protected override DayState GetInitialState()
|
||||||
|
{
|
||||||
|
return new DayState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using Fluxor;
|
||||||
|
|
||||||
|
namespace KoogleApp.Store.Day
|
||||||
|
{
|
||||||
|
public static class DayStateReducers
|
||||||
|
{
|
||||||
|
//[ReducerMethod]
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Fluxor;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace KoogleApp.Store.Day
|
||||||
|
{
|
||||||
|
public enum DayStatus
|
||||||
|
{
|
||||||
|
New,
|
||||||
|
Started,
|
||||||
|
Finished
|
||||||
|
}
|
||||||
|
|
||||||
|
//[FeatureState]
|
||||||
|
public record DayState(int Number, DateTime Date, DayStatus Status)
|
||||||
|
{
|
||||||
|
public DayState() : this(Number: 0, Date: DateTime.Today, Status: DayStatus.New)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,11 +3,11 @@ using KoogleApp.Data;
|
||||||
|
|
||||||
namespace KoogleApp.Store.Player
|
namespace KoogleApp.Store.Player
|
||||||
{
|
{
|
||||||
public class PlayerEffects
|
public class PlayerStateEffects
|
||||||
{
|
{
|
||||||
private readonly SharedDataService _dataService;
|
private readonly SharedDataService _dataService;
|
||||||
|
|
||||||
public PlayerEffects(SharedDataService dataService)
|
public PlayerStateEffects(SharedDataService dataService)
|
||||||
{
|
{
|
||||||
_dataService = dataService;
|
_dataService = dataService;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
|
|
||||||
namespace KoogleApp.Store.Player
|
namespace KoogleApp.Store.Player
|
||||||
{
|
{
|
||||||
public class PlayersStateReducers
|
public static class PlayersStateReducers
|
||||||
{
|
{
|
||||||
[ReducerMethod]
|
[ReducerMethod]
|
||||||
public static PlayersState OnPlayersLoaded(PlayersState state, PlayersLoadedAction action)
|
public static PlayersState OnPlayersLoaded(PlayersState state, PlayersLoadedAction action)
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,10 @@ Update Database:
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
- Redo State after start / lode or game stop
|
- Redo State after start / lode or game stop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Fluxor:
|
||||||
|
- https://dev.to/mr_eking/advanced-blazor-state-management-using-fluxor-part-5-14j2
|
||||||
-
|
-
|
||||||
Loading…
Reference in New Issue