fix state handling
This commit is contained in:
parent
c34efaa3c8
commit
e55ce2d53a
|
|
@ -12,5 +12,86 @@ namespace KoogleApp.Games
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsCircle(this GameProgress progress)
|
||||||
|
{
|
||||||
|
var res = 0;
|
||||||
|
var possible = progress.BeforeThrowState.Pin5State == PinStatus.Standing && progress.AfterThrowState.Pin5State == PinStatus.Standing;
|
||||||
|
if (progress.BeforeThrowState.Pin1State == PinStatus.Standing && progress.AfterThrowState.Pin1State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin2State == PinStatus.Standing && progress.AfterThrowState.Pin2State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin3State == PinStatus.Standing && progress.AfterThrowState.Pin3State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin4State == PinStatus.Standing && progress.AfterThrowState.Pin4State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin6State == PinStatus.Standing && progress.AfterThrowState.Pin6State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin7State == PinStatus.Standing && progress.AfterThrowState.Pin7State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin8State == PinStatus.Standing && progress.AfterThrowState.Pin8State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin9State == PinStatus.Standing && progress.AfterThrowState.Pin9State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
return res == 8 && possible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int PinCount(this GameProgress progress)
|
||||||
|
{
|
||||||
|
var res = 0;
|
||||||
|
if (progress.BeforeThrowState.Pin1State == PinStatus.Standing && progress.AfterThrowState.Pin1State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin2State == PinStatus.Standing && progress.AfterThrowState.Pin2State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin3State == PinStatus.Standing && progress.AfterThrowState.Pin3State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin4State == PinStatus.Standing && progress.AfterThrowState.Pin4State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin5State == PinStatus.Standing && progress.AfterThrowState.Pin5State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin6State == PinStatus.Standing && progress.AfterThrowState.Pin6State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin7State == PinStatus.Standing && progress.AfterThrowState.Pin7State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin8State == PinStatus.Standing && progress.AfterThrowState.Pin8State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
if (progress.BeforeThrowState.Pin9State == PinStatus.Standing && progress.AfterThrowState.Pin9State == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Spieler</th>
|
<th>Spieler</th>
|
||||||
<th>Würfe</th>
|
<th>Würfe</th>
|
||||||
|
<th>Kegel</th>
|
||||||
|
<th>Kränze</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -28,6 +30,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>@PlayersState.GetName(item.Key)</td>
|
<td>@PlayersState.GetName(item.Key)</td>
|
||||||
<td>@item.Value.ThrowCount</td>
|
<td>@item.Value.ThrowCount</td>
|
||||||
|
<td>@item.Value.PinCount</td>
|
||||||
|
<td>@item.Value.CircleCount</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,9 @@ namespace KoogleApp.Games.Training
|
||||||
var tm = ts.Throws[playerId];
|
var tm = ts.Throws[playerId];
|
||||||
ts.Throws[playerId] = tm with
|
ts.Throws[playerId] = tm with
|
||||||
{
|
{
|
||||||
ThrowCount = tm.ThrowCount+1
|
ThrowCount = tm.ThrowCount + 1,
|
||||||
|
PinCount = tm.PinCount + progress.PinCount(),
|
||||||
|
CircleCount = tm.CircleCount + Convert.ToInt32(progress.IsCircle())
|
||||||
};
|
};
|
||||||
|
|
||||||
var newModel = ((TrainingState)(progress.GameModel)) with { Throws = ts.Throws };
|
var newModel = ((TrainingState)(progress.GameModel)) with { Throws = ts.Throws };
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
|
|
||||||
public record ThrowAction(bool LeftSink, bool RightSink, ParticipantsState ParticipantsState);
|
public record ThrowAction(bool LeftSink, bool RightSink, ParticipantsState ParticipantsState);
|
||||||
|
|
||||||
public record ThrowUpdateAction(bool LeftSink, bool RightSink);
|
public record ThrowUpdateAction(ThrowPanelState State);
|
||||||
|
|
||||||
public record UpdateStateAfterUndoRedo(ThrowPanelState ThrowPanelState, ParticipantsState ParticipantsState);
|
public record UpdateStateAfterUndoRedo(ThrowPanelState ThrowPanelState, ParticipantsState ParticipantsState);
|
||||||
|
|
||||||
|
|
@ -46,7 +46,8 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
|
|
||||||
public record GameProgress(ThrowPanelState? BeforeThrowState, ParticipantsState? BeforeParticipantsState,
|
public record GameProgress(ThrowPanelState? BeforeThrowState, ParticipantsState? BeforeParticipantsState,
|
||||||
ThrowPanelState AfterThrowState, ParticipantsState AfterParticipantsState,
|
ThrowPanelState AfterThrowState, ParticipantsState AfterParticipantsState,
|
||||||
StartParams StartParams, IGameModel GameModel);
|
StartParams StartParams, IGameModel GameModel,
|
||||||
|
ThrowPanelState? NextThrowState);
|
||||||
|
|
||||||
public record DeleteThrowPanelSessionAction();
|
public record DeleteThrowPanelSessionAction();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,33 +151,32 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
[EffectMethod]
|
[EffectMethod]
|
||||||
public async Task HandleThrowAction(ThrowAction throwAction, IDispatcher dispatcher)
|
public async Task HandleThrowAction(ThrowAction throwAction, IDispatcher dispatcher)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var beforeStates = dataService.GetCurrentData();
|
var beforeStates = dataService.GetCurrentData();
|
||||||
|
|
||||||
// change ThrowStatus and save - here we need to save the old state, before it is changed by ThrowUpdateAction, so that undo/redo works correctly
|
// change ThrowStatus and save - here we need to save the old state, before it is changed by ThrowUpdateAction, so that undo/redo works correctly
|
||||||
dispatcher.Dispatch(new EnsureBeforeThrowStatusAction(throwAction.ParticipantsState, beforeStates.Status.GameModel));
|
dispatcher.Dispatch(new EnsureBeforeThrowStatusAction(throwAction.ParticipantsState, beforeStates.Status.GameModel));
|
||||||
|
|
||||||
// perform throw
|
// perform throw - we will get the new state after resetting all pins for the next throw.
|
||||||
dispatcher.Dispatch(new ThrowUpdateAction(throwAction.LeftSink, throwAction.RightSink));
|
// For the calculation of the game-progress in HandleThrow nextState if normally not useful
|
||||||
|
var nextState = throwPanelState.Value.CalculateNextPanelState();
|
||||||
|
dispatcher.Dispatch(new ThrowUpdateAction(nextState));
|
||||||
|
|
||||||
var afterState = throwPanelState.Value;
|
var generalGameProgress = new GameProgress(
|
||||||
|
|
||||||
var progress = new GameProgress(
|
|
||||||
BeforeThrowState: beforeStates.Status?.ThrowPanelState,
|
BeforeThrowState: beforeStates.Status?.ThrowPanelState,
|
||||||
BeforeParticipantsState: throwAction.ParticipantsState,
|
BeforeParticipantsState: throwAction.ParticipantsState,
|
||||||
AfterThrowState: afterState,
|
AfterThrowState: throwPanelState.Value,
|
||||||
AfterParticipantsState: throwAction.ParticipantsState,
|
AfterParticipantsState: throwAction.ParticipantsState,
|
||||||
StartParams: dataService.StartParams,
|
StartParams: dataService.StartParams,
|
||||||
GameModel: beforeStates.Status.GameModel);
|
GameModel: beforeStates.Status.GameModel,
|
||||||
|
NextThrowState: nextState);
|
||||||
|
|
||||||
dispatcher.Dispatch(progress); // currently unused
|
dispatcher.Dispatch(generalGameProgress); // currently unused
|
||||||
|
|
||||||
var participants = throwAction.ParticipantsState;
|
//var participants = throwAction.ParticipantsState;
|
||||||
|
|
||||||
|
|
||||||
|
var gameSpecificProgress = gameService.HandleThrow(generalGameProgress, dispatcher);
|
||||||
|
|
||||||
var progress2 = gameService.HandleThrow(progress, dispatcher);
|
|
||||||
//foreach (var action in actions)
|
//foreach (var action in actions)
|
||||||
//{
|
//{
|
||||||
// if (action is SelectedNextPlayerIds)
|
// if (action is SelectedNextPlayerIds)
|
||||||
|
|
@ -191,7 +190,8 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
|
|
||||||
|
|
||||||
// save again - save the new state after the throw
|
// save again - save the new state after the throw
|
||||||
dispatcher.Dispatch(new TriggerNewThrowPanelStateChangedAction(true, progress2.AfterParticipantsState, progress2.GameModel)); // this will trigger ThrowPanelStateChangedAction with the new state (not current _throwPanelState.Value)
|
dispatcher.Dispatch(new TriggerNewThrowPanelStateChangedAction(true,
|
||||||
|
gameSpecificProgress.AfterParticipantsState, gameSpecificProgress.GameModel)); // this will trigger ThrowPanelStateChangedAction with the new state (not current _throwPanelState.Value)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
|
{
|
||||||
|
class PinState(PinStatus pinStatus)
|
||||||
|
{
|
||||||
|
public PinStatus PinStatus { get; set; } = pinStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ThrowPanelStateExtensions
|
||||||
|
{
|
||||||
|
public static ThrowPanelState CalculateNextPanelState(this ThrowPanelState state)
|
||||||
|
{
|
||||||
|
var nextCounter = 1;
|
||||||
|
var reset = true;
|
||||||
|
if (state.ThrowCounterPerRound < state.ThrowsPerRound)
|
||||||
|
{
|
||||||
|
nextCounter = state.ThrowCounterPerRound + 1;
|
||||||
|
reset = state.ThrowMode != ThrowMode.Decrease;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _pins = new List<PinState>
|
||||||
|
{
|
||||||
|
new(state.Pin9State), new(state.Pin8State),
|
||||||
|
new(state.Pin7State),
|
||||||
|
new(state.Pin6State),
|
||||||
|
new(state.Pin5State),
|
||||||
|
new(state.Pin4State),
|
||||||
|
new(state.Pin3State),
|
||||||
|
new(state.Pin2State),
|
||||||
|
new( state.Pin1State),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_pins.All(_ => _.PinStatus == PinStatus.Fallen)) // abgeräumt
|
||||||
|
{
|
||||||
|
reset = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reset)
|
||||||
|
{
|
||||||
|
foreach (var pin in _pins)
|
||||||
|
{
|
||||||
|
pin.PinStatus = PinStatus.Standing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (state.ThrowMode == ThrowMode.Decrease)
|
||||||
|
{
|
||||||
|
foreach (var pin in _pins)
|
||||||
|
{
|
||||||
|
var nr = _pins.IndexOf(pin) + 1;
|
||||||
|
if (pin.PinStatus != PinStatus.Disabled && pin.PinStatus == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
pin.PinStatus = PinStatus.Disabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return state with
|
||||||
|
{
|
||||||
|
Pin1State = _pins[8].PinStatus,
|
||||||
|
Pin2State = _pins[7].PinStatus,
|
||||||
|
Pin3State = _pins[6].PinStatus,
|
||||||
|
Pin4State = _pins[5].PinStatus,
|
||||||
|
Pin5State = _pins[4].PinStatus,
|
||||||
|
Pin6State = _pins[3].PinStatus,
|
||||||
|
Pin7State = _pins[2].PinStatus,
|
||||||
|
Pin8State = _pins[1].PinStatus,
|
||||||
|
Pin9State = _pins[0].PinStatus,
|
||||||
|
ThrowCounterPerRound = nextCounter,
|
||||||
|
BellValue = false,
|
||||||
|
ThrowPanelStateStatus = ThrowPanelStateStatus.AfterThrow,
|
||||||
|
ThrowCounter = state.ThrowCounter + 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,8 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
public static class ThrowPanelStateReducer
|
public static class ThrowPanelStateReducer
|
||||||
{
|
{
|
||||||
[ReducerMethod]
|
[ReducerMethod]
|
||||||
public static ThrowPanelState OnReceiveStateFromServer(ThrowPanelState state, ReceiveThrowPanelStateFromServerAction action)
|
public static ThrowPanelState OnReceiveStateFromServer(ThrowPanelState state,
|
||||||
|
ReceiveThrowPanelStateFromServerAction action)
|
||||||
{
|
{
|
||||||
return action.State;
|
return action.State;
|
||||||
}
|
}
|
||||||
|
|
@ -139,13 +140,14 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class PinState(PinStatus pinStatus)
|
//class PinState(PinStatus pinStatus)
|
||||||
{
|
//{
|
||||||
public PinStatus PinStatus { get; set; } = pinStatus;
|
// public PinStatus PinStatus { get; set; } = pinStatus;
|
||||||
}
|
//}
|
||||||
|
|
||||||
[ReducerMethod]
|
[ReducerMethod]
|
||||||
public static ThrowPanelState OnUpdatePinStateByNumber(ThrowPanelState state, UpdatePinStateByNumberAction action)
|
public static ThrowPanelState OnUpdatePinStateByNumber(ThrowPanelState state,
|
||||||
|
UpdatePinStateByNumberAction action)
|
||||||
{
|
{
|
||||||
var chgCnt = 0;
|
var chgCnt = 0;
|
||||||
|
|
||||||
|
|
@ -210,7 +212,8 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
}
|
}
|
||||||
|
|
||||||
[ReducerMethod]
|
[ReducerMethod]
|
||||||
public static ThrowPanelState OnEnsureBeforeThrowStatusAction(ThrowPanelState state, EnsureBeforeThrowStatusAction action)
|
public static ThrowPanelState OnEnsureBeforeThrowStatusAction(ThrowPanelState state,
|
||||||
|
EnsureBeforeThrowStatusAction action)
|
||||||
{
|
{
|
||||||
return state with
|
return state with
|
||||||
{
|
{
|
||||||
|
|
@ -221,71 +224,76 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
||||||
[ReducerMethod]
|
[ReducerMethod]
|
||||||
public static ThrowPanelState OnThrowUpdateAction(ThrowPanelState state, ThrowUpdateAction action)
|
public static ThrowPanelState OnThrowUpdateAction(ThrowPanelState state, ThrowUpdateAction action)
|
||||||
{
|
{
|
||||||
var nextCounter = 1;
|
return action.State;
|
||||||
var reset = true;
|
|
||||||
if (state.ThrowCounterPerRound < state.ThrowsPerRound)
|
|
||||||
{
|
|
||||||
nextCounter = state.ThrowCounterPerRound + 1;
|
|
||||||
reset = state.ThrowMode != ThrowMode.Decrease;
|
|
||||||
}
|
}
|
||||||
|
//[ReducerMethod]
|
||||||
|
//public static ThrowPanelState OnThrowUpdateAction(ThrowPanelState state, ThrowUpdateAction action)
|
||||||
|
//{
|
||||||
|
// var nextCounter = 1;
|
||||||
|
// var reset = true;
|
||||||
|
// if (state.ThrowCounterPerRound < state.ThrowsPerRound)
|
||||||
|
// {
|
||||||
|
// nextCounter = state.ThrowCounterPerRound + 1;
|
||||||
|
// reset = state.ThrowMode != ThrowMode.Decrease;
|
||||||
|
// }
|
||||||
|
|
||||||
var _pins = new List<PinState>
|
// var _pins = new List<PinState>
|
||||||
{
|
// {
|
||||||
new(state.Pin9State), new(state.Pin8State),
|
// new(state.Pin9State), new(state.Pin8State),
|
||||||
new(state.Pin7State),
|
// new(state.Pin7State),
|
||||||
new(state.Pin6State),
|
// new(state.Pin6State),
|
||||||
new(state.Pin5State),
|
// new(state.Pin5State),
|
||||||
new(state.Pin4State),
|
// new(state.Pin4State),
|
||||||
new(state.Pin3State),
|
// new(state.Pin3State),
|
||||||
new(state.Pin2State),
|
// new(state.Pin2State),
|
||||||
new( state.Pin1State),
|
// new( state.Pin1State),
|
||||||
};
|
// };
|
||||||
|
|
||||||
if (_pins.All(_ => _.PinStatus == PinStatus.Fallen)) // abgeräumt
|
// if (_pins.All(_ => _.PinStatus == PinStatus.Fallen)) // abgeräumt
|
||||||
{
|
// {
|
||||||
reset = true;
|
// reset = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (reset)
|
// if (reset)
|
||||||
{
|
// {
|
||||||
foreach (var pin in _pins)
|
// foreach (var pin in _pins)
|
||||||
{
|
// {
|
||||||
pin.PinStatus = PinStatus.Standing;
|
// pin.PinStatus = PinStatus.Standing;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (state.ThrowMode == ThrowMode.Decrease)
|
// if (state.ThrowMode == ThrowMode.Decrease)
|
||||||
{
|
// {
|
||||||
foreach (var pin in _pins)
|
// foreach (var pin in _pins)
|
||||||
{
|
// {
|
||||||
var nr = _pins.IndexOf(pin) + 1;
|
// var nr = _pins.IndexOf(pin) + 1;
|
||||||
if (pin.PinStatus != PinStatus.Disabled && pin.PinStatus == PinStatus.Fallen)
|
// if (pin.PinStatus != PinStatus.Disabled && pin.PinStatus == PinStatus.Fallen)
|
||||||
{
|
// {
|
||||||
pin.PinStatus = PinStatus.Disabled;
|
// pin.PinStatus = PinStatus.Disabled;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
return state with
|
// return state with
|
||||||
{
|
// {
|
||||||
Pin1State = _pins[8].PinStatus,
|
// Pin1State = _pins[8].PinStatus,
|
||||||
Pin2State = _pins[7].PinStatus,
|
// Pin2State = _pins[7].PinStatus,
|
||||||
Pin3State = _pins[6].PinStatus,
|
// Pin3State = _pins[6].PinStatus,
|
||||||
Pin4State = _pins[5].PinStatus,
|
// Pin4State = _pins[5].PinStatus,
|
||||||
Pin5State = _pins[4].PinStatus,
|
// Pin5State = _pins[4].PinStatus,
|
||||||
Pin6State = _pins[3].PinStatus,
|
// Pin6State = _pins[3].PinStatus,
|
||||||
Pin7State = _pins[2].PinStatus,
|
// Pin7State = _pins[2].PinStatus,
|
||||||
Pin8State = _pins[1].PinStatus,
|
// Pin8State = _pins[1].PinStatus,
|
||||||
Pin9State = _pins[0].PinStatus,
|
// Pin9State = _pins[0].PinStatus,
|
||||||
ThrowCounterPerRound = nextCounter,
|
// ThrowCounterPerRound = nextCounter,
|
||||||
BellValue = false,
|
// BellValue = false,
|
||||||
ThrowPanelStateStatus = ThrowPanelStateStatus.AfterThrow,
|
// ThrowPanelStateStatus = ThrowPanelStateStatus.AfterThrow,
|
||||||
ThrowCounter = state.ThrowCounter + 1
|
// ThrowCounter = state.ThrowCounter + 1
|
||||||
};
|
// };
|
||||||
}
|
//}
|
||||||
|
|
||||||
[ReducerMethod]
|
[ReducerMethod]
|
||||||
public static ThrowPanelState OnUpdateStateAfterUndoRedo(ThrowPanelState state, UpdateStateAfterUndoRedo action)
|
public static ThrowPanelState OnUpdateStateAfterUndoRedo(ThrowPanelState state, UpdateStateAfterUndoRedo action)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@ using KoogleApp.Services;
|
||||||
|
|
||||||
namespace KoogleApp.Store.Game.ThrowTimer
|
namespace KoogleApp.Store.Game.ThrowTimer
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// https://learn.microsoft.com/en-us/aspnet/core/blazor/components/synchronization-context?view=aspnetcore-10.0
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger"></param>
|
||||||
|
/// <param name="eventAggregator"></param>
|
||||||
public class TimerEffects(ILogger<TimerEffects> logger, IMyEventAggregator eventAggregator)
|
public class TimerEffects(ILogger<TimerEffects> logger, IMyEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
private CancellationTokenSource? _timerCancellation;
|
private CancellationTokenSource? _timerCancellation;
|
||||||
|
|
|
||||||
|
|
@ -15,203 +15,8 @@
|
||||||
"Pin8State": 0,
|
"Pin8State": 0,
|
||||||
"Pin9State": 0,
|
"Pin9State": 0,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 3,
|
||||||
"ThrowCounterPerRound": 3,
|
|
||||||
"ThrowMode": 0,
|
|
||||||
"ThrowPanelStateStatus": 3,
|
|
||||||
"ThrowCounter": 2,
|
|
||||||
"DayId": 35
|
|
||||||
},
|
|
||||||
"ParticipantsState": {
|
|
||||||
"PlayerIds": [
|
|
||||||
3,
|
|
||||||
5,
|
|
||||||
10,
|
|
||||||
12,
|
|
||||||
9
|
|
||||||
],
|
|
||||||
"Eliminated": []
|
|
||||||
},
|
|
||||||
"GameModel": {
|
|
||||||
"$type": "TrainingState",
|
|
||||||
"Throws": {
|
|
||||||
"5": {
|
|
||||||
"PlayerId": 5,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 1,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"PlayerId": 3,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 1,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"10": {
|
|
||||||
"PlayerId": 10,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 0,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"12": {
|
|
||||||
"PlayerId": 12,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 0,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"9": {
|
|
||||||
"PlayerId": 9,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 0,
|
|
||||||
"BellCount": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Version": 5,
|
|
||||||
"LastModified": "2025-11-25T21:04:40.615022+01:00",
|
|
||||||
"LastModifiedBy": "test1@test.de"
|
|
||||||
},
|
|
||||||
"UndoHistory": [
|
|
||||||
{
|
|
||||||
"Status": {
|
|
||||||
"StartParams": null,
|
|
||||||
"ThrowPanelState": {
|
|
||||||
"IsStated": true,
|
|
||||||
"BellValue": false,
|
|
||||||
"Pin1State": 0,
|
|
||||||
"Pin2State": 0,
|
|
||||||
"Pin3State": 0,
|
|
||||||
"Pin4State": 0,
|
|
||||||
"Pin5State": 0,
|
|
||||||
"Pin6State": 0,
|
|
||||||
"Pin7State": 0,
|
|
||||||
"Pin8State": 0,
|
|
||||||
"Pin9State": 1,
|
|
||||||
"ThrowsPerRound": 3,
|
|
||||||
"ThrowCounterPerRound": 2,
|
"ThrowCounterPerRound": 2,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowPanelStateStatus": 2,
|
|
||||||
"ThrowCounter": 1,
|
|
||||||
"DayId": 35
|
|
||||||
},
|
|
||||||
"ParticipantsState": {
|
|
||||||
"PlayerIds": [
|
|
||||||
3,
|
|
||||||
5,
|
|
||||||
10,
|
|
||||||
12,
|
|
||||||
9
|
|
||||||
],
|
|
||||||
"Eliminated": []
|
|
||||||
},
|
|
||||||
"GameModel": {
|
|
||||||
"$type": "TrainingState",
|
|
||||||
"Throws": {
|
|
||||||
"5": {
|
|
||||||
"PlayerId": 5,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 1,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"PlayerId": 3,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 1,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"10": {
|
|
||||||
"PlayerId": 10,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 0,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"12": {
|
|
||||||
"PlayerId": 12,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 0,
|
|
||||||
"BellCount": 0
|
|
||||||
},
|
|
||||||
"9": {
|
|
||||||
"PlayerId": 9,
|
|
||||||
"TeamNr": 0,
|
|
||||||
"PinCount": 0,
|
|
||||||
"CircleCount": 0,
|
|
||||||
"SinkCount": 0,
|
|
||||||
"StrikeCount": 0,
|
|
||||||
"ClearedCount": 0,
|
|
||||||
"ThrowCount": 0,
|
|
||||||
"BellCount": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Version": 4,
|
|
||||||
"LastModified": "2025-11-25T21:04:40.6119067+01:00",
|
|
||||||
"LastModifiedBy": "test1@test.de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Status": {
|
|
||||||
"StartParams": 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": 2,
|
|
||||||
"ThrowMode": 0,
|
|
||||||
"ThrowPanelStateStatus": 3,
|
"ThrowPanelStateStatus": 3,
|
||||||
"ThrowCounter": 1,
|
"ThrowCounter": 1,
|
||||||
"DayId": 35
|
"DayId": 35
|
||||||
|
|
@ -232,7 +37,7 @@
|
||||||
"5": {
|
"5": {
|
||||||
"PlayerId": 5,
|
"PlayerId": 5,
|
||||||
"TeamNr": 0,
|
"TeamNr": 0,
|
||||||
"PinCount": 0,
|
"PinCount": 9,
|
||||||
"CircleCount": 0,
|
"CircleCount": 0,
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
|
|
@ -248,7 +53,7 @@
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
"ClearedCount": 0,
|
"ClearedCount": 0,
|
||||||
"ThrowCount": 1,
|
"ThrowCount": 0,
|
||||||
"BellCount": 0
|
"BellCount": 0
|
||||||
},
|
},
|
||||||
"10": {
|
"10": {
|
||||||
|
|
@ -288,27 +93,28 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Version": 3,
|
"Version": 3,
|
||||||
"LastModified": "2025-11-25T21:04:29.212834+01:00",
|
"LastModified": "2025-11-26T17:43:59.6602498+01:00",
|
||||||
"LastModifiedBy": "test1@test.de"
|
"LastModifiedBy": "test1@test.de"
|
||||||
},
|
},
|
||||||
|
"UndoHistory": [
|
||||||
{
|
{
|
||||||
"Status": {
|
"Status": {
|
||||||
"StartParams": null,
|
"StartParams": null,
|
||||||
"ThrowPanelState": {
|
"ThrowPanelState": {
|
||||||
"IsStated": true,
|
"IsStated": true,
|
||||||
"BellValue": false,
|
"BellValue": false,
|
||||||
"Pin1State": 0,
|
"Pin1State": 1,
|
||||||
"Pin2State": 0,
|
"Pin2State": 1,
|
||||||
"Pin3State": 0,
|
"Pin3State": 1,
|
||||||
"Pin4State": 0,
|
"Pin4State": 1,
|
||||||
"Pin5State": 0,
|
"Pin5State": 1,
|
||||||
"Pin6State": 0,
|
"Pin6State": 1,
|
||||||
"Pin7State": 0,
|
"Pin7State": 1,
|
||||||
"Pin8State": 0,
|
"Pin8State": 1,
|
||||||
"Pin9State": 1,
|
"Pin9State": 1,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 3,
|
||||||
"ThrowCounterPerRound": 1,
|
"ThrowCounterPerRound": 1,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowPanelStateStatus": 2,
|
"ThrowPanelStateStatus": 2,
|
||||||
"ThrowCounter": 0,
|
"ThrowCounter": 0,
|
||||||
"DayId": 35
|
"DayId": 35
|
||||||
|
|
@ -329,7 +135,7 @@
|
||||||
"5": {
|
"5": {
|
||||||
"PlayerId": 5,
|
"PlayerId": 5,
|
||||||
"TeamNr": 0,
|
"TeamNr": 0,
|
||||||
"PinCount": 0,
|
"PinCount": 9,
|
||||||
"CircleCount": 0,
|
"CircleCount": 0,
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
|
|
@ -345,7 +151,7 @@
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
"ClearedCount": 0,
|
"ClearedCount": 0,
|
||||||
"ThrowCount": 1,
|
"ThrowCount": 0,
|
||||||
"BellCount": 0
|
"BellCount": 0
|
||||||
},
|
},
|
||||||
"10": {
|
"10": {
|
||||||
|
|
@ -385,14 +191,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Version": 2,
|
"Version": 2,
|
||||||
"LastModified": "2025-11-25T21:04:29.205203+01:00",
|
"LastModified": "2025-11-26T17:43:59.6569595+01:00",
|
||||||
"LastModifiedBy": "test1@test.de"
|
"LastModifiedBy": "test1@test.de"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Status": {
|
"Status": {
|
||||||
"StartParams": {
|
"StartParams": {
|
||||||
"DayId": 35,
|
"DayId": 35,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 3,
|
||||||
"Participants": [
|
"Participants": [
|
||||||
5,
|
5,
|
||||||
|
|
@ -401,7 +207,7 @@
|
||||||
12,
|
12,
|
||||||
9
|
9
|
||||||
],
|
],
|
||||||
"ParticipantsMode": 1,
|
"ParticipantsMode": 0,
|
||||||
"KnownGameType": "GameTraining"
|
"KnownGameType": "GameTraining"
|
||||||
},
|
},
|
||||||
"ThrowPanelState": {
|
"ThrowPanelState": {
|
||||||
|
|
@ -418,7 +224,7 @@
|
||||||
"Pin9State": 0,
|
"Pin9State": 0,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 3,
|
||||||
"ThrowCounterPerRound": 1,
|
"ThrowCounterPerRound": 1,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowPanelStateStatus": 1,
|
"ThrowPanelStateStatus": 1,
|
||||||
"ThrowCounter": 0,
|
"ThrowCounter": 0,
|
||||||
"DayId": 35
|
"DayId": 35
|
||||||
|
|
@ -439,7 +245,7 @@
|
||||||
"5": {
|
"5": {
|
||||||
"PlayerId": 5,
|
"PlayerId": 5,
|
||||||
"TeamNr": 0,
|
"TeamNr": 0,
|
||||||
"PinCount": 0,
|
"PinCount": 9,
|
||||||
"CircleCount": 0,
|
"CircleCount": 0,
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
|
|
@ -455,7 +261,7 @@
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
"ClearedCount": 0,
|
"ClearedCount": 0,
|
||||||
"ThrowCount": 1,
|
"ThrowCount": 0,
|
||||||
"BellCount": 0
|
"BellCount": 0
|
||||||
},
|
},
|
||||||
"10": {
|
"10": {
|
||||||
|
|
@ -495,7 +301,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Version": 1,
|
"Version": 1,
|
||||||
"LastModified": "2025-11-25T20:04:22.1609288Z",
|
"LastModified": "2025-11-26T16:43:52.6721758Z",
|
||||||
"LastModifiedBy": "test1@test.de"
|
"LastModifiedBy": "test1@test.de"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue