@Override public boolean isValid(Game game) { if (!super.isValid(game)) return false; // we need a good location if (newLocation == null) { invalidMessage = "Location can't be null"; return false; } // Make sure the player does not put robber or pirate on the edge of the // map, // which is forbidden if (game.board().hexes().isAtEdge(newLocation)) { invalidMessage = "putting robber on the edge is not allowed"; return false; } // TODO: check if a previous action included rolling a 7, // or playing a soldier development card // Player may not leave the robber on the same location if (game.robber().location().equals(newLocation)) { invalidMessage = "putting robber back onto same location is not allowed"; return false; } Hex hex = game.board().hexes().get(newLocation); if (!hex.isRobberPlaceable()) { invalidMessage = "Can't place robber or pirate on a " + hex.getName(); return false; } return super.isValid(game); }
@Override public void start(GameBoardVisual gameVisual) { possibleNewLocations.clear(); for (Hex hex : gameVisual.hexVisuals().keySet()) { if (hex.isRobberPlaceable()) { if (hex.location().equals(gameVisual.game().robber().location())) { // Disable the current location of the robber gameVisual.hexVisuals().get(hex).setEnabled(false); } else { // A possible location to place the robber. possibleNewLocations.add(gameVisual.hexVisuals().get(hex)); } } else { // Can't place a robber here, darken location gameVisual.hexVisuals().get(hex).setDarkened(true); } } }