diff --git a/KoogleApp/Components/Controls/NumberPanel.razor b/KoogleApp/Components/Controls/NumberPanel.razor index 0802a8f..4d71333 100644 --- a/KoogleApp/Components/Controls/NumberPanel.razor +++ b/KoogleApp/Components/Controls/NumberPanel.razor @@ -5,12 +5,14 @@ @using KoogleApp.Store.Game.Participants @using KoogleApp.Store.Game.Setup @using KoogleApp.Store.Game.ThrowPanel +@using KoogleApp.Store.Player @inherits FluxorComponent @inject IState ThrowPanelState @inject IDispatcher Dispatcher @inject IState ParticipantsState +@inject IState PlayersState @inject IState SetupState @if (ThrowPanelState.Value.IsStated) @@ -132,11 +134,11 @@ { @if (SetupState.Value.ParticipantsMode == ParticipantsMode.FreeToChoose) { - + } else { -

@($"P: {@ParticipantsState.Value.PlayerIds.FirstOrDefault()}")

+ @ParticipantsState.GetName(PlayersState); } } diff --git a/KoogleApp/Components/Pages/Game.razor b/KoogleApp/Components/Pages/Game.razor index 1bd591c..3528da0 100644 --- a/KoogleApp/Components/Pages/Game.razor +++ b/KoogleApp/Components/Pages/Game.razor @@ -35,17 +35,17 @@ @inject IDispatcher Dispatcher @inject IDialogService DialogService -@* @inject IGameStatusDataService _dataService; *@ - +@inject IGameStatusDataService DataService; +@* @ThrowPanelState.Value *@ @switch (_gameView) { case GameView.Throw: - - @* @GetParticipantsState() *@ - @GetSetupState(); + @* @DayState.Value *@ +@* @GetParticipantsState() + @GetSetupState(); *@ @if (DayState.Value.Status != DayStatus.Started) { @@ -105,21 +105,10 @@ private bool isAuthenticated; - protected override void OnInitialized() - { + { + base.OnInitialized(); - - // Verbindung zum Hub aufbauen (nur einmal) - - - // if (!ThrowPanelState.Value.IsConnected) - { - Dispatcher.Dispatch(new ConnectToHubAction()); - Dispatcher.Dispatch(new InitializeDayAction()); - - Dispatcher.Dispatch(new UpdateUndoRedoStateAction()); - } } protected override void OnAfterRender(bool firstRender) @@ -127,6 +116,11 @@ if (firstRender) { EventAggregator.Subscribe(this); + + Dispatcher.Dispatch(new ConnectToHubAction()); + Dispatcher.Dispatch(new InitializeDayAction()); + + DataService.LoadFromFile(); } } diff --git a/KoogleApp/Services/GameStatusDataService.cs b/KoogleApp/Services/GameStatusDataService.cs index c8d604f..7cb3266 100644 --- a/KoogleApp/Services/GameStatusDataService.cs +++ b/KoogleApp/Services/GameStatusDataService.cs @@ -294,6 +294,10 @@ namespace KoogleApp.Services if (history != null) { + if (_undoStack == null) + { + _undoStack = new Stack(); + } _undoStack.Clear(); foreach (var snapshot in history.AsEnumerable().Reverse()) { @@ -310,6 +314,10 @@ namespace KoogleApp.Services if (redoHistory != null) { + if (_redoStack == null) + { + _redoStack = new Stack(); + } _redoStack.Clear(); foreach (var snapshot in redoHistory.AsEnumerable().Reverse()) { diff --git a/KoogleApp/Store/Game/Participants/Selectors.cs b/KoogleApp/Store/Game/Participants/Selectors.cs new file mode 100644 index 0000000..4c9239c --- /dev/null +++ b/KoogleApp/Store/Game/Participants/Selectors.cs @@ -0,0 +1,22 @@ +using Fluxor; +using KoogleApp.Store.Player; + +namespace KoogleApp.Store.Game.Participants +{ + public static class ParticipantsSelectors + { + //public static string GetName(IState players, IState participants) + //{ + // return players.Value.Players.First(p => p.Id == participants.Value.PlayerIds.First()).Name; + //} + + public static string GetName(this IState participants, IState players) + { + if (participants.Value == null || participants.Value.PlayerIds.Length == 0) + { + return string.Empty; + } + return players.Value.Players.First(p => p.Id == participants.Value.PlayerIds.First()).Name; + } + } +} diff --git a/KoogleApp/appdata.json b/KoogleApp/appdata.json deleted file mode 100644 index 9443f39..0000000 --- a/KoogleApp/appdata.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "CurrentData": { - "Status": { - "SetupState": null, - "ThrowPanelState": { - "IsStated": true, - "BellValue": false, - "Pin1State": 0, - "Pin2State": 0, - "Pin3State": 0, - "Pin4State": 0, - "Pin5State": 0, - "Pin6State": 0, - "Pin7State": 0, - "Pin8State": 0, - "Pin9State": 0, - "ThrowsPerRound": 3, - "ThrowCounterPerRound": 1, - "ThrowMode": 0, - "ThrowPanelStateStatus": 1, - "ThrowCounter": 0, - "DayId": 35 - }, - "ParticipantsState": { - "PlayerIds": [ - 5, - 3, - 10, - 12, - 9 - ], - "Eliminated": [] - } - }, - "Version": 2, - "LastModified": "2025-11-21T19:30:06.7529818+01:00", - "LastModifiedBy": "test1@test.de" - }, - "UndoHistory": [ - { - "Status": { - "SetupState": { - "ThrowMode": 0, - "ThrowsPerRound": 3, - "Players": [ - 5, - 3, - 10, - 12, - 9 - ], - "ParticipantsMode": 0 - }, - "ThrowPanelState": { - "IsStated": true, - "BellValue": false, - "Pin1State": 0, - "Pin2State": 0, - "Pin3State": 0, - "Pin4State": 0, - "Pin5State": 0, - "Pin6State": 0, - "Pin7State": 0, - "Pin8State": 0, - "Pin9State": 0, - "ThrowsPerRound": 3, - "ThrowCounterPerRound": 1, - "ThrowMode": 0, - "ThrowPanelStateStatus": 1, - "ThrowCounter": 0, - "DayId": 35 - }, - "ParticipantsState": { - "PlayerIds": [ - 5, - 3, - 10, - 12, - 9 - ], - "Eliminated": [] - } - }, - "Version": 1, - "LastModified": "2025-11-21T19:30:06.7492871+01:00", - "LastModifiedBy": "test1@test.de" - } - ], - "RedoHistory": [] -} \ No newline at end of file