Skip to content

Commit

Permalink
More sonar fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaglam committed Feb 4, 2024
1 parent 6bd0515 commit c2fb684
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class AbstractGameState { // TODO (HIGH) [AI] separate human mov
* @param views contains the user interfaces.
* @param playerAI is the current AI strategy.
*/
public AbstractGameState(StateMachine stateMachine, GameSettings settings, ViewFacade views, ArtificialIntelligence playerAI) {
protected AbstractGameState(StateMachine stateMachine, GameSettings settings, ViewFacade views, ArtificialIntelligence playerAI) {
this.stateMachine = stateMachine;
this.settings = settings;
this.playerAI = playerAI;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/carcassonne/model/grid/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ private boolean findBoundary(GridSpot spot, GridDirection direction, boolean[][]
if (!isOnGrid(newX, newY)) { // if not on grid
return true; // found boundary
}
if (spots[newX][newY].isOccupied()) {
} else if (!visitedPositions[newX][newY]) { // if not visited
if (spots[newX][newY].isFree() && !visitedPositions[newX][newY]) { // if not visited
visitedPositions[newX][newY] = true; // mark as visited
for (GridDirection newDirection : GridDirection.directNeighbors()) { // recursion
if (findBoundary(spots[newX][newY], newDirection, visitedPositions)) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/carcassonne/model/tile/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ public boolean allowsPlacingMeeple(GridDirection position, Player player, GameSe
TerrainType terrain = getTerrain(position);
boolean placeable = false;
if (isPlaced()) { // placing meeples on tiles that are not placed is not possible
if (terrain == TerrainType.OTHER) {
placeable = false; // you can never place on terrain other
} else if (terrain == TerrainType.MONASTERY) {
if (terrain == TerrainType.MONASTERY) {
placeable = true; // you can always place on a monastery
} else {
} else if (terrain != TerrainType.OTHER) {
GridPattern pattern;
if (terrain == TerrainType.FIELDS) {
pattern = new FieldsPattern(getGridSpot(), position);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carcassonne/view/main/TileLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TileLayer extends JPanel {
private static final long serialVersionUID = 1503933201337556131L;
private final List<TileDepiction> placementHighlights;
private final transient List<TileDepiction> tileLabels;
private final TileDepiction[][] tileDepictionGrid;
private final transient TileDepiction[][] tileDepictionGrid;

/**
* Creates the tile layer.
Expand Down

0 comments on commit c2fb684

Please sign in to comment.