File tree Expand file tree Collapse file tree
src/CodeBreaker.Blazor.Client/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 ondragover = " event.preventDefault();"
2222 @ondragenter = " @(() => SetDropClass(localVariable))"
2323 @ondragleave = " @RemoveDropClass"
24- @ondrop = " () => UpdateField(localVariable)" / >
24+ @ondrop = " () => UpdateField(localVariable)"
25+ @onclick = " () => SelectField(localVariable)" / >
2526 }
2627 else if (_isMobile && i == 1 )
2728 {
7071 {
7172 <div draggable =" true"
7273 class =" @($" draggable {colorField.ToLower()} " )"
73- @ondragstart =" @(() => _activeColor = colorField)" >
74+ @ondragstart =" @(() => _activeColor = colorField)"
75+ @onclick =" () => SelectColor(colorField)" >
7476 @colorField [0]
7577 </div >
7678 }
9193 {
9294 <div draggable =" true"
9395 class =" @($" draggable shape {shapeField.ToLower()} " )"
94- @ondragstart =" @(() => _activeShape = shapeField)" />
96+ @ondragstart =" @(() => _activeShape = shapeField)"
97+ @onclick =" () => SelectShape(shapeField)" />
9598 }
9699 else
97100 {
Original file line number Diff line number Diff line change @@ -122,8 +122,23 @@ private void SelectField(int index)
122122
123123 private void SelectColor ( string color )
124124 {
125- _currentMove [ _selectedField ] . Selected = true ;
126- _currentMove [ _selectedField ] . Color = color ;
125+ int fieldIndex ;
126+
127+ // If a field is selected, use the selected field
128+ if ( _selectedField != - 1 )
129+ fieldIndex = _selectedField ;
130+ else
131+ {
132+ // If no field is selected, find the first field that is not set
133+ fieldIndex = Array . FindIndex ( _currentMove , f => f . Color is null && f . Shape is null ) ;
134+
135+ // If all fields are set, do not set the color
136+ if ( fieldIndex == - 1 )
137+ return ;
138+ }
139+
140+ _currentMove [ fieldIndex ] . Selected = true ;
141+ _currentMove [ fieldIndex ] . Color = color ;
127142 }
128143
129144 private void SelectShape ( string shape )
You can’t perform that action at this time.
0 commit comments