Skip to content

Commit

Permalink
allow Shepherd / Bard even Farmes rule is off
Browse files Browse the repository at this point in the history
Fixes #423
  • Loading branch information
farin committed Jan 24, 2022
1 parent d4cc7b9 commit ab29597
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ private Stream<Tuple2<FeaturePointer, Structure>> getAvailableStructures(GameSta
// TODO use interface instead
places = places.filter(t -> !(t._2 instanceof Castle) && !(t._2 instanceof SoloveiRazboynik) && !(t._2 instanceof Acrobats) && !(t._2 instanceof Circus));

if (!state.getBooleanRule(Rule.FARMERS)) {
places = places.filter(t -> !(t._2 instanceof Field));
}

// towers are handled by Tower capability separately (needs collect towers on all tiles)
// (and flier or magic portal use is also not allowed to be placed on tower
places = places.filter(t -> !(t._2 instanceof Tower));
Expand Down Expand Up @@ -155,15 +151,22 @@ protected Vector<PlayerAction<?>> prepareMeepleActions(GameState state, Vector<C
Position currentTilePos = lastPlaced.getPosition();
Stream<PlacedTile> tiles;
Stream<Tuple2<FeaturePointer, Structure>> specialMeepleStructures;
Stream<Tuple2<FeaturePointer, Structure>> allRegularMeepleStructures;
Stream<Tuple2<FeaturePointer, Structure>> regularMeepleStructures;

if (lastPlaced.getTile().hasModifier(PortalCapability.MAGIC_PORTAL) && !state.getFlags().contains(Flag.PORTAL_USED)) {
Stream<PlacedTile> allTiles = Stream.ofAll(state.getPlacedTiles().values());
regularMeepleStructures = getAvailableStructures(state, allTiles, HashSet.of(currentTilePos));
allRegularMeepleStructures = getAvailableStructures(state, allTiles, HashSet.of(currentTilePos));
specialMeepleStructures = getAvailableStructures(state, Stream.of(lastPlaced), HashSet.of(currentTilePos));
} else {
regularMeepleStructures = getAvailableStructures(state, Stream.of(lastPlaced), HashSet.of(currentTilePos));
specialMeepleStructures = regularMeepleStructures;
allRegularMeepleStructures = getAvailableStructures(state, Stream.of(lastPlaced), HashSet.of(currentTilePos));
specialMeepleStructures = allRegularMeepleStructures;
}

if (!state.getBooleanRule(Rule.FARMERS)) {
regularMeepleStructures = allRegularMeepleStructures.filter(t -> !(t._2 instanceof Field));
} else {
regularMeepleStructures = allRegularMeepleStructures;
}

Vector<PlayerAction<?>> actions = availMeeples.map(meeple -> {
Expand Down

0 comments on commit ab29597

Please sign in to comment.