@using Koogle.Application.Games.Training @using Koogle.Domain.Enums @using MudBlazor Training-Einstellungen In die Vollen Abräumen Automatisch Frei wählbar Training ist ein freies Übungsspiel. Es gibt keinen Gewinner - nur Statistiken. Das Spiel muss manuell beendet werden. @code { /// /// Callback when setup options change. /// [Parameter] public EventCallback OnOptionsChanged { get; set; } /// /// Initial setup options. /// [Parameter] public object? InitialOptions { get; set; } private TrainingSetupOptionsInternal _options = new(); protected override void OnInitialized() { if (InitialOptions is TrainingSetupOptions options) { _options = new TrainingSetupOptionsInternal { ThrowMode = options.ThrowMode, ThrowsPerRound = options.ThrowsPerRound, ParticipantsMode = options.ParticipantsMode }; } } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await NotifyOptionsChanged(); } } private async Task NotifyOptionsChanged() { var options = new TrainingSetupOptions { ThrowMode = _options.ThrowMode, ThrowsPerRound = _options.ThrowsPerRound, ParticipantsMode = _options.ParticipantsMode }; await OnOptionsChanged.InvokeAsync(options); } /// /// Gets the current setup options. /// public TrainingSetupOptions GetOptions() => new() { ThrowMode = _options.ThrowMode, ThrowsPerRound = _options.ThrowsPerRound, ParticipantsMode = _options.ParticipantsMode }; // Internal mutable class for two-way binding private class TrainingSetupOptionsInternal { private ThrowMode _throwMode = ThrowMode.Reposition; private int _throwsPerRound = 3; private ParticipantsMode _participantsMode = ParticipantsMode.GameLogic; public ThrowMode ThrowMode { get => _throwMode; set => _throwMode = value; } public int ThrowsPerRound { get => _throwsPerRound; set => _throwsPerRound = value; } public ParticipantsMode ParticipantsMode { get => _participantsMode; set => _participantsMode = value; } } }