diff --git a/KoogleApp/Components/Controls/ParticipantsModeSelect.razor b/KoogleApp/Components/Controls/ParticipantsModeSelect.razor index 69cb3db..f79976e 100644 --- a/KoogleApp/Components/Controls/ParticipantsModeSelect.razor +++ b/KoogleApp/Components/Controls/ParticipantsModeSelect.razor @@ -6,7 +6,6 @@ @inject IState SetupState @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 ValueSelector - { - get; - set; - } = null!; - - - [Parameter, EditorRequired] - public Action OnValueChanged - { - get; - set; - } = null!; + [Parameter] + public EventCallback ValueChanged { get; set; } } diff --git a/KoogleApp/Components/Controls/ThrowCountSelect.razor b/KoogleApp/Components/Controls/ThrowCountSelect.razor index e55b33a..6dfb583 100644 --- a/KoogleApp/Components/Controls/ThrowCountSelect.razor +++ b/KoogleApp/Components/Controls/ThrowCountSelect.razor @@ -1,51 +1,34 @@ -@using KoogleApp.Store.Game.ThrowPanel - -@typeparam TState -@inject IState State - - @code { - private int _count; - private int Count - { - get => _count; - set - { - if (_count == value) - { - return; - } - _count = value; - OnValueChanged?.Invoke(_count); - } - } - [Parameter, EditorRequired] - public Func ValueSelector - { - get; - set; - } = null!; - - - [Parameter, EditorRequired] - public Action 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 ValueChanged { get; set; } } diff --git a/KoogleApp/Components/Controls/ThrowModeSelect.razor b/KoogleApp/Components/Controls/ThrowModeSelect.razor index 63168e2..646d882 100644 --- a/KoogleApp/Components/Controls/ThrowModeSelect.razor +++ b/KoogleApp/Components/Controls/ThrowModeSelect.razor @@ -1,8 +1,8 @@ @using KoogleApp.Store.Game.ThrowPanel -@typeparam TState +@* @typeparam TState @inject IState State - + *@ ValueSelector - { - get; - set; - } = null!; + + + // [Parameter, EditorRequired] + // public Func ValueSelector + // { + // get; + // set; + // } = null!; - [Parameter, EditorRequired] + [Parameter] public Action 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 ValueChanged { get; set; } } diff --git a/KoogleApp/Components/Dialogs/StartGameDialog.razor b/KoogleApp/Components/Dialogs/StartGameDialog.razor index 9ba70eb..ee27018 100644 --- a/KoogleApp/Components/Dialogs/StartGameDialog.razor +++ b/KoogleApp/Components/Dialogs/StartGameDialog.razor @@ -44,7 +44,9 @@ - + } @@ -56,6 +58,8 @@ @code { + private DynamicComponent? dynamicComponentRef; + Converter converter = new Converter { 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, diff --git a/KoogleApp/Games/IKnownGame.cs b/KoogleApp/Games/IKnownGame.cs index 8c12106..9baa84f 100644 --- a/KoogleApp/Games/IKnownGame.cs +++ b/KoogleApp/Games/IKnownGame.cs @@ -10,6 +10,6 @@ public Type BoardComponentType { get; } - public Type SetupModelType { get; } + public Type SetupModelType { get; } } } diff --git a/KoogleApp/Games/ISetupControl.cs b/KoogleApp/Games/ISetupControl.cs new file mode 100644 index 0000000..963861a --- /dev/null +++ b/KoogleApp/Games/ISetupControl.cs @@ -0,0 +1,9 @@ +using KoogleApp.Store.Game.ThrowPanel; + +namespace KoogleApp.Games +{ + public interface ISetupControl + { + IGameSetupModel GameSetupModel { get; } + } +} diff --git a/KoogleApp/Games/Shit/Setup.razor b/KoogleApp/Games/Shit/Setup.razor index 8cb86cd..f7d89c5 100644 --- a/KoogleApp/Games/Shit/Setup.razor +++ b/KoogleApp/Games/Shit/Setup.razor @@ -1,5 +1,22 @@ -

Setup

+@using Fluxor +@using KoogleApp.Store.Game.Setup +@using KoogleApp.Components.Controls +@using KoogleApp.Store.Game.ThrowPanel +@using MudBlazor + +@implements ISetupControl + +

Setup

+ @code { + public IGameSetupModel GameSetupModel => + new ShitSetupState() + { + ThrowMode = ThrowMode.Reposition, + ThrowsPerRound = int.MaxValue, + ParticipantsMode = ParticipantsMode.GameLogic, + + }; } diff --git a/KoogleApp/Games/Training/Setup.razor b/KoogleApp/Games/Training/Setup.razor index ae76566..3d193d7 100644 --- a/KoogleApp/Games/Training/Setup.razor +++ b/KoogleApp/Games/Training/Setup.razor @@ -4,23 +4,33 @@ @using KoogleApp.Store.Game.ThrowPanel @using MudBlazor -@inject IDispatcher Dispatcher +@* @inject IDispatcher Dispatcher *@ + +@implements ISetupControl - + - + - + + @code { + ThrowMode ThrowMode = ThrowMode.Reposition; + + int ThrowsPerRound = 3; + + ParticipantsMode ParticipantsMode = ParticipantsMode.GameLogic; + + public IGameSetupModel GameSetupModel => + new TrainingSetupState() + { + ThrowMode = ThrowMode, + ParticipantsMode = ParticipantsMode, + ThrowsPerRound = ThrowsPerRound + }; } diff --git a/KoogleApp/appdata.json b/KoogleApp/appdata.json index b156e5c..d2fffea 100644 --- a/KoogleApp/appdata.json +++ b/KoogleApp/appdata.json @@ -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" } ],