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