58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using Fluxor;
|
|
using System.Text.Json.Serialization;
|
|
using static MudBlazor.CategoryTypes;
|
|
|
|
namespace KoogleApp.Games.Training
|
|
{
|
|
|
|
public record ThrowModel
|
|
{
|
|
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<int, ThrowModel> Throws) : IGameModel
|
|
{
|
|
public TrainingState() : this([])
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public static class TrainingStateExtension
|
|
{
|
|
public static TrainingState DeepCopy(this TrainingState State)
|
|
{
|
|
//// Array und alle Elemente kopieren
|
|
//var itemsCopy = Throws.Select(item => item with { }).ToArray();
|
|
//return this with { Throws = itemsCopy };
|
|
|
|
|
|
// Dictionary und alle Elemente kopieren
|
|
// Dictionary und alle Values kopieren
|
|
var itemsCopy = State.Throws.ToDictionary(
|
|
kvp => kvp.Key, // Key kopieren (int ist value type)
|
|
kvp => kvp.Value with { } // Value als Record kopieren
|
|
);
|
|
return State with { Throws = itemsCopy };
|
|
}
|
|
}
|
|
|
|
}
|