ObservableProperty entfernt, Properties refaktoriert
In allen betroffenen ViewModels wurden die mit [ObservableProperty] markierten Felder entfernt und durch public partial Properties mit { get; set; } ersetzt. Property-Namen wurden vereinheitlicht (z.B. IsChallengeVisible, PendingChallenge, SyncStatusText). In LobbyViewModel.cs wird nun geprüft, ob alle Spieler bereit sind, bevor das Spiel gestartet werden kann (CanStartGame). Die Behandlung von StateChanged-Messages aktualisiert relevante Properties. In SlipItIn.csproj wurde das WarningLevel für alle Konfigurationen explizit auf 1 gesetzt.
This commit is contained in:
@@ -104,4 +104,36 @@
|
|||||||
<AndroidManifest>Platforms\Android\AndroidManifest.Release.xml</AndroidManifest>
|
<AndroidManifest>Platforms\Android\AndroidManifest.Release.xml</AndroidManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0-android|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0-ios|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0-maccatalyst|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0-windows10.0.19041.0|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0-android|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0-ios|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0-maccatalyst|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0-windows10.0.19041.0|AnyCPU'">
|
||||||
|
<WarningLevel>1</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -23,31 +23,31 @@ public partial class GameBoardViewModel : BaseViewModel,
|
|||||||
private DateTime _lastStateUtc = DateTime.UtcNow;
|
private DateTime _lastStateUtc = DateTime.UtcNow;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int gameId;
|
private partial int GameId { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int currentRound;
|
private partial int CurrentRound { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int roundTimeRemaining;
|
private partial int RoundTimeRemaining { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isChallengeVisible;
|
private partial bool IsConnected { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private SlipChallengeDto? pendingChallenge;
|
private partial bool IsSyncing { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isConnected;
|
public partial bool IsChallengeVisible { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isSyncing;
|
public partial SlipChallengeDto? PendingChallenge { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string syncStatusText = "Bereit";
|
public partial string SyncStatusText { get; set; } = "Bereit";
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int pendingSyncActions;
|
public partial int PendingSyncActions { get; set; }
|
||||||
|
|
||||||
public ObservableCollection<PlayerCardDto> MyCards { get; } = [];
|
public ObservableCollection<PlayerCardDto> MyCards { get; } = [];
|
||||||
public ObservableCollection<PlayerInfoDto> OtherPlayers { get; } = [];
|
public ObservableCollection<PlayerInfoDto> OtherPlayers { get; } = [];
|
||||||
@@ -233,12 +233,12 @@ public partial class GameBoardViewModel : BaseViewModel,
|
|||||||
|
|
||||||
public void Receive(SyncStateChangedMessage message)
|
public void Receive(SyncStateChangedMessage message)
|
||||||
{
|
{
|
||||||
MainThread.BeginInvokeOnMainThread(() =>
|
MainThread.BeginInvokeOnMainThread((Action)(() =>
|
||||||
{
|
{
|
||||||
IsSyncing = message.Value.IsSyncing;
|
IsSyncing = message.Value.IsSyncing;
|
||||||
SyncStatusText = message.Value.StatusText;
|
SyncStatusText = message.Value.StatusText;
|
||||||
PendingSyncActions = message.Value.PendingActions;
|
PendingSyncActions = message.Value.PendingActions;
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Receive(ConnectionStateChangedMessage message)
|
public void Receive(ConnectionStateChangedMessage message)
|
||||||
|
|||||||
@@ -22,25 +22,25 @@ public partial class LobbyViewModel : BaseViewModel,
|
|||||||
private readonly IApiService _apiService;
|
private readonly IApiService _apiService;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string lobbyCode = string.Empty;
|
public partial string LobbyCode { get; set; } = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int gameId;
|
public partial int GameId { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isHost;
|
public partial bool IsHost { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isConnected;
|
public partial bool IsConnected { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isSyncing;
|
public partial bool IsSyncing { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string syncStatusText = "Bereit";
|
public partial string SyncStatusText { get; set; } = "Bereit";
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int pendingSyncActions;
|
public partial int PendingSyncActions { get; set; }
|
||||||
|
|
||||||
public ObservableCollection<PlayerInfoDto> Players { get; } = [];
|
public ObservableCollection<PlayerInfoDto> Players { get; } = [];
|
||||||
|
|
||||||
@@ -106,6 +106,9 @@ public partial class LobbyViewModel : BaseViewModel,
|
|||||||
if (GameId <= 0)
|
if (GameId <= 0)
|
||||||
throw new InvalidOperationException("Keine aktive Lobby gefunden.");
|
throw new InvalidOperationException("Keine aktive Lobby gefunden.");
|
||||||
|
|
||||||
|
if (!CanStartGame)
|
||||||
|
throw new InvalidOperationException("Alle Spieler müssen bereit sein, bevor das Spiel gestartet werden kann.");
|
||||||
|
|
||||||
await _signalR.StartGameAsync(GameId);
|
await _signalR.StartGameAsync(GameId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -133,6 +136,11 @@ public partial class LobbyViewModel : BaseViewModel,
|
|||||||
Players.Clear();
|
Players.Clear();
|
||||||
foreach (var player in message.Value.Players)
|
foreach (var player in message.Value.Players)
|
||||||
Players.Add(player);
|
Players.Add(player);
|
||||||
|
|
||||||
|
var currentUsername = _authSession.CurrentUser?.Username;
|
||||||
|
IsCurrentPlayerReady = message.Value.Players.Any(p =>
|
||||||
|
p.IsReady && string.Equals(p.Username, currentUsername, StringComparison.OrdinalIgnoreCase));
|
||||||
|
CanStartGame = message.Value.Players.Count >= 2 && message.Value.Players.All(p => p.IsReady);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ public partial class LoginViewModel : BaseViewModel
|
|||||||
private readonly IGameStateService _gameStateService;
|
private readonly IGameStateService _gameStateService;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string email = string.Empty;
|
public partial string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string password = string.Empty;
|
public partial string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
public LoginViewModel(IApiService apiService, IAuthSessionService authSession, ISignalRService signalR, IGameStateService gameStateService)
|
public LoginViewModel(IApiService apiService, IAuthSessionService authSession, ISignalRService signalR, IGameStateService gameStateService)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ public partial class RegisterViewModel : BaseViewModel
|
|||||||
private readonly ISignalRService _signalR;
|
private readonly ISignalRService _signalR;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string username = string.Empty;
|
public partial string Username { get; set; } = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string email = string.Empty;
|
public partial string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string password = string.Empty;
|
public partial string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
public RegisterViewModel(IApiService apiService, IAuthSessionService authSession, ISignalRService signalR)
|
public RegisterViewModel(IApiService apiService, IAuthSessionService authSession, ISignalRService signalR)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user