dev states on stop game

This commit is contained in:
beo3000 2025-11-11 19:11:15 +01:00
parent 1f3df7723f
commit 0df393812a
6 changed files with 57 additions and 212 deletions

View File

@ -62,15 +62,9 @@
</div>
<!-- Scrollbarer Inhalt -->
<MudTextField @bind-Value="SharedText"></MudTextField>
<p>Aktueller Text: @SharedText</p>
<MudContainer Class="mt-4">
@switch (_gameView)
{
case GameView.Throw:
@ -87,16 +81,7 @@
break;
}
<MudToolBar>
<MudTooltip Text="Undo" Color="Color.Primary" Placement="Placement.Bottom" Arrow="true">
<MudIconButton Icon="@Icons.Material.Filled.Save" Variant="Variant.Filled" Color="Color.Primary"
Disabled="@(!_canSave)"
Class="mr-5" OnClick="SaveClick" />
</MudTooltip>
</MudToolBar>
</MudContainer>
@code {
// private ThrowPanelState _throwPanelState = null;
@ -111,21 +96,7 @@
private bool isAuthenticated;
private string _sharedText = string.Empty;
private bool _canSave = true;
public string SharedText
{
get => _sharedText;
set
{
if (_sharedText != value)
{
_sharedText = value;
}
}
}
// private HubConnection? hubConnection;

View File

@ -16,7 +16,7 @@ namespace KoogleApp.Services
bool CanUndo();
bool CanRedo();
Task SaveToDatabaseAndReset();
Task SaveToDatabaseAndReset(GameStatus lastContent, string username);
void Initialize(GameStatus content, string username);
}
@ -42,6 +42,14 @@ namespace KoogleApp.Services
{
lock (_lock)
{
if (_currentData == null)
{
return new GameStatusSnapshot
{
Version = -1
};
}
return new GameStatusSnapshot
{
Status = _currentData.Status,
@ -52,8 +60,10 @@ namespace KoogleApp.Services
}
}
public Task SaveToDatabaseAndReset()
public Task SaveToDatabaseAndReset(GameStatus lastContent, string username)
{
UpdateData(lastContent, username);
Initialize(null, "system");
if (File.Exists(_dataFilePath))

View File

@ -53,7 +53,9 @@ namespace KoogleApp.Store.Game.ThrowPanel
}
else // stop action
{
await _dataService.SaveToDatabaseAndReset();
var username = await GetUsername();
await _dataService.SaveToDatabaseAndReset(new GameStatus { ThrowPanelState = _state.Value with { ThrowPanelStateStatus = ThrowPanelStateStatus.GameEnd } }, username);
dispatcher.Dispatch(new UpdateUndoRedoStateAction());
}
dispatcher.Dispatch(new ThrowPanelStateChangedAction(_state.Value, false));
@ -188,7 +190,11 @@ namespace KoogleApp.Store.Game.ThrowPanel
if (state == null)
{
var data = _dataService.GetCurrentData();
state = data.Status.ThrowPanelState;
if (data.Status != null)
{
state = data.Status.ThrowPanelState;
}
dispatcher.Dispatch(new UpdateUndoRedoStateAction());
}

View File

@ -0,0 +1,27 @@
{
"IsStated": false,
"BellValue": 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,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 1,
"ThrowMode": 0,
"ThrowPanelStateStatus": 4,
"ThrowCounter": 0
}

View File

@ -1,175 +0,0 @@
{
"CurrentData": {
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": false,
"Pin1Value": false,
"Pin2Value": false,
"Pin3Value": false,
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
"Pin3Disabled": false,
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 3,
"ThrowMode": 1,
"ThrowPanelStateStatus": 3,
"ThrowCounter": 2
}
},
"Version": 5,
"LastModified": "2025-11-11T14:25:20.7054454+01:00",
"LastModifiedBy": "test1@test.de"
},
"UndoHistory": [
{
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": false,
"Pin1Value": false,
"Pin2Value": false,
"Pin3Value": false,
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
"Pin3Disabled": false,
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 2,
"ThrowMode": 1,
"ThrowPanelStateStatus": 2,
"ThrowCounter": 1
}
},
"Version": 4,
"LastModified": "2025-11-11T14:25:20.6996276+01:00",
"LastModifiedBy": "test1@test.de"
},
{
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": false,
"Pin1Value": false,
"Pin2Value": false,
"Pin3Value": false,
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
"Pin3Disabled": false,
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 2,
"ThrowMode": 1,
"ThrowPanelStateStatus": 3,
"ThrowCounter": 1
}
},
"Version": 3,
"LastModified": "2025-11-11T14:21:38.6653918+01:00",
"LastModifiedBy": "test1@test.de"
},
{
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": false,
"Pin1Value": false,
"Pin2Value": false,
"Pin3Value": false,
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
"Pin3Disabled": false,
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": false,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 1,
"ThrowMode": 1,
"ThrowPanelStateStatus": 2,
"ThrowCounter": 0
}
},
"Version": 2,
"LastModified": "2025-11-11T14:21:38.6623607+01:00",
"LastModifiedBy": "test1@test.de"
},
{
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": 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,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 1,
"ThrowMode": 1,
"ThrowPanelStateStatus": 1,
"ThrowCounter": 0
}
},
"Version": 1,
"LastModified": "2025-11-11T14:21:31.2803757+01:00",
"LastModifiedBy": "test1@test.de"
}
],
"RedoHistory": []
}

View File

@ -5,4 +5,10 @@ Create Schema:
''' dotnet ef migrations add 001 --project KoogleApp
Update Database:
''' dotnet ef database update -- Development --project KoogleApp
''' dotnet ef database update -- Development --project KoogleApp
## TODOs
- Redo State after start / lode or game stop
-