Skip to content

Commit 55b5c32

Browse files
committed
Spell attack should no longer be usable if Card has no spell
1 parent de94574 commit 55b5c32

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Client.UI/ViewModels/MainGame/PlayingGameViewModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Client.UI.Enums;
55
using System;
66
using System.Linq;
7+
using System.Windows;
78

89
namespace Client.UI.ViewModels.MainGame
910
{
@@ -31,7 +32,7 @@ public PlayingGameViewModel()
3132
Opponent = new (Game.Opponent);
3233

3334
AttackCmd = new (() => InvokeCardAction(CardAction.BasicAttack));
34-
SpellAttackCmd = new (() => InvokeCardAction(CardAction.SpellUse));
35+
SpellAttackCmd = new (() => InvokeCardAction(CardAction.SpellUse), () => Game.Player.ActiveCard?.Spell != null);
3536
DefendCmd = new (Game.DefendSelfAsync);
3637

3738
Game.PacketProcessed += OnPacketProcessed;
@@ -47,13 +48,18 @@ private void OnPacketProcessed(UInt16 packet)
4748

4849
foreach (var card in Opponent.Cards)
4950
card.SelectionType = SelectionType.None;
51+
52+
Application.Current.Dispatcher.Invoke(SpellAttackCmd.NotifyCanExecuteChanged);
5053
}
5154

5255
private void InvokeCardAction(CardAction action)
5356
{
5457
if (action == CardAction.SpellUse)
5558
{
5659
var targets = Game.Player.ActiveCard.Spell?.GetPossibleTargets(Game.Player, Game.Opponent);
60+
if (targets == null)
61+
return;
62+
5763
foreach (var playerCards in Player.Cards.Where(x => targets.Contains(x.Guid)).Concat(Opponent.Cards.Where(x => targets.Contains(x.Guid))))
5864
{
5965
playerCards.SelectionType = SelectionType.SpellUsable;

0 commit comments

Comments
 (0)