fix handle participants and undo

This commit is contained in:
beo3000 2025-11-21 14:52:06 +01:00
parent 0884c8da60
commit e2fdb23f56
8 changed files with 37 additions and 28 deletions

View File

@ -30,7 +30,7 @@
{
get
{
if (ParticipantsState.Value.PlayerIds.Length > 0)
if (ParticipantsState.Value != null && ParticipantsState.Value.PlayerIds.Length > 0)
{
return PlayersState.Value.Players.FirstOrDefault(_ => _.Id == ParticipantsState.Value.PlayerIds.First());
}
@ -50,7 +50,7 @@
// set;
// } = null!;
[Parameter,EditorRequired]
[Parameter]
public Func<PlayersState, PlayerState> ValueSelector
{
get;

View File

@ -125,15 +125,18 @@
<MudItem xs="12">
<MudPaper Class="pa-4 d-flex align-center justify-center mud-width-full" Style="height: 76px;">
<ChangePlayerSelect/>
@if (CanSelectPlayer)
<MudPaper Class="pa-4 d-flex align-center justify-center mud-width-full" Style="height: 76px;">
@if (ParticipantsState.Value != null)
{
<ChangePlayerSelect/>
@if (CanSelectPlayer)
{
}
else
{
<p>@($"P: {@ParticipantsState.Value.PlayerIds.FirstOrDefault()}")</p>
}
else
{
<p>@($"P: {@ParticipantsState.Value.PlayerIds.FirstOrDefault()}")</p>
}
}
</MudPaper>
</MudItem>

View File

@ -205,7 +205,7 @@ namespace KoogleApp.Services
{
return false;
}
return _undoStack.Count > 0;
return _undoStack.Count > 1;
}
}

View File

@ -35,5 +35,11 @@ namespace KoogleApp.Store.Game.Participants
PlayerIds = lst.ToArray()
};
}
[ReducerMethod]
public static ParticipantsState OnUpdateStateAfterUndoRedo(ParticipantsState state, UpdateStateAfterUndoRedo action)
{
return action.ParticipantsState;
}
}
}

View File

@ -35,7 +35,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
public record ThrowUpdateAction(bool LeftSink, bool RightSink);
public record AfterUndoRedoAction(ThrowPanelState State);
public record UpdateStateAfterUndoRedo(ThrowPanelState ThrowPanelState, ParticipantsState ParticipantsState);
public record EnsureBeforeThrowStatusAction(ParticipantsState ParticipantsState);

View File

@ -288,9 +288,9 @@ namespace KoogleApp.Store.Game.ThrowPanel
}
[ReducerMethod]
public static ThrowPanelState OnAfterUndoRedo(ThrowPanelState state, AfterUndoRedoAction action)
public static ThrowPanelState OnUpdateStateAfterUndoRedo(ThrowPanelState state, UpdateStateAfterUndoRedo action)
{
return action.State;
return action.ThrowPanelState;
}
}
}

View File

@ -33,7 +33,7 @@ namespace KoogleApp.Store.Game.UndoRedo
if (success)
{
var currentData = _dataService.GetCurrentData();
dispatcher.Dispatch(new AfterUndoRedoAction(currentData.Status.ThrowPanelState));
dispatcher.Dispatch(new UpdateStateAfterUndoRedo(currentData.Status.ThrowPanelState, currentData.Status.ParticipantsState));
}
dispatcher.Dispatch(new UpdateUndoRedoStateAction());
@ -48,7 +48,7 @@ namespace KoogleApp.Store.Game.UndoRedo
if (success)
{
var currentData = _dataService.GetCurrentData();
dispatcher.Dispatch(new AfterUndoRedoAction(currentData.Status.ThrowPanelState));
dispatcher.Dispatch(new UpdateStateAfterUndoRedo(currentData.Status.ThrowPanelState, currentData.Status.ParticipantsState));
}
dispatcher.Dispatch(new UpdateUndoRedoStateAction());

View File

@ -22,15 +22,15 @@
},
"ParticipantsState": {
"PlayerIds": [
9,
5,
3
3,
9
],
"Eliminated": []
}
},
"Version": 4,
"LastModified": "2025-11-21T13:31:18.7132247+01:00",
"LastModified": "2025-11-21T14:49:53.2943989+01:00",
"LastModifiedBy": "test1@test.de"
},
"UndoHistory": [
@ -42,11 +42,11 @@
"Pin1State": 0,
"Pin2State": 0,
"Pin3State": 0,
"Pin4State": 0,
"Pin5State": 0,
"Pin6State": 0,
"Pin7State": 0,
"Pin8State": 0,
"Pin4State": 1,
"Pin5State": 1,
"Pin6State": 1,
"Pin7State": 1,
"Pin8State": 1,
"Pin9State": 1,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 1,
@ -57,15 +57,15 @@
},
"ParticipantsState": {
"PlayerIds": [
9,
5,
3
3,
9
],
"Eliminated": []
}
},
"Version": 3,
"LastModified": "2025-11-21T13:31:18.7088636+01:00",
"LastModified": "2025-11-21T14:49:53.289455+01:00",
"LastModifiedBy": "test1@test.de"
},
{
@ -99,7 +99,7 @@
}
},
"Version": 2,
"LastModified": "2025-11-21T13:31:10.7173634+01:00",
"LastModified": "2025-11-21T14:49:31.5450392+01:00",
"LastModifiedBy": "test1@test.de"
},
{
@ -126,7 +126,7 @@
"ParticipantsState": null
},
"Version": 1,
"LastModified": "2025-11-21T13:31:10.7160527+01:00",
"LastModified": "2025-11-21T14:49:31.5423511+01:00",
"LastModifiedBy": "test1@test.de"
}
],