Skip to content

Commit

Permalink
#676 Adds discovery text for planetary statuses.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomount committed Apr 3, 2024
1 parent 3305012 commit e46a2cf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4527,8 +4527,10 @@ public void handleTimedStatuses(final int turnNumber) {
AppliedStatus applied = new AppliedStatus(status.getStatus());
if (statuses.add(applied) && planetOwnerInfo != null) {
// Need to improve text for new status
String text = status.getStatus().getDiscoveryText();
text = text.replaceAll("<PLANETNAME>", getName());
Message msg = new Message(MessageType.PLANETARY,
"Planet status changed: " + status.getStatus().getDescription(),
getName() + " has new discovery: " + text,
Icons.getIconByName(Icons.ICON_PLANET));
msg.setMatchByString(getName());
msg.setCoordinate(getCoordinate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static boolean isConflictingWith(final PlanetaryStatus status,
private boolean hidden;
/** Status can be found with away team */
private boolean awayTeam;
/** Text to show when discovering planetary status. */
private String discoveryText;
/**
* Create new planetary status definition
* @param id ID of planetary status definition
Expand All @@ -104,6 +106,7 @@ public static boolean isConflictingWith(final PlanetaryStatus status,
this.conflictingIds = Objects.requireNonNull(conflictingIds);
this.hidden = false;
this.setAwayTeam(false);
setDiscoveryText("");
}

/**
Expand Down Expand Up @@ -237,4 +240,20 @@ public void setAwayTeam(final boolean awayTeam) {
this.awayTeam = awayTeam;
}

/**
* Get Planetary status discovery text.
* @return the discoveryText
*/
public String getDiscoveryText() {
return discoveryText;
}

/**
* Set discovery text for planetary status.
* @param discoveryText the discoveryText to set
*/
public void setDiscoveryText(final String discoveryText) {
this.discoveryText = discoveryText;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ protected Optional<PlanetaryStatus> parseFromJson(final JSONObject jobj) {

// Optional fields
final var description = jobj.optString("description", "");
String discovery = jobj.optString("discoveryText", description);
var rawConflicts = jobj.optJSONArray("conflictsWith", new JSONArray());
var conflictsWith = new ArrayList<String>();
for (var rawEntry : rawConflicts) {
Expand All @@ -176,6 +177,7 @@ protected Optional<PlanetaryStatus> parseFromJson(final JSONObject jobj) {
var tmp = new PlanetaryStatus(statusId, name, description,
conflictsWith.toArray(new String[conflictsWith.size()]));

tmp.setDiscoveryText(discovery);
// Other optional fields
tmp.setFoodBonus(jobj.optInt("foodBonus", 0));
tmp.setMineBonus(jobj.optInt("mineBonus", 0));
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/resources/data/planet_statuses/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"id": "FERTILE_SOIL",
"name": "Fertile soil",
"description": "Planet's surface has fertile soil where plants grow faster. This will grant one extra food per star year.",
"discoveryText": "<PLANETNAME> soil is full of minerals and has good growing biome for plants. This will grant one extra food per star year.",
"conflictsWith": [
"METAL_RICH_SURFACE",
"MOLTEN_LAVA"
Expand All @@ -25,6 +26,7 @@
"id": "MOLTEN_LAVA",
"name": "Molten lava",
"description": "Planet surface has big lava pool or river. This can be used to easy access metal and temperature can be used to increase productivity, downside is this cause unhappiness to population.",
"discoveryText": "<PLANETNAME> has massive lava flow. This hot magma can be used to access metal and heat can be used as energy source. Problem is that people near there lava are affraid.",
"conflictsWith": [
"FERTILE_SOIL",
"METAL_RICH_SURFACE"
Expand Down

0 comments on commit e46a2cf

Please sign in to comment.