@@ -91,7 +91,7 @@ public static Node create(
91
91
ObservableValue <Set <Animal >> cancelledAnimalsO = boardO .map (Board ::cancelledAnimals );
92
92
// the fringe only exists when the next action is to place a tile
93
93
ObservableValue <Set <Pos >> fringeTilesO = gameStateO .map (
94
- state -> state .nextAction () == GameState .Action .PLACE_TILE
94
+ state -> ( state .nextAction () == GameState .Action .PLACE_TILE && isOwnerCurrentPlayerO . getValue ())
95
95
// important to understand
96
96
// we can not use boardO.getValue() here!
97
97
// because this map may be triggered before boardO gets updated!
@@ -148,23 +148,27 @@ public static Node create(
148
148
if (!isInFringeO .getValue ()) return new CellData (Color .TRANSPARENT );
149
149
150
150
PlayerColor currentPlayer = gameStateO .getValue ().currentPlayer ();
151
+ assert currentPlayer != null ;
152
+
151
153
152
154
// if the mouse is currently on this tile (in the fringe) we display it normally
153
155
// if it can be placed there with its current position, and with a white veil otherwise
154
156
if (group .isHover ()) {
155
157
PlacedTile willBePlacedTile = new PlacedTile (
156
158
gameStateO .getValue ().tileToPlace (), currentPlayer , rotationO .getValue (), pos
157
159
);
158
- return new CellData (willBePlacedTile ,
159
- boardO .getValue ().canAddTile (willBePlacedTile ) ? Color .TRANSPARENT : Color .WHITE
160
- );
160
+ boolean canBePlaced = boardO .getValue ().canAddTile (willBePlacedTile );
161
+ return new CellData (willBePlacedTile , canBePlaced ? Color .TRANSPARENT : Color .WHITE );
161
162
}
163
+
164
+ boolean couldBePlaced = boardO .getValue ().couldPlaceTileAtPos (gameStateO .getValue ().tileToPlace (), pos );
165
+
162
166
// finally, if the tile is in the fringe but the mouse is not on it,
163
167
// we display it with a veil of the current player's color
164
- return new CellData (ColorMap .fillColor (currentPlayer ));
168
+ return new CellData (ColorMap .fillColor (currentPlayer ). deriveColor ( 0 , 1 , 1 , couldBePlaced ? 1 : .5 ) );
165
169
// these arguments are the sensibility of the code,
166
170
// every time one of them changes, the code is re-executed
167
- }, isInFringeO , group .hoverProperty (), rotationO , darkVeilEnabledO , placedTileO );
171
+ }, isInFringeO , group .hoverProperty (), rotationO , darkVeilEnabledO , placedTileO , isOwnerCurrentPlayerO );
168
172
169
173
// we bind the graphical properties of the group to the cell data's values
170
174
group .rotateProperty ().bind (cellDataO .map (cellData -> cellData .tileRotation ().degreesCW ()));
0 commit comments