Skip to content

Commit ca9a13b

Browse files
committed
Refine reset logic in Playground class
Introduce a check for `AvailableShapes` to determine if the game uses only colors or both colors and shapes. If `AvailableShapes` is null or empty, reset only the color of the selected field. If both color and shape are set, reset both. Ensure the selected field is marked and `_selectable` is set to true.
1 parent 2be1390 commit ca9a13b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,21 @@ private void SelectField(int index)
122122
for (int i = 0; i < _currentMove.Length; i++)
123123
_currentMove[i].Selected = false;
124124

125-
// Reset the field, if it is already filled
126-
if (_currentMove[_selectedField].Color is not null || _currentMove[_selectedField].Shape is not null)
125+
if (AvailableShapes is null || !AvailableShapes.Any())
127126
{
127+
// Current game only with colors
128+
// Reset the color of the selected field (will be selected in the next step)
129+
_currentMove[_selectedField].Color = null;
130+
}
131+
else if (_currentMove[_selectedField].Color is not null && _currentMove[_selectedField].Shape is not null)
132+
{
133+
// Current game with colors and shapes
134+
// Reset the color and shape of the selected field when both are set
128135
_currentMove[_selectedField].Color = null;
129136
_currentMove[_selectedField].Shape = null;
130137
}
131138

139+
132140
// Set the selected field to selected
133141
_currentMove[_selectedField].Selected = true;
134142
_selectable = true;

0 commit comments

Comments
 (0)