Skip to content

Commit

Permalink
Enhancement bernardosulzbach#118: Adding riverside location and achie…
Browse files Browse the repository at this point in the history
…vement
  • Loading branch information
Immutablevoid committed Oct 30, 2019
1 parent 6ea20f9 commit a2e68eb
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ void setBlobSize(int blobSize) {
this.blobSize = blobSize;
}

public enum Type {RIVER, BRIDGE, DUNGEON_ENTRANCE, DUNGEON_STAIRWAY, DUNGEON_ROOM, DUNGEON_CORRIDOR, LAND}
public enum Type {RIVER, BRIDGE, DUNGEON_ENTRANCE, DUNGEON_STAIRWAY, DUNGEON_ROOM, DUNGEON_CORRIDOR, LAND, RIVERSIDE}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ boolean isBridge(Point point) {
return river != null && river.isBridge(point.getY());
}

/**
* Returns if in this point there should be a riverside.
*/
boolean isRiverside(Point point) {
River leftOfRiver = rivers.get(point.getX() - 1);
River rightOfRiver = rivers.get(point.getX() + 1);
return leftOfRiver != null || rightOfRiver != null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ private Location createRandomBridgeLocation(@NotNull final Point point) {
return new Location(Random.select(locationPresetStore.getLocationPresetsByType(Type.BRIDGE)), world, point);
}

private Location createRiversideLocation(@NotNull final Point point) {
LocationPresetStore locationPresetStore = LocationPresetStore.getDefaultLocationPresetStore();
return new Location(Random.select(locationPresetStore.getLocationPresetsByType(Type.RIVERSIDE)), world, point);
}

public void expand(Point point) {
riverGenerator.expand(point, chunkSide);
Point currentPoint;
Expand All @@ -66,6 +71,8 @@ public void expand(Point point) {
world.addLocation(createRandomRiverLocation(currentPoint), currentPoint);
} else if (riverGenerator.isBridge(currentPoint)) {
world.addLocation(createRandomBridgeLocation(currentPoint), currentPoint);
} else if (riverGenerator.isRiverside(currentPoint)) {
world.addLocation(createRiversideLocation(currentPoint), currentPoint);
} else if (dungeonDistributor.rollForDungeon(currentPoint)) {
dungeonCreator.createDungeon(world, currentPoint);
} else {
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/achievements.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,17 @@
}
}
},
{
"id": "DOWN_BY_THE_RIVERSIDE",
"name": "Down By the Riverside",
"info": "Visit 10 different riversides.",
"text": "visited ten different riversides",
"explorationRequirements": {
"visitedLocations": {
"RIVERSIDE": 10
}
}
},
{
"id": "REAPER",
"name": "Reaper",
Expand Down
63 changes: 63 additions & 0 deletions src/main/resources/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,69 @@
"probability": 0.05
}
]
},
{
"id": "RIVERSIDE",
"type": "RIVERSIDE",
"name": {
"singular": "Riverside"
},
"color": [
100,
250,
200
],
"symbol": "R",
"info": "The is an area with a flowing river. The river seems to be brimming with fish.",
"blobSize": 0,
"lightPermittivity": 1,
"blockedEntrances": [
"U",
"D"
],
"spawners": [
{
"id": "FROG",
"population": {
"minimum": 1,
"maximum": 3
},
"delay": 2
},
{
"id": "GREEN_IGUANA",
"population": {
"minimum": 2,
"maximum": 2
},
"delay": 32
},
{
"id": "TRAVELER",
"population": {
"minimum": 1,
"maximum": 2
},
"delay": 36
}
],
"tags": [
"FISHABLE"
],
"items": [
{
"id": "STONE",
"probability": 0.3
},
{
"id": "SPEAR",
"probability": 0.1
},
{
"id": "STICK",
"probability": 0.3
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class AchievementsJsonFileTest extends ResourcesTypeTest {
private static final String QUERY_FIELD = "query";
private static final String FOREST_FIELD = "FOREST";
private static final String DESERT_FIELD = "DESERT";
private static final String RIVERSIDE_FIELD = "RIVERSIDE";
private static final String GRAVEYARD_FIELD = "GRAVEYARD";
private static final String PART_OF_DAY_FIELD = "partOfDay";
private static final String ACHIEVEMENTS_FIELD = "achievements";
Expand Down Expand Up @@ -121,6 +122,7 @@ private JsonRule getVisitedLocationsRule() {
Map<String, JsonRule> visitedLocationsRules = new HashMap<>();
JsonRule optionalIntegerRule = JsonRuleFactory.makeOptionalRule(JsonRuleFactory.makeIntegerRule());
visitedLocationsRules.put(DESERT_FIELD, optionalIntegerRule);
visitedLocationsRules.put(RIVERSIDE_FIELD, optionalIntegerRule);
visitedLocationsRules.put(GRAVEYARD_FIELD, optionalIntegerRule);
return JsonRuleFactory.makeObjectRule(visitedLocationsRules);
}
Expand Down

0 comments on commit a2e68eb

Please sign in to comment.