Skip to content

Commit 626ed07

Browse files
committed
Added feature for clearing a single field, when clicking on it
1 parent 195dd8b commit 626ed07

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,19 @@ private void ResetMove() =>
117117
private void SelectField(int index)
118118
{
119119
_selectedField = index;
120-
120+
121+
// Set all fields to not selected
121122
for (int i = 0; i < _currentMove.Length; i++)
122123
_currentMove[i].Selected = false;
123-
124+
125+
// Reset the field, if it is already filled
126+
if (_currentMove[_selectedField].Color is not null || _currentMove[_selectedField].Shape is not null)
127+
{
128+
_currentMove[_selectedField].Color = null;
129+
_currentMove[_selectedField].Shape = null;
130+
}
131+
132+
// Set the selected field to selected
124133
_currentMove[_selectedField].Selected = true;
125134
_selectable = true;
126135
}

0 commit comments

Comments
 (0)