File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ private void OnKeyPressed(object sender, ConsoleKey key)
52
52
MoveCursor ( GridPosition . Right ) ;
53
53
break ;
54
54
case ConsoleKey . Spacebar :
55
- SelectItem ( ) ;
55
+ ChangeItemSelection ( ) ;
56
56
break ;
57
57
}
58
58
}
@@ -74,18 +74,34 @@ private void MoveCursor(GridPosition direction)
74
74
_gameBoardRenderer . ActivateItem ( gridPosition ) ;
75
75
}
76
76
77
- private void SelectItem ( )
77
+ private void ChangeItemSelection ( )
78
+ {
79
+ if ( _hasSelectedItem )
80
+ {
81
+ ClearSelection ( ) ;
82
+ }
83
+ else
84
+ {
85
+ SelectActiveItem ( ) ;
86
+ }
87
+ }
88
+
89
+ private void DragItem ( GridPosition gridPosition )
90
+ {
91
+ ClearSelection ( ) ;
92
+ SwapItemsAsync ( _gameBoardRenderer . ActiveGridPosition , gridPosition ) . Forget ( ) ;
93
+ }
94
+
95
+ private void SelectActiveItem ( )
78
96
{
79
97
_hasSelectedItem = true ;
80
98
_gameBoardRenderer . SelectActiveGridSlot ( ) ;
81
99
}
82
100
83
- private void DragItem ( GridPosition gridPosition )
101
+ private void ClearSelection ( )
84
102
{
85
103
_hasSelectedItem = false ;
86
104
_gameBoardRenderer . ClearSelection ( ) ;
87
-
88
- SwapItemsAsync ( _gameBoardRenderer . ActiveGridPosition , gridPosition ) . Forget ( ) ;
89
105
}
90
106
}
91
107
}
You can’t perform that action at this time.
0 commit comments