diff --git a/KoogleApp/Components/Dialogs/StartGameDialog.razor b/KoogleApp/Components/Dialogs/StartGameDialog.razor
new file mode 100644
index 0000000..230adf6
--- /dev/null
+++ b/KoogleApp/Components/Dialogs/StartGameDialog.razor
@@ -0,0 +1,42 @@
+@using KoogleApp.Model
+
+
+
+
+
+
+ Save as favorite?
+
+
+
+
+ in die Vollen
+ Abräumen
+
+
+
+ Abbrechen
+ Start
+
+
+
+@code {
+ [CascadingParameter]
+ private IMudDialogInstance MudDialog { get; set; }
+
+ public ThrowMode ThrowMode { get; set; } = ThrowMode.Reposition;
+
+ [Parameter]
+ public string Description { get; set; } = "";
+
+ private void Cancel() => MudDialog.Cancel();
+
+ private void Start()
+ {
+ // if (!string.IsNullOrEmpty(Description))
+ {
+ // Snackbar.Add("Favorite added", Severity.Success);
+ MudDialog.Close(DialogResult.Ok(ThrowMode));
+ }
+ }
+}
diff --git a/KoogleApp/Components/Pages/Game.razor b/KoogleApp/Components/Pages/Game.razor
index 515993e..79d0291 100644
--- a/KoogleApp/Components/Pages/Game.razor
+++ b/KoogleApp/Components/Pages/Game.razor
@@ -5,6 +5,7 @@
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.SignalR.Client
@using KoogleApp.Components.Controls
+@using KoogleApp.Components.Dialogs
@using KoogleApp.Model.EventMessages
@using KoogleApp.Model.Framework
@using KoogleApp.Store.Game
@@ -22,6 +23,7 @@
@inject IMyEventAggregator EventAggregator
@inject IState ThrowPanelState
@inject IDispatcher Dispatcher
+@inject IDialogService DialogService
@* @inject IGameStatusDataService _dataService; *@
@@ -251,10 +253,38 @@
// }
}
- private void StartStopClick()
+ private async Task StartStopClick()
{
- var action = new StartStopAction(ThrowPanelState.Value);
- Dispatcher.Dispatch(action);
+ if (!ThrowPanelState.Value.IsStated)
+ {
+ var parameters = new DialogParameters { { x => x.Description, "" }};
+ // parameters.Add(x => x.Record, Record);
+
+ var options = new DialogOptions
+ {
+
+ };
+
+
+ var dialog = await DialogService.ShowAsync("Spiel starten", parameters, options);
+ var result = await dialog.Result;
+
+ if (!result.Canceled)
+ {
+ var action = new StartStopAction(ThrowPanelState.Value, new StartParams());
+ Dispatcher.Dispatch(action);
+ }
+ }
+ else
+ {
+ var result = await DialogService.ShowMessageBox("Spiel beenden?", "Spiel wirklich abbrechen?", "JA", "NEIN");
+ if (result.Value)
+ {
+ var action = new StartStopAction(ThrowPanelState.Value,null);
+ Dispatcher.Dispatch(action);
+ }
+ }
+
// _throwPanelState = ThrowPanelState.Create();
// await BroadcastThrowPanelStateAction(_throwPanelState);
diff --git a/KoogleApp/Hub/SharedModelHub.cs b/KoogleApp/Hub/SharedModelHub.cs
index b3e4222..92afbbe 100644
--- a/KoogleApp/Hub/SharedModelHub.cs
+++ b/KoogleApp/Hub/SharedModelHub.cs
@@ -52,7 +52,7 @@ namespace KoogleApp.Hub
await _hubConnection.StartAsync();
}
- public async Task HandleStartAction(StartStopAction stopAction, IDispatcher dispatcher)
+ public async Task HandelBroadcastThrowPanelStateAction(BroadcastThrowPanelStateAction action, IDispatcher dispatcher)
{
if (_hubConnection?.State != HubConnectionState.Connected)
{
@@ -64,7 +64,7 @@ namespace KoogleApp.Hub
{
if (_hubConnection is not null)
{
- await _hubConnection.SendAsync("BroadcastThrowPanelState", stopAction.State);
+ await _hubConnection.SendAsync("BroadcastThrowPanelState", action.State);
}
//await Clients.Others.SendAsync("ReceiveThrowPanelState", new ThrowPanelState());
diff --git a/KoogleApp/Model/StartParams.cs b/KoogleApp/Model/StartParams.cs
new file mode 100644
index 0000000..c8753f0
--- /dev/null
+++ b/KoogleApp/Model/StartParams.cs
@@ -0,0 +1,8 @@
+namespace KoogleApp.Model
+{
+ public record StartParams(ThrowMode ThrowMode, int ThrowsPerRound)
+ {
+ public StartParams() : this(ThrowMode: ThrowMode.Reposition, ThrowsPerRound:3)
+ {}
+ }
+}
diff --git a/KoogleApp/Model/ThrowPanelState.cs b/KoogleApp/Model/ThrowPanelState.cs
index 50a2433..37f70ee 100644
--- a/KoogleApp/Model/ThrowPanelState.cs
+++ b/KoogleApp/Model/ThrowPanelState.cs
@@ -5,16 +5,23 @@ using Microsoft.IdentityModel.Tokens;
namespace KoogleApp.Model
{
+ public enum ThrowMode
+ {
+ Reposition, // in die Vollen
+ Decrease // Abräumen
+ }
+
[FeatureState]
public record ThrowPanelState(bool IsStated, bool BellValue,
bool Pin1Value, bool Pin2Value, bool Pin3Value, bool Pin4Value, bool Pin5Value, bool Pin6Value, bool Pin7Value, bool Pin8Value, bool Pin9Value,
- bool Pin1Disabled, bool Pin2Disabled, bool Pin3Disabled, bool Pin4Disabled, bool Pin5Disabled, bool Pin6Disabled, bool Pin7Disabled, bool Pin8Disabled, bool Pin9Disabled
- )
+ bool Pin1Disabled, bool Pin2Disabled, bool Pin3Disabled, bool Pin4Disabled, bool Pin5Disabled, bool Pin6Disabled, bool Pin7Disabled, bool Pin8Disabled, bool Pin9Disabled,
+ int ThrowsPerRound, int ThrowCounter, ThrowMode ThrowMode)
{
// Required for creating initial state
public ThrowPanelState() : this(BellValue:false, IsStated:false,
Pin1Value:false, Pin2Value:false, Pin3Value: false, Pin4Value: false, Pin5Value: false, Pin6Value: false, Pin7Value: false, Pin8Value: false, Pin9Value: false,
- Pin1Disabled:false, Pin2Disabled:false, Pin3Disabled: false, Pin4Disabled: false, Pin5Disabled: false, Pin6Disabled: false, Pin7Disabled: false, Pin8Disabled: false, Pin9Disabled: false
+ Pin1Disabled:false, Pin2Disabled:false, Pin3Disabled: false, Pin4Disabled: false, Pin5Disabled: false, Pin6Disabled: false, Pin7Disabled: false, Pin8Disabled: false, Pin9Disabled: false,
+ ThrowsPerRound : 3, ThrowCounter : 0, ThrowMode : ThrowMode.Reposition
)
{ }
}
diff --git a/KoogleApp/Store/Game/ThrowPanel/Actions.cs b/KoogleApp/Store/Game/ThrowPanel/Actions.cs
index 127d9b4..aee5da0 100644
--- a/KoogleApp/Store/Game/ThrowPanel/Actions.cs
+++ b/KoogleApp/Store/Game/ThrowPanel/Actions.cs
@@ -4,7 +4,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
{
public record TogglePinValueAction(bool IsOn, int PinNumber);
- public record StartStopAction(ThrowPanelState State);
+ public record StartStopAction(ThrowPanelState State, StartParams? StartParams);
public record ConnectToHubAction();
diff --git a/KoogleApp/Store/Game/ThrowPanel/Effects.cs b/KoogleApp/Store/Game/ThrowPanel/Effects.cs
index fa35dbb..1e2ccd4 100644
--- a/KoogleApp/Store/Game/ThrowPanel/Effects.cs
+++ b/KoogleApp/Store/Game/ThrowPanel/Effects.cs
@@ -122,7 +122,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
// TODO error handling
}
- await _sharedModelHub.HandleStartAction(new StartStopAction(_state.Value), dispatcher);
+ await _sharedModelHub.HandelBroadcastThrowPanelStateAction(action, dispatcher);
}
}
}
diff --git a/KoogleApp/ThrowPanelState.json b/KoogleApp/ThrowPanelState.json
index 36856cc..497f0ec 100644
--- a/KoogleApp/ThrowPanelState.json
+++ b/KoogleApp/ThrowPanelState.json
@@ -1,13 +1,13 @@
{
- "IsStated": true,
+ "IsStated": false,
"BellValue": true,
- "Pin1Value": true,
- "Pin2Value": true,
- "Pin3Value": true,
- "Pin4Value": true,
- "Pin5Value": true,
- "Pin6Value": true,
- "Pin7Value": false,
+ "Pin1Value": false,
+ "Pin2Value": false,
+ "Pin3Value": false,
+ "Pin4Value": false,
+ "Pin5Value": false,
+ "Pin6Value": false,
+ "Pin7Value": true,
"Pin8Value": true,
"Pin9Value": true,
"Pin1Disabled": false,
@@ -18,5 +18,8 @@
"Pin6Disabled": false,
"Pin7Disabled": false,
"Pin8Disabled": false,
- "Pin9Disabled": false
+ "Pin9Disabled": false,
+ "ThrowsPerRound": 3,
+ "ThrowCounter": 0,
+ "ThrowMode": 0
}
\ No newline at end of file