diff --git a/Client.UI/Sql/DataHolder.cs b/Client.UI/Sql/DataHolder.cs index e7f7cbf..0f2e6cd 100644 --- a/Client.UI/Sql/DataHolder.cs +++ b/Client.UI/Sql/DataHolder.cs @@ -38,7 +38,7 @@ public void LoadData(IReadOnlyDictionary cards) public SpellData GetSpellData(UInt32 id) => spellsData.TryGetValue(id, out var spellData) ? spellData : new SpellData(id, string.Empty, string.Empty, string.Empty, string.Empty); - public AchievementInfo GetAchievementInfo(UInt32 id) => achievements.TryGetValue(id, out var name) ? name : null; + public AchievementInfo GetAchievementInfo(UInt32 id) => achievements.TryGetValue(id, out var name) ? name : new AchievementInfo(string.Empty, string.Empty); public string GetCriteriaDescription(UInt32 id) => criteriaDescriptions.TryGetValue(id, out var description) ? description : string.Empty; diff --git a/Client.UI/ViewModels/Achievements/AchievementsViewModel.cs b/Client.UI/ViewModels/Achievements/AchievementsViewModel.cs index 81d3262..c784f5c 100644 --- a/Client.UI/ViewModels/Achievements/AchievementsViewModel.cs +++ b/Client.UI/ViewModels/Achievements/AchievementsViewModel.cs @@ -11,7 +11,8 @@ public class AchievementsViewModel public AchievementsViewModel() { var game = App.GetGame() ?? throw new InvalidOperationException("Game must exist at this point"); - Achievements = game.Achievements.OrderByDescending(x => x.IsCompleted).ThenByDescending(x => x.CompletionDate).Select(x => new AchievementViewModel(x, game.DataHolder)).ToList(); + Achievements = game.Achievements.OrderByDescending(x => x.IsCompleted).ThenByDescending(x => x.CompletionDate) + .Select(x => new AchievementViewModel(x, game.DataHolder)).ToList(); } } } diff --git a/Client.UI/ViewModels/Cards/CardViewModel.cs b/Client.UI/ViewModels/Cards/CardViewModel.cs index dded384..c241cab 100644 --- a/Client.UI/ViewModels/Cards/CardViewModel.cs +++ b/Client.UI/ViewModels/Cards/CardViewModel.cs @@ -46,7 +46,7 @@ private set public ICommand OnClickCmd { get => onClickCmd; - protected set + protected init { if (onClickCmd == value) return; diff --git a/Client.UI/ViewModels/MainGame/PlayingGameViewModel.cs b/Client.UI/ViewModels/MainGame/PlayingGameViewModel.cs index e0cbf04..5aca449 100644 --- a/Client.UI/ViewModels/MainGame/PlayingGameViewModel.cs +++ b/Client.UI/ViewModels/MainGame/PlayingGameViewModel.cs @@ -32,7 +32,7 @@ public PlayingGameViewModel() AttackCmd = new (() => InvokeCardAction(CardAction.BasicAttack)); SpellAttackCmd = new (() => InvokeCardAction(CardAction.SpellUse)); - DefendCmd = new (() => Game.DefendSelfAsync()); + DefendCmd = new (Game.DefendSelfAsync); Game.PacketProcessed += OnPacketProcessed; } diff --git a/Client.UI/ViewModels/User/CreateAccountViewModel.cs b/Client.UI/ViewModels/User/CreateAccountViewModel.cs index c5ab689..9630261 100644 --- a/Client.UI/ViewModels/User/CreateAccountViewModel.cs +++ b/Client.UI/ViewModels/User/CreateAccountViewModel.cs @@ -10,9 +10,9 @@ public class CreateAccountViewModel : LoginViewModel { public string Username { get; set; } - public async Task CreateAccount(string password, Action callback) + public Task CreateAccount(string password, Action callback) { - return await UserOperation(new Packet(CMSGPackets.UserCreate).Builder().Write(Username).Write(Email).Write(password).Build(), callback); + return UserOperation(new Packet(CMSGPackets.UserCreate).Builder().Write(Username).Write(Email).Write(password).Build(), callback); } } } diff --git a/Client.UI/ViewModels/User/LoginViewModel.cs b/Client.UI/ViewModels/User/LoginViewModel.cs index c37c45b..e225c97 100644 --- a/Client.UI/ViewModels/User/LoginViewModel.cs +++ b/Client.UI/ViewModels/User/LoginViewModel.cs @@ -41,9 +41,9 @@ public LoginViewModel() Server = ServerList.FirstOrDefault(); } - public async Task Login(string password, Action callback) + public Task Login(string password, Action callback) { - return await UserOperation(new Packet(CMSGPackets.UserLogIn).Builder().Write(Email).Write(password).Build(), callback); + return UserOperation(new Packet(CMSGPackets.UserLogIn).Builder().Write(Email).Write(password).Build(), callback); } protected async Task UserOperation(Packet packet, Action callback) diff --git a/Client.UI/ViewModels/User/UserViewModel.cs b/Client.UI/ViewModels/User/UserViewModel.cs index c6caa98..4cd21da 100644 --- a/Client.UI/ViewModels/User/UserViewModel.cs +++ b/Client.UI/ViewModels/User/UserViewModel.cs @@ -20,19 +20,19 @@ public UserViewModel(string name, Game game) { this.game = game; Name = name; - AcceptFriend = new AsyncCommandHandler(async () => await HandleFriendRequest(UserRelationAction.AcceptFriend)); - DenyFriend = new AsyncCommandHandler(async () => await HandleFriendRequest(UserRelationAction.DenyFriend)); - BlockUser = new AsyncCommandHandler(async () => await HandleFriendRequest(UserRelationAction.BlockUser)); - RemoveBlockedUser = new AsyncCommandHandler(async () => await HandleFriendRequest(UserRelationAction.RemoveBlockedUser)); + AcceptFriend = new AsyncCommandHandler(() => HandleFriendRequest(UserRelationAction.AcceptFriend)); + DenyFriend = new AsyncCommandHandler(() => HandleFriendRequest(UserRelationAction.DenyFriend)); + BlockUser = new AsyncCommandHandler(() => HandleFriendRequest(UserRelationAction.BlockUser)); + RemoveBlockedUser = new AsyncCommandHandler(() => HandleFriendRequest(UserRelationAction.RemoveBlockedUser)); } - protected async Task HandleFriendRequest(UserRelationAction action) + protected Task HandleFriendRequest(UserRelationAction action) { var packet = new Packet(CMSGPackets.UserRelation); packet.Write(Name); packet.Write((byte)action); - await game.SendPacketAsync(packet); + return game.SendPacketAsync(packet); } } }