fix select participantsMode
This commit is contained in:
parent
3e42cc1bb9
commit
edb9a2eee8
|
|
@ -3,6 +3,7 @@
|
|||
@using KoogleApp.Services
|
||||
@using KoogleApp.Store.Game
|
||||
@using KoogleApp.Store.Game.Participants
|
||||
@using KoogleApp.Store.Game.Setup
|
||||
@using KoogleApp.Store.Game.ThrowPanel
|
||||
|
||||
@inherits FluxorComponent
|
||||
|
|
@ -10,6 +11,7 @@
|
|||
@inject IState<ThrowPanelState> ThrowPanelState
|
||||
@inject IDispatcher Dispatcher
|
||||
@inject IState<ParticipantsState> ParticipantsState
|
||||
@inject IState<SetupState> SetupState
|
||||
|
||||
@if (ThrowPanelState.Value.IsStated)
|
||||
{
|
||||
|
|
@ -128,10 +130,9 @@
|
|||
<MudPaper Class="pa-4 d-flex align-center justify-center mud-width-full" Style="height: 76px;">
|
||||
@if (ParticipantsState.Value != null)
|
||||
{
|
||||
<ChangePlayerSelect/>
|
||||
@if (CanSelectPlayer)
|
||||
@if (SetupState.Value.ParticipantsMode == ParticipantsMode.FreeToChoose)
|
||||
{
|
||||
|
||||
<ChangePlayerSelect />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
@using KoogleApp.Store.Game.Setup
|
||||
@using KoogleApp.Store.Game.ThrowPanel
|
||||
|
||||
@inject IDispatcher Dispatcher
|
||||
@inherits FluxorComponent
|
||||
|
||||
@inject IState<SetupState> SetupState
|
||||
|
||||
<MudSelect T="ParticipantsMode" Label="Spieler-Modus" HelperText="Wie wird der nächste Spieler bestimmt"
|
||||
|
||||
@bind-Value="Value"
|
||||
OpenIcon="@Icons.Material.Filled.Mode" AdornmentColor="Color.Primary">
|
||||
@foreach (var item in _values)
|
||||
{
|
||||
<MudSelectItem T="ParticipantsMode" Value="item.Key">@item.Value</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
<EnumSelect Label="Spieler-Modus"
|
||||
TEnum="@ParticipantsMode" TState="SetupState" HelperText="Wie wird der nächste Spieler bestimmt"
|
||||
ValueSelector="@(state => state.ParticipantsMode)"
|
||||
OnValueChanged="@(value => Dispatcher.Dispatch(new SetParticipantsModeAction(value)))"
|
||||
EnumValues="_values" />
|
||||
|
||||
@code {
|
||||
Dictionary<ParticipantsMode, string> _values = new()
|
||||
|
|
@ -18,4 +25,25 @@
|
|||
};
|
||||
|
||||
|
||||
private ParticipantsMode Value
|
||||
{
|
||||
get => SetupState.Value.ParticipantsMode;
|
||||
set => OnValueChanged?.Invoke(value);
|
||||
}
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Func<SetupState, ParticipantsMode> ValueSelector
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = null!;
|
||||
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<ParticipantsMode> OnValueChanged
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = null!;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
@using KoogleApp.Store.Player
|
||||
@using Dispatcher = Fluxor.Dispatcher
|
||||
|
||||
@inherits FluxorComponent
|
||||
|
||||
@inject GameTypeService GameTypeService
|
||||
@inject IState<SetupState> SetupState
|
||||
@inject IState<PlayersState> PlayersState
|
||||
|
|
@ -21,13 +23,15 @@
|
|||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@SetupState.Value.ParticipantsMode
|
||||
|
||||
<MudSelect T="IKnownGame" Label="Spiel" @bind-Value="_selectedGameType" HelperText="Wähle ein Spiel aus"
|
||||
OpenIcon="@Icons.Material.Filled.Mode" AdornmentColor="Color.Primary">
|
||||
@foreach (var item in _gameTypes)
|
||||
{
|
||||
<MudSelectItem T="IKnownGame" Value="@(item)">@item.Name</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudSelect>
|
||||
|
||||
<MudGrid>
|
||||
@if (_selectedSetupComponentType is not null)
|
||||
|
|
@ -37,13 +41,13 @@
|
|||
</MudItem>
|
||||
|
||||
<MudItem xs="12">
|
||||
<PlayerSelect @bind-SelectedValues="Players" />
|
||||
<PlayerSelect @bind-SelectedValues="Players"/>
|
||||
</MudItem>
|
||||
|
||||
<DynamicComponent Type="_selectedSetupComponentType"/>
|
||||
}
|
||||
</MudGrid>
|
||||
|
||||
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Abbrechen</MudButton>
|
||||
|
|
@ -87,6 +91,11 @@
|
|||
|
||||
private void Start()
|
||||
{
|
||||
MudDialog.Close(DialogResult.Ok(new StartParams(DayState.Value.Id, SetupState.Value.ThrowMode, SetupState.Value.ThrowsPerRound, PlayerIds, SetupState.Value.ParticipantsMode)));
|
||||
MudDialog.Close(DialogResult.Ok(new StartParams(
|
||||
DayState.Value.Id,
|
||||
SetupState.Value.ThrowMode,
|
||||
SetupState.Value.ThrowsPerRound,
|
||||
PlayerIds,
|
||||
SetupState.Value.ParticipantsMode)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
@using KoogleApp.Store.DayFeature
|
||||
@using KoogleApp.Store.Game
|
||||
@using KoogleApp.Store.Game.Participants
|
||||
@using KoogleApp.Store.Game.Setup
|
||||
@using KoogleApp.Store.Game.ThrowPanel
|
||||
@using KoogleApp.Store.Game.ThrowTimer
|
||||
@using KoogleApp.Store.Game.UndoRedo
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
@inject IState<ThrowPanelState> ThrowPanelState
|
||||
@inject IState<DayState> DayState
|
||||
@inject IState<ParticipantsState> ParticipantsState
|
||||
@inject IState<SetupState> SetupState
|
||||
|
||||
@inject IDispatcher Dispatcher
|
||||
@inject IDialogService DialogService
|
||||
|
|
@ -42,8 +44,8 @@
|
|||
case GameView.Throw:
|
||||
<PanelToolbar>
|
||||
|
||||
@GetParticipantsState()
|
||||
|
||||
@* @GetParticipantsState() *@
|
||||
@GetSetupState();
|
||||
|
||||
@if (DayState.Value.Status != DayStatus.Started)
|
||||
{
|
||||
|
|
@ -265,4 +267,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
private string GetSetupState()
|
||||
{
|
||||
return JsonSerializer.Serialize(SetupState.Value,new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
@using MudBlazor
|
||||
|
||||
@inject IDispatcher Dispatcher
|
||||
@inject IState<SetupState> SetupState
|
||||
|
||||
|
||||
<MudItem>
|
||||
<ThrowModeSelect TState="SetupState"
|
||||
|
|
@ -19,7 +17,9 @@
|
|||
OnValueChanged="@(value => Dispatcher.Dispatch(new SetThrowsPerRoundAction(value)))"/>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<ParticipantsModeSelect/>
|
||||
<ParticipantsModeSelect
|
||||
ValueSelector="@(state => state.ParticipantsMode)"
|
||||
OnValueChanged="@(value => Dispatcher.Dispatch(new SetParticipantsModeAction(value)))" />
|
||||
</MudItem>
|
||||
@code {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
namespace KoogleApp.Model
|
||||
{
|
||||
public record StartParams(int DayId, ThrowMode ThrowMode, int ThrowsPerRound, int[] Participants, ParticipantsMode ParticipantsMode)
|
||||
public record StartParams(int DayId, ThrowMode ThrowMode, int ThrowsPerRound, int[] Participants,
|
||||
ParticipantsMode ParticipantsMode)
|
||||
|
||||
{
|
||||
public StartParams() : this(DayId: 0, ThrowMode: ThrowMode.Reposition, ThrowsPerRound: 3, [], ParticipantsMode: Store.Game.ThrowPanel.ParticipantsMode.FreeToChoose)
|
||||
public StartParams() : this(DayId: 0, ThrowMode: ThrowMode.Reposition,
|
||||
ThrowsPerRound: 3, [],
|
||||
ParticipantsMode: ParticipantsMode.FreeToChoose)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using KoogleApp.Store.Player;
|
|||
|
||||
namespace KoogleApp.Store.Game.Participants
|
||||
{
|
||||
public record ParticipantsStateChangedAction(ParticipantsState? ParticipantsState);
|
||||
public record SaveAndBroadcastParticipantsStateAction(ParticipantsState? ParticipantsState);
|
||||
|
||||
public record LoadParticipantsStatesFromSessionAction();
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ namespace KoogleApp.Store.Game.Participants
|
|||
|
||||
public record BroadcastParticipantsStateAction(ParticipantsState ParticipantsState);
|
||||
|
||||
public record ParticipantsStateLoadedAction(ParticipantsState ParticipantsState);
|
||||
public record ParticipantsStateChangedAction(ParticipantsState ParticipantsState);
|
||||
|
||||
public record SetParticipatingPlayersAction(int[] PlayerIds);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace KoogleApp.Store.Game.Participants
|
|||
private readonly IGameStatusDataService _dataService = dataService;
|
||||
|
||||
[EffectMethod]
|
||||
public async Task HandelParticipantsStateChangedAction(ParticipantsStateChangedAction action, IDispatcher dispatcher)
|
||||
public async Task HandelParticipantsStateChangedAction(SaveAndBroadcastParticipantsStateAction action, IDispatcher dispatcher)
|
||||
{
|
||||
dispatcher.Dispatch(new SaveParticipantsStateAction(action.ParticipantsState));
|
||||
|
||||
|
|
@ -36,8 +36,8 @@ namespace KoogleApp.Store.Game.Participants
|
|||
PlayerIds = lst.ToArray()
|
||||
};
|
||||
|
||||
dispatcher.Dispatch(new SaveAndBroadcastParticipantsStateAction(newState));
|
||||
dispatcher.Dispatch(new ParticipantsStateChangedAction(newState));
|
||||
dispatcher.Dispatch(new ParticipantsStateLoadedAction(newState));
|
||||
}
|
||||
|
||||
[EffectMethod]
|
||||
|
|
@ -95,7 +95,7 @@ namespace KoogleApp.Store.Game.Participants
|
|||
|
||||
if (state != null)
|
||||
{
|
||||
dispatcher.Dispatch(new ParticipantsStateLoadedAction(state));
|
||||
dispatcher.Dispatch(new ParticipantsStateChangedAction(state));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace KoogleApp.Store.Game.Participants
|
|||
}
|
||||
|
||||
[ReducerMethod]
|
||||
public static ParticipantsState OnParticipantsState(ParticipantsState state, ParticipantsStateLoadedAction action)
|
||||
public static ParticipantsState OnParticipantsState(ParticipantsState state, ParticipantsStateChangedAction action)
|
||||
{
|
||||
return action.ParticipantsState;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,6 @@ namespace KoogleApp.Store.Game.Setup
|
|||
public record LoadSetupStatesFromSessionAction();
|
||||
|
||||
public record SetupStateLoadedAction(SetupState SetupState);
|
||||
|
||||
public record ResetSetupStateAction();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ namespace KoogleApp.Store.Game.Setup
|
|||
[FeatureState]
|
||||
public record SetupState(ThrowMode ThrowMode, int ThrowsPerRound, int[] Players, ParticipantsMode ParticipantsMode)
|
||||
{
|
||||
public SetupState() : this(ThrowMode: ThrowMode.Reposition, ThrowsPerRound:3, Players:[], ParticipantsMode: ParticipantsMode.FreeToChoose)
|
||||
public SetupState() : this(ThrowMode: ThrowMode.Reposition, ThrowsPerRound:3, Players:[],
|
||||
ParticipantsMode: ParticipantsMode.FreeToChoose)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
private readonly ILogger<ThrowPanelEffects> _logger;
|
||||
private readonly HubConnectionService _sharedHubService;
|
||||
private readonly IState<ThrowPanelState> _throwPanelState;
|
||||
private readonly IState<SetupState> _setupState;
|
||||
private readonly SessionStorage _sessionStorage;
|
||||
private readonly string _dataFilePath = "ThrowPanelState.json";
|
||||
private readonly AuthenticationStateProvider _authenticationStateProvider;
|
||||
|
|
@ -32,6 +33,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
ILogger<ThrowPanelEffects> logger,
|
||||
HubConnectionService sharedHubService,
|
||||
IState<ThrowPanelState> throwPanelState,
|
||||
IState<SetupState> setupState,
|
||||
AuthenticationStateProvider authenticationStateProvider,
|
||||
IGameStatusDataService dataService,
|
||||
SessionStorage sessionStorage)
|
||||
|
|
@ -65,7 +67,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
setupState = new SetupState(startStopAction.StartParams.ThrowMode,
|
||||
startStopAction.StartParams.ThrowsPerRound, startStopAction.StartParams.Participants,
|
||||
ParticipantsMode: startStopAction.StartParams.ParticipantsMode);
|
||||
|
||||
|
||||
var username = await GetUsername();
|
||||
_dataService.Initialize(new GameStatus()
|
||||
{
|
||||
|
|
@ -82,13 +84,14 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
ThrowPanelState = _throwPanelState.Value with { ThrowPanelStateStatus = ThrowPanelStateStatus.GameEnd },
|
||||
}, username);
|
||||
dispatcher.Dispatch(new UpdateUndoRedoStateAction());
|
||||
|
||||
participantsState = new ParticipantsState();
|
||||
}
|
||||
|
||||
// reset settings and all relevant states for the next game
|
||||
dispatcher.Dispatch(new ThrowPanelStateChangedAction(_throwPanelState.Value, true, ParticipantsState: participantsState));
|
||||
if (participantsState != null)
|
||||
{
|
||||
dispatcher.Dispatch(new ParticipantsStateChangedAction(participantsState));
|
||||
}
|
||||
dispatcher.Dispatch(new ParticipantsStateChangedAction(participantsState));
|
||||
dispatcher.Dispatch(new ResetSetupStateAction()); // TODO: not reduced
|
||||
}
|
||||
|
||||
[EffectMethod]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
}
|
||||
},
|
||||
"Version": 2,
|
||||
"LastModified": "2025-11-21T17:52:34.7010655+01:00",
|
||||
"LastModified": "2025-11-21T19:30:06.7529818+01:00",
|
||||
"LastModifiedBy": "test1@test.de"
|
||||
},
|
||||
"UndoHistory": [
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
12,
|
||||
9
|
||||
],
|
||||
"ParticipantsMode": 1
|
||||
"ParticipantsMode": 0
|
||||
},
|
||||
"ThrowPanelState": {
|
||||
"IsStated": true,
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
}
|
||||
},
|
||||
"Version": 1,
|
||||
"LastModified": "2025-11-21T17:52:34.6986698+01:00",
|
||||
"LastModified": "2025-11-21T19:30:06.7492871+01:00",
|
||||
"LastModifiedBy": "test1@test.de"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"PlayerIds": [
|
||||
12,
|
||||
5,
|
||||
3,
|
||||
10,
|
||||
9
|
||||
],
|
||||
"Eliminated": []
|
||||
}
|
||||
Loading…
Reference in New Issue