dev setup model
This commit is contained in:
parent
b3b4d01130
commit
304caa1d9e
|
|
@ -6,7 +6,6 @@
|
||||||
@inject IState<SetupState> SetupState
|
@inject IState<SetupState> SetupState
|
||||||
|
|
||||||
<MudSelect T="ParticipantsMode" Label="Spieler-Modus" HelperText="Wie wird der nächste Spieler bestimmt"
|
<MudSelect T="ParticipantsMode" Label="Spieler-Modus" HelperText="Wie wird der nächste Spieler bestimmt"
|
||||||
|
|
||||||
@bind-Value="Value"
|
@bind-Value="Value"
|
||||||
OpenIcon="@Icons.Material.Filled.Mode" AdornmentColor="Color.Primary">
|
OpenIcon="@Icons.Material.Filled.Mode" AdornmentColor="Color.Primary">
|
||||||
@foreach (var item in _values)
|
@foreach (var item in _values)
|
||||||
|
|
@ -25,25 +24,27 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private ParticipantsMode Value
|
// private ParticipantsMode SelectedValue
|
||||||
|
// {
|
||||||
|
// get => SetupState.Value.ParticipantsMode;
|
||||||
|
// set => OnValueChanged?.Invoke(value);
|
||||||
|
// }
|
||||||
|
|
||||||
|
private ParticipantsMode _value;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public ParticipantsMode Value
|
||||||
{
|
{
|
||||||
get => SetupState.Value.ParticipantsMode;
|
get => _value;
|
||||||
set => OnValueChanged?.Invoke(value);
|
set
|
||||||
|
{
|
||||||
|
if (_value == value) return;
|
||||||
|
_value = value;
|
||||||
|
ValueChanged.InvokeAsync(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
[Parameter]
|
||||||
public Func<SetupState, ParticipantsMode> ValueSelector
|
public EventCallback<ParticipantsMode> ValueChanged { get; set; }
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = null!;
|
|
||||||
|
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
|
||||||
public Action<ParticipantsMode> OnValueChanged
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = null!;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,34 @@
|
||||||
@using KoogleApp.Store.Game.ThrowPanel
|
<MudNumericField @bind-Value="Value" Label="Würfe" HelperText="Anzahl Würfe pro Runde"
|
||||||
|
|
||||||
@typeparam TState
|
|
||||||
@inject IState<TState> State
|
|
||||||
|
|
||||||
<MudNumericField @bind-Value="Count" Label="Würfe" HelperText="Anzahl Würfe pro Runde"
|
|
||||||
Max="99"
|
Max="99"
|
||||||
Min="1"
|
Min="1"
|
||||||
Variant="Variant.Outlined" />
|
Variant="Variant.Outlined" />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private int _count;
|
|
||||||
private int Count
|
|
||||||
{
|
|
||||||
get => _count;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_count == value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_count = value;
|
|
||||||
OnValueChanged?.Invoke(_count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
|
||||||
public Func<TState, int> ValueSelector
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = null!;
|
|
||||||
|
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
|
||||||
public Action<int> OnValueChanged
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = null!;
|
|
||||||
|
|
||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
_count = ValueSelector.Invoke(State.Value);
|
_value = 3;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int _value;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int Value
|
||||||
|
{
|
||||||
|
get => _value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_value == value) return;
|
||||||
|
_value = value;
|
||||||
|
ValueChanged.InvokeAsync(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<int> ValueChanged { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
@using KoogleApp.Store.Game.ThrowPanel
|
@using KoogleApp.Store.Game.ThrowPanel
|
||||||
|
|
||||||
@typeparam TState
|
@* @typeparam TState
|
||||||
@inject IState<TState> State
|
@inject IState<TState> State
|
||||||
|
*@
|
||||||
|
|
||||||
<MudSelect T="ThrowModeClass" Label="Wurf-Modus" HelperText="Wähle zwischen Abräumen und in die Vollen"
|
<MudSelect T="ThrowModeClass" Label="Wurf-Modus" HelperText="Wähle zwischen Abräumen und in die Vollen"
|
||||||
|
|
||||||
|
|
@ -28,18 +28,21 @@
|
||||||
}
|
}
|
||||||
_throwModeClass = value;
|
_throwModeClass = value;
|
||||||
OnValueChanged?.Invoke(value.ThrowMode);
|
OnValueChanged?.Invoke(value.ThrowMode);
|
||||||
|
Value = value.ThrowMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
|
||||||
public Func<TState, ThrowMode> ValueSelector
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = null!;
|
|
||||||
|
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
// [Parameter, EditorRequired]
|
||||||
|
// public Func<TState, ThrowMode> ValueSelector
|
||||||
|
// {
|
||||||
|
// get;
|
||||||
|
// set;
|
||||||
|
// } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
public Action<ThrowMode> OnValueChanged
|
public Action<ThrowMode> OnValueChanged
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
@ -56,8 +59,25 @@
|
||||||
_items.Add(new ThrowModeClass(ThrowMode.Reposition, "in die Vollen"));
|
_items.Add(new ThrowModeClass(ThrowMode.Reposition, "in die Vollen"));
|
||||||
_items.Add(new ThrowModeClass(ThrowMode.Decrease, "Abräumen"));
|
_items.Add(new ThrowModeClass(ThrowMode.Decrease, "Abräumen"));
|
||||||
|
|
||||||
_throwModeClass = _items.FirstOrDefault(_ => _.ThrowMode == ValueSelector.Invoke(State.Value));
|
_throwModeClass = _items.First();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ThrowMode _value;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public ThrowMode Value
|
||||||
|
{
|
||||||
|
get => _value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_value == value) return;
|
||||||
|
_value = value;
|
||||||
|
ValueChanged.InvokeAsync(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<ThrowMode> ValueChanged { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,9 @@
|
||||||
<PlayerSelect @bind-SelectedValues="Players"/>
|
<PlayerSelect @bind-SelectedValues="Players"/>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
<DynamicComponent Type="_selectedSetupComponentType"/>
|
<DynamicComponent
|
||||||
|
Type="_selectedSetupComponentType"
|
||||||
|
@ref="dynamicComponentRef" />
|
||||||
}
|
}
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
|
|
||||||
|
|
@ -56,6 +58,8 @@
|
||||||
</MudDialog>
|
</MudDialog>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private DynamicComponent? dynamicComponentRef;
|
||||||
|
|
||||||
Converter<IKnownGame> converter = new Converter<IKnownGame>
|
Converter<IKnownGame> converter = new Converter<IKnownGame>
|
||||||
{
|
{
|
||||||
SetFunc = value => value?.Name,
|
SetFunc = value => value?.Name,
|
||||||
|
|
@ -101,13 +105,12 @@
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
var setupModel = Activator.CreateInstance(_selectedGameType.SetupModelType) as IGameSetupModel;
|
var setupModel = (dynamicComponentRef.Instance as ISetupControl).GameSetupModel;
|
||||||
setupModel.ParticipantsMode = SetupState.Value.ParticipantsMode;
|
setupModel.ParticipantsMode = SetupState.Value.ParticipantsMode;
|
||||||
setupModel.ThrowMode = SetupState.Value.ThrowMode;
|
|
||||||
setupModel.ThrowsPerRound = SetupState.Value.ThrowsPerRound;
|
|
||||||
setupModel.Participants = PlayerIds;
|
|
||||||
setupModel.DayId = DayState.Value.Id;
|
setupModel.DayId = DayState.Value.Id;
|
||||||
setupModel.KnownGameType = SetupState.Value.Game.GetType().Name;
|
setupModel.KnownGameType = SetupState.Value.Game.GetType().Name;
|
||||||
|
setupModel.Participants = PlayerIds;
|
||||||
|
|
||||||
|
|
||||||
// MudDialog.Close(DialogResult.Ok(new StartParams(
|
// MudDialog.Close(DialogResult.Ok(new StartParams(
|
||||||
// DayState.Value.Id,
|
// DayState.Value.Id,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
using KoogleApp.Store.Game.ThrowPanel;
|
||||||
|
|
||||||
|
namespace KoogleApp.Games
|
||||||
|
{
|
||||||
|
public interface ISetupControl
|
||||||
|
{
|
||||||
|
IGameSetupModel GameSetupModel { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,22 @@
|
||||||
<h3>Setup</h3>
|
@using Fluxor
|
||||||
|
@using KoogleApp.Store.Game.Setup
|
||||||
|
@using KoogleApp.Components.Controls
|
||||||
|
@using KoogleApp.Store.Game.ThrowPanel
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
@implements ISetupControl
|
||||||
|
|
||||||
|
<h3>Setup</h3>
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
public IGameSetupModel GameSetupModel =>
|
||||||
|
new ShitSetupState()
|
||||||
|
{
|
||||||
|
ThrowMode = ThrowMode.Reposition,
|
||||||
|
ThrowsPerRound = int.MaxValue,
|
||||||
|
ParticipantsMode = ParticipantsMode.GameLogic,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,33 @@
|
||||||
@using KoogleApp.Store.Game.ThrowPanel
|
@using KoogleApp.Store.Game.ThrowPanel
|
||||||
@using MudBlazor
|
@using MudBlazor
|
||||||
|
|
||||||
@inject IDispatcher Dispatcher
|
@* @inject IDispatcher Dispatcher *@
|
||||||
|
|
||||||
|
@implements ISetupControl
|
||||||
|
|
||||||
<MudItem>
|
<MudItem>
|
||||||
<ThrowModeSelect TState="SetupState"
|
<ThrowModeSelect @bind-Value="ThrowMode"/>
|
||||||
ValueSelector="@(state => state.ThrowMode)"
|
|
||||||
OnValueChanged="@(value => Dispatcher.Dispatch(new SetThrowModeAction(value)))" />
|
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem>
|
<MudItem>
|
||||||
<ThrowCountSelect TState="SetupState"
|
<ThrowCountSelect @bind-Value="ThrowsPerRound"/>
|
||||||
ValueSelector="@(state => state.ThrowsPerRound)"
|
|
||||||
OnValueChanged="@(value => Dispatcher.Dispatch(new SetThrowsPerRoundAction(value)))"/>
|
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem>
|
<MudItem>
|
||||||
<ParticipantsModeSelect
|
<ParticipantsModeSelect @bind-Value="ParticipantsMode" />
|
||||||
ValueSelector="@(state => state.ParticipantsMode)"
|
|
||||||
OnValueChanged="@(value => Dispatcher.Dispatch(new SetParticipantsModeAction(value)))" />
|
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
ThrowMode ThrowMode = ThrowMode.Reposition;
|
||||||
|
|
||||||
|
int ThrowsPerRound = 3;
|
||||||
|
|
||||||
|
ParticipantsMode ParticipantsMode = ParticipantsMode.GameLogic;
|
||||||
|
|
||||||
|
public IGameSetupModel GameSetupModel =>
|
||||||
|
new TrainingSetupState()
|
||||||
|
{
|
||||||
|
ThrowMode = ThrowMode,
|
||||||
|
ParticipantsMode = ParticipantsMode,
|
||||||
|
ThrowsPerRound = ThrowsPerRound
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,25 @@
|
||||||
"Pin1State": 0,
|
"Pin1State": 0,
|
||||||
"Pin2State": 0,
|
"Pin2State": 0,
|
||||||
"Pin3State": 0,
|
"Pin3State": 0,
|
||||||
"Pin4State": 0,
|
"Pin4State": 2,
|
||||||
"Pin5State": 0,
|
"Pin5State": 0,
|
||||||
"Pin6State": 0,
|
"Pin6State": 0,
|
||||||
"Pin7State": 0,
|
"Pin7State": 0,
|
||||||
"Pin8State": 0,
|
"Pin8State": 0,
|
||||||
"Pin9State": 0,
|
"Pin9State": 0,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 4,
|
||||||
"ThrowCounterPerRound": 2,
|
"ThrowCounterPerRound": 2,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowPanelStateStatus": 3,
|
"ThrowPanelStateStatus": 3,
|
||||||
"ThrowCounter": 1,
|
"ThrowCounter": 1,
|
||||||
"DayId": 35
|
"DayId": 35
|
||||||
},
|
},
|
||||||
"ParticipantsState": {
|
"ParticipantsState": {
|
||||||
"PlayerIds": [
|
"PlayerIds": [
|
||||||
12,
|
|
||||||
5,
|
5,
|
||||||
3,
|
3,
|
||||||
10,
|
10,
|
||||||
|
12,
|
||||||
9
|
9
|
||||||
],
|
],
|
||||||
"Eliminated": []
|
"Eliminated": []
|
||||||
|
|
@ -37,12 +37,12 @@
|
||||||
"5": {
|
"5": {
|
||||||
"PlayerId": 5,
|
"PlayerId": 5,
|
||||||
"TeamNr": 0,
|
"TeamNr": 0,
|
||||||
"PinCount": 0,
|
"PinCount": 1,
|
||||||
"CircleCount": 0,
|
"CircleCount": 0,
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
"ClearedCount": 0,
|
"ClearedCount": 0,
|
||||||
"ThrowCount": 0,
|
"ThrowCount": 1,
|
||||||
"BellCount": 0
|
"BellCount": 0
|
||||||
},
|
},
|
||||||
"3": {
|
"3": {
|
||||||
|
|
@ -70,12 +70,12 @@
|
||||||
"12": {
|
"12": {
|
||||||
"PlayerId": 12,
|
"PlayerId": 12,
|
||||||
"TeamNr": 0,
|
"TeamNr": 0,
|
||||||
"PinCount": 1,
|
"PinCount": 0,
|
||||||
"CircleCount": 0,
|
"CircleCount": 0,
|
||||||
"SinkCount": 0,
|
"SinkCount": 0,
|
||||||
"StrikeCount": 0,
|
"StrikeCount": 0,
|
||||||
"ClearedCount": 0,
|
"ClearedCount": 0,
|
||||||
"ThrowCount": 1,
|
"ThrowCount": 0,
|
||||||
"BellCount": 0
|
"BellCount": 0
|
||||||
},
|
},
|
||||||
"9": {
|
"9": {
|
||||||
|
|
@ -93,7 +93,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Version": 3,
|
"Version": 3,
|
||||||
"LastModified": "2025-11-27T18:02:52.0439516+01:00",
|
"LastModified": "2025-11-27T21:06:17.9099848+01:00",
|
||||||
"LastModifiedBy": "test1@test.de"
|
"LastModifiedBy": "test1@test.de"
|
||||||
},
|
},
|
||||||
"UndoHistory": [
|
"UndoHistory": [
|
||||||
|
|
@ -106,25 +106,25 @@
|
||||||
"Pin1State": 0,
|
"Pin1State": 0,
|
||||||
"Pin2State": 0,
|
"Pin2State": 0,
|
||||||
"Pin3State": 0,
|
"Pin3State": 0,
|
||||||
"Pin4State": 0,
|
"Pin4State": 1,
|
||||||
"Pin5State": 0,
|
"Pin5State": 0,
|
||||||
"Pin6State": 0,
|
"Pin6State": 0,
|
||||||
"Pin7State": 0,
|
"Pin7State": 0,
|
||||||
"Pin8State": 0,
|
"Pin8State": 0,
|
||||||
"Pin9State": 1,
|
"Pin9State": 0,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 4,
|
||||||
"ThrowCounterPerRound": 1,
|
"ThrowCounterPerRound": 1,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowPanelStateStatus": 2,
|
"ThrowPanelStateStatus": 2,
|
||||||
"ThrowCounter": 0,
|
"ThrowCounter": 0,
|
||||||
"DayId": 35
|
"DayId": 35
|
||||||
},
|
},
|
||||||
"ParticipantsState": {
|
"ParticipantsState": {
|
||||||
"PlayerIds": [
|
"PlayerIds": [
|
||||||
12,
|
|
||||||
5,
|
5,
|
||||||
3,
|
3,
|
||||||
10,
|
10,
|
||||||
|
12,
|
||||||
9
|
9
|
||||||
],
|
],
|
||||||
"Eliminated": []
|
"Eliminated": []
|
||||||
|
|
@ -191,7 +191,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Version": 2,
|
"Version": 2,
|
||||||
"LastModified": "2025-11-27T18:02:52.0372178+01:00",
|
"LastModified": "2025-11-27T21:06:17.8971982+01:00",
|
||||||
"LastModifiedBy": "test1@test.de"
|
"LastModifiedBy": "test1@test.de"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -199,8 +199,8 @@
|
||||||
"SetupModel": {
|
"SetupModel": {
|
||||||
"$type": "TrainingSetupState",
|
"$type": "TrainingSetupState",
|
||||||
"DayId": 35,
|
"DayId": 35,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 4,
|
||||||
"Participants": [
|
"Participants": [
|
||||||
5,
|
5,
|
||||||
3,
|
3,
|
||||||
|
|
@ -223,9 +223,9 @@
|
||||||
"Pin7State": 0,
|
"Pin7State": 0,
|
||||||
"Pin8State": 0,
|
"Pin8State": 0,
|
||||||
"Pin9State": 0,
|
"Pin9State": 0,
|
||||||
"ThrowsPerRound": 3,
|
"ThrowsPerRound": 4,
|
||||||
"ThrowCounterPerRound": 1,
|
"ThrowCounterPerRound": 1,
|
||||||
"ThrowMode": 0,
|
"ThrowMode": 1,
|
||||||
"ThrowPanelStateStatus": 1,
|
"ThrowPanelStateStatus": 1,
|
||||||
"ThrowCounter": 0,
|
"ThrowCounter": 0,
|
||||||
"DayId": 35
|
"DayId": 35
|
||||||
|
|
@ -302,7 +302,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Version": 1,
|
"Version": 1,
|
||||||
"LastModified": "2025-11-27T17:02:45.406402Z",
|
"LastModified": "2025-11-27T20:06:09.3170916Z",
|
||||||
"LastModifiedBy": "test1@test.de"
|
"LastModifiedBy": "test1@test.de"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue