File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Client.UI/ViewModels/MainGame Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 4
4
using Client . UI . Enums ;
5
5
using System ;
6
6
using System . Linq ;
7
+ using System . Windows ;
7
8
8
9
namespace Client . UI . ViewModels . MainGame
9
10
{
@@ -31,7 +32,7 @@ public PlayingGameViewModel()
31
32
Opponent = new ( Game . Opponent ) ;
32
33
33
34
AttackCmd = new ( ( ) => InvokeCardAction ( CardAction . BasicAttack ) ) ;
34
- SpellAttackCmd = new ( ( ) => InvokeCardAction ( CardAction . SpellUse ) ) ;
35
+ SpellAttackCmd = new ( ( ) => InvokeCardAction ( CardAction . SpellUse ) , ( ) => Game . Player . ActiveCard ? . Spell != null ) ;
35
36
DefendCmd = new ( Game . DefendSelfAsync ) ;
36
37
37
38
Game . PacketProcessed += OnPacketProcessed ;
@@ -47,13 +48,18 @@ private void OnPacketProcessed(UInt16 packet)
47
48
48
49
foreach ( var card in Opponent . Cards )
49
50
card . SelectionType = SelectionType . None ;
51
+
52
+ Application . Current . Dispatcher . Invoke ( SpellAttackCmd . NotifyCanExecuteChanged ) ;
50
53
}
51
54
52
55
private void InvokeCardAction ( CardAction action )
53
56
{
54
57
if ( action == CardAction . SpellUse )
55
58
{
56
59
var targets = Game . Player . ActiveCard . Spell ? . GetPossibleTargets ( Game . Player , Game . Opponent ) ;
60
+ if ( targets == null )
61
+ return ;
62
+
57
63
foreach ( var playerCards in Player . Cards . Where ( x => targets . Contains ( x . Guid ) ) . Concat ( Opponent . Cards . Where ( x => targets . Contains ( x . Guid ) ) ) )
58
64
{
59
65
playerCards . SelectionType = SelectionType . SpellUsable ;
You can’t perform that action at this time.
0 commit comments