Skip to content

Commit 2edebbe

Browse files
Merge pull request #105 from CodebreakerApp/82-allow-to-clear-a-selection-before-a-move-is-done
82 allow to clear a selection before a move is done
2 parents 1ff1b32 + 94fa03d commit 2edebbe

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/CodeBreaker.Blazor.Client/Components/Playground.razor.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private void SelectColor(string color)
135135
else
136136
{
137137
// If no field is selected, find the first field that is not set
138-
fieldIndex = Array.FindIndex(_currentMove, f => f.Color is null && f.Shape is null);
138+
fieldIndex = Array.FindIndex(_currentMove, f => f.Color is null);
139139

140140
// If all fields are set, do not set the color
141141
if (fieldIndex == -1)
@@ -148,8 +148,26 @@ private void SelectColor(string color)
148148

149149
private void SelectShape(string shape)
150150
{
151-
_currentMove[_selectedField].Selected = true;
152-
_currentMove[_selectedField].Shape = shape;
151+
//_currentMove[_selectedField].Selected = true;
152+
//_currentMove[_selectedField].Shape = shape;
153+
154+
int fieldIndex;
155+
156+
// If a field is selected, use the selected field
157+
if (_selectedField != -1)
158+
fieldIndex = _selectedField;
159+
else
160+
{
161+
// If no field is selected, find the first field that is not set
162+
fieldIndex = Array.FindIndex(_currentMove, f => f.Shape is null);
163+
164+
// If all fields are set, do not set the color
165+
if (fieldIndex == -1)
166+
return;
167+
}
168+
169+
_currentMove[fieldIndex].Selected = true;
170+
_currentMove[fieldIndex].Shape = shape;
153171
}
154172
#endregion
155173

src/CodeBreaker.Blazor.Client/Components/Playground.razor.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@
121121
height: calc(var(--game-field-height) - 4px);
122122
}
123123

124-
.game-container .game-move div {
125-
margin: 0 auto;
126-
}
127-
128124
.game-container .game-row.selectable .can-drop,
129125
.game-container .game-row.selectable .can-drop,
130126
.colors div:hover {

0 commit comments

Comments
 (0)