diff --git a/KoogleApp/Games/Training/BoardTraining.razor b/KoogleApp/Games/Training/BoardTraining.razor index 2a95caa..67878a9 100644 --- a/KoogleApp/Games/Training/BoardTraining.razor +++ b/KoogleApp/Games/Training/BoardTraining.razor @@ -14,7 +14,7 @@ @if (TrainingState.Value != null) { -

@TrainingState.Value.TestField

+

@TrainingState.Value

} @code { diff --git a/KoogleApp/Games/Training/GameTrainingService.cs b/KoogleApp/Games/Training/GameTrainingService.cs index eb2f66b..05561ce 100644 --- a/KoogleApp/Games/Training/GameTrainingService.cs +++ b/KoogleApp/Games/Training/GameTrainingService.cs @@ -17,6 +17,16 @@ namespace KoogleApp.Games.Training public IGameModel InitGameModel(StartParams startParams) { _gameModel = new TrainingState(); + + var dict = new Dictionary(); + + foreach (var participant in startParams.Participants) + { + var tm = new ThrowModel() with { PlayerId = participant }; + dict.Add(participant, tm); + } + + _gameModel = _gameModel with { Throws = dict }; return _gameModel; } @@ -41,8 +51,16 @@ namespace KoogleApp.Games.Training res.Add(new SelectedNextPlayerIds(afterParticipantsState)); } + var playerId = progress.BeforeParticipantsState.PlayerIds.First(); - var newModel = ((TrainingState)(progress.GameModel)) with { TestField = "lorem ipsum" }; + var ts = progress.GameModel as TrainingState; + var tm = ts.Throws[playerId]; + ts.Throws[playerId] = tm with + { + ThrowCount = tm.ThrowCount+1 + }; + + var newModel = ((TrainingState)(progress.GameModel)) with { Throws = ts.Throws }; res.Add(new UpdateTrainingStateAction(newModel)); diff --git a/KoogleApp/Games/Training/Reducers.cs b/KoogleApp/Games/Training/Reducers.cs index f7e55a1..7fe8142 100644 --- a/KoogleApp/Games/Training/Reducers.cs +++ b/KoogleApp/Games/Training/Reducers.cs @@ -11,7 +11,7 @@ namespace KoogleApp.Games.Training [ReducerMethod] public static TrainingState OnTestActions(TrainingState state, UpdateTrainingStateAction action) { - return state with { TestField = action.TrainingState.TestField }; + return action.TrainingState; } } } diff --git a/KoogleApp/Games/Training/TrainingState.cs b/KoogleApp/Games/Training/TrainingState.cs index 02f2bc1..28081ab 100644 --- a/KoogleApp/Games/Training/TrainingState.cs +++ b/KoogleApp/Games/Training/TrainingState.cs @@ -3,11 +3,32 @@ using System.Text.Json.Serialization; namespace KoogleApp.Games.Training { - [FeatureState] - //[JsonPolymorphic(UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)] - public record TrainingState(string TestField) : IGameModel + + public record ThrowModel { - public TrainingState():this(TestField:"DefaultValue TrainingState") + public int PlayerId { get; set; } + + public int TeamNr { get; set; } + + public int PinCount { get; set; } + + public int CircleCount { get; set; } + + public int SinkCount { get; set; } + + public int StrikeCount { get; set; } + + public int ClearedCount { get; set; } + + public int ThrowCount { get; set; } + + public int BellCount { get; set; } + } + + [FeatureState] + public record TrainingState(Dictionary Throws) : IGameModel + { + public TrainingState():this([]) { } diff --git a/KoogleApp/Services/GameStatusDataService.cs b/KoogleApp/Services/GameStatusDataService.cs index 763ef49..c355a8f 100644 --- a/KoogleApp/Services/GameStatusDataService.cs +++ b/KoogleApp/Services/GameStatusDataService.cs @@ -84,7 +84,7 @@ namespace KoogleApp.Services return GetCurrentData(); } } - public StartParams? StartParams => GetInitialData().Status.StartParams; + public StartParams? StartParams => GetInitialData()?.Status?.StartParams; public Task SaveToDatabaseAndReset(GameStatus lastContent, string username) diff --git a/KoogleApp/appdata.json b/KoogleApp/appdata.json deleted file mode 100644 index a2548e6..0000000 --- a/KoogleApp/appdata.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "CurrentData": { - "Status": { - "StartParams": null, - "ThrowPanelState": { - "IsStated": true, - "BellValue": false, - "Pin1State": 0, - "Pin2State": 0, - "Pin3State": 0, - "Pin4State": 0, - "Pin5State": 0, - "Pin6State": 0, - "Pin7State": 0, - "Pin8State": 0, - "Pin9State": 0, - "ThrowsPerRound": 3, - "ThrowCounterPerRound": 2, - "ThrowMode": 0, - "ThrowPanelStateStatus": 3, - "ThrowCounter": 1, - "DayId": 35 - }, - "ParticipantsState": { - "PlayerIds": [ - 5, - 3, - 10, - 12, - 9 - ], - "Eliminated": [] - }, - "GameModel": { - "$type": "TrainingState", - "TestField": "lorem ipsum" - } - }, - "Version": 3, - "LastModified": "2025-11-25T16:54:41.0021528+01:00", - "LastModifiedBy": "test1@test.de" - }, - "UndoHistory": [ - { - "Status": { - "StartParams": null, - "ThrowPanelState": { - "IsStated": true, - "BellValue": false, - "Pin1State": 0, - "Pin2State": 0, - "Pin3State": 0, - "Pin4State": 0, - "Pin5State": 0, - "Pin6State": 0, - "Pin7State": 0, - "Pin8State": 0, - "Pin9State": 1, - "ThrowsPerRound": 3, - "ThrowCounterPerRound": 1, - "ThrowMode": 0, - "ThrowPanelStateStatus": 2, - "ThrowCounter": 0, - "DayId": 35 - }, - "ParticipantsState": { - "PlayerIds": [ - 5, - 3, - 10, - 12, - 9 - ], - "Eliminated": [] - }, - "GameModel": { - "$type": "TrainingState", - "TestField": "DefaultValue TrainingState" - } - }, - "Version": 2, - "LastModified": "2025-11-25T16:54:39.3461194+01:00", - "LastModifiedBy": "test1@test.de" - }, - { - "Status": { - "StartParams": { - "DayId": 35, - "ThrowMode": 0, - "ThrowsPerRound": 3, - "Participants": [ - 5, - 3, - 10, - 12, - 9 - ], - "ParticipantsMode": 1, - "KnownGameType": "GameTraining" - }, - "ThrowPanelState": { - "IsStated": true, - "BellValue": false, - "Pin1State": 0, - "Pin2State": 0, - "Pin3State": 0, - "Pin4State": 0, - "Pin5State": 0, - "Pin6State": 0, - "Pin7State": 0, - "Pin8State": 0, - "Pin9State": 0, - "ThrowsPerRound": 3, - "ThrowCounterPerRound": 1, - "ThrowMode": 0, - "ThrowPanelStateStatus": 1, - "ThrowCounter": 0, - "DayId": 35 - }, - "ParticipantsState": { - "PlayerIds": [ - 5, - 3, - 10, - 12, - 9 - ], - "Eliminated": [] - }, - "GameModel": { - "$type": "TrainingState", - "TestField": "DefaultValue TrainingState" - } - }, - "Version": 1, - "LastModified": "2025-11-25T15:54:32.8809692Z", - "LastModifiedBy": "test1@test.de" - } - ], - "RedoHistory": [] -} \ No newline at end of file