Skip to content

Commit

Permalink
#676 Adds reseBonus for status ids.
Browse files Browse the repository at this point in the history
Adds two new research statuses.
  • Loading branch information
tuomount committed Apr 10, 2024
1 parent 1d8e3c9 commit 9538e8b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 27 deletions.
7 changes: 7 additions & 0 deletions src/main/java/org/openRealmOfStars/starMap/planet/Planet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,13 @@ private int getTotalResearchProduction() {
addEntryIfWorthy(sb, "government", value);
}

for (var appliedStatus : statuses) {
final var status = appliedStatus.getStatus();
final var tmpVal = status.getReseBonus();
result += tmpVal;
addEntryIfWorthy(sb, status.getName(), tmpVal);
}

value = 0;
if (governor != null) {
if (governor.hasPerk(Perk.SCIENTIST)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ public static boolean isConflictingWith(final PlanetaryStatus status,
private int prodBonus;
/** Bonus/malus to credits production */
private int credBonus;
/** Bonus/malus to research production */
private int reseBonus;
/** Status is not visible, until it is applied. This cannot be revealed even
* by sending away team. */
private boolean hidden;
/** Status can be found with away team */
private boolean awayTeam;
/** Text to show when discovering planetary status. */
private String discoveryText;
/**
Expand All @@ -105,7 +105,6 @@ public static boolean isConflictingWith(final PlanetaryStatus status,
this.description = Objects.requireNonNull(description);
this.conflictingIds = Objects.requireNonNull(conflictingIds);
this.hidden = false;
this.setAwayTeam(false);
setDiscoveryText("");
}

Expand Down Expand Up @@ -177,6 +176,13 @@ public int getCredBonus() {
// This is to preserve immutability guarantees to rest of the code.
//

/**
* @return the reseBonus
*/
public int getReseBonus() {
return reseBonus;
}

/**
* @param foodBonus the foodBonus to set
*/
Expand Down Expand Up @@ -212,6 +218,13 @@ void setCredBonus(final int credBonus) {
this.credBonus = credBonus;
}

/**
* @param reseBonus the reseBonus to set
*/
void setReseBonus(final int reseBonus) {
this.reseBonus = reseBonus;
}

/**
* @return the hidden
*/
Expand All @@ -226,20 +239,6 @@ public void setHidden(final boolean hidden) {
this.hidden = hidden;
}

/**
* @return the awayTeam
*/
public boolean isAwayTeam() {
return awayTeam;
}

/**
* @param awayTeam the awayTeam to set
*/
public void setAwayTeam(final boolean awayTeam) {
this.awayTeam = awayTeam;
}

/**
* Get Planetary status discovery text.
* @return the discoveryText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ protected Optional<PlanetaryStatus> parseFromJson(final JSONObject jobj) {
tmp.setProdBonus(jobj.optInt("prodBonus", 0));
tmp.setHappinessBonus(jobj.optInt("happinesBonus", 0));
tmp.setCredBonus(jobj.optInt("credBonus", 0));
tmp.setReseBonus(jobj.optInt("reseBonus", 0));
tmp.setHidden(jobj.optBoolean("hidden", false));
tmp.setAwayTeam(jobj.optBoolean("awayTeam", false));

return Optional.of(tmp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public final class StatusIds {
* at some point. */
public static final String PIRATE_WORLD = "PIRATE_WORLD";

/** Planet has nanite sand which is active. Cannot mix with SPACE_TIME_WARP*/
public static final String NANITE_SAND = "NANITE_SAND";

/** Planet has space time warp. This cannot be mixed with NANITE_SAND. */
public static final String SPACE_TIME_WARP = "SPACE_TIME_WARP";

/** List storing all hardcoded IDs. Populated at runtime, via reflection. */
private static List<String> hardcodedIds = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ public static TimedStatus[] getRandomPlanetaryStatus(
case BARRENWORLD1:
gems = 20;
value = DiceGenerator.getRandom(99);
if (value < 50) {
if (value < 5) {
if (DiceGenerator.getBoolean()) {
status = StatusFactory.getTimedStatus(StatusIds.NANITE_SAND,
TimedStatusType.AFTER_COLONIZATION,
DiceGenerator.getRandom(11, 60));
} else {
status = StatusFactory.getTimedStatus(StatusIds.SPACE_TIME_WARP,
TimedStatusType.AFTER_COLONIZATION,
DiceGenerator.getRandom(11, 60));
}
} else if (value < 55) {
status = StatusFactory.getTimedStatus(StatusIds.METAL_RICH_SURFACE,
TimedStatusType.AFTER_COLONIZATION_OR_AWAY_TEAM,
DiceGenerator.getRandom(8, 30));
Expand Down Expand Up @@ -151,10 +161,20 @@ public static TimedStatus[] getRandomPlanetaryStatus(
gems = 15;
value = DiceGenerator.getRandom(99);
if (value < 10) {
if (DiceGenerator.getBoolean()) {
status = StatusFactory.getTimedStatus(StatusIds.NANITE_SAND,
TimedStatusType.AFTER_COLONIZATION,
DiceGenerator.getRandom(11, 60));
} else {
status = StatusFactory.getTimedStatus(StatusIds.SPACE_TIME_WARP,
TimedStatusType.AFTER_COLONIZATION,
DiceGenerator.getRandom(11, 60));
}
} else if (value < 20) {
status = StatusFactory.getTimedStatus(StatusIds.FERTILE_SOIL,
TimedStatusType.AFTER_COLONIZATION_OR_AWAY_TEAM,
DiceGenerator.getRandom(15, 35));
} else if (value < 55) {
} else if (value < 65) {
status = StatusFactory.getTimedStatus(StatusIds.METAL_RICH_SURFACE,
TimedStatusType.AFTER_COLONIZATION_OR_AWAY_TEAM,
DiceGenerator.getRandom(15, 30));
Expand All @@ -173,7 +193,17 @@ public static TimedStatus[] getRandomPlanetaryStatus(
case VOLCANICWORLD6:
gems = 12;
value = DiceGenerator.getRandom(99);
if (value < 30) {
if (value < 8) {
if (DiceGenerator.getBoolean()) {
status = StatusFactory.getTimedStatus(StatusIds.NANITE_SAND,
TimedStatusType.AFTER_COLONIZATION,
DiceGenerator.getRandom(11, 60));
} else {
status = StatusFactory.getTimedStatus(StatusIds.SPACE_TIME_WARP,
TimedStatusType.AFTER_COLONIZATION,
DiceGenerator.getRandom(11, 60));
}
} else if (value < 38) {
status = StatusFactory.getTimedStatus(StatusIds.FERTILE_SOIL,
TimedStatusType.AFTER_COLONIZATION_OR_AWAY_TEAM,
DiceGenerator.getRandom(15, 35));
Expand Down
32 changes: 27 additions & 5 deletions src/main/resources/resources/data/planet_statuses/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"MOLTEN_LAVA"
],
"mineBonus": 1,
"awayTeam": true
"hidden": false
},
{
"id": "FERTILE_SOIL",
Expand All @@ -20,7 +20,7 @@
"MOLTEN_LAVA"
],
"foodBonus": 1,
"awayTeam": true
"hidden": false
},
{
"id": "MOLTEN_LAVA",
Expand All @@ -34,22 +34,44 @@
"mineBonus": 1,
"prodBonus": 1,
"happinessBonus": -1,
"awayTeam": true
"hidden": false
},
{
"id": "TECTONIC_QUAKE",
"name": "Tectonic quake",
"description": "Tectonic plates move over the crust and cause quakes.",
"discoveryText": "<PLANETNAME> has tectonic quakes, this will cause damage to buildings and population.",
"awayTeam": false
"hidden": true
},
{
"id": "PRECIOUS_GEMS",
"name": "Precious gems",
"description": "Planet has precious gems on surface. These will grant extra credit per star year.",
"discoveryText": "<PLANETNAME> has surface full of precious gems. This can produce extra credit.",
"credBonus": 1,
"awayTeam": true
"hidden": false
},
{
"id": "NANITE_SAND",
"name": "Nanite sand",
"description": "Planet has nanite sand which is active. These will grant extra two research per star year.",
"discoveryText": "<PLANETNAME> has active nanites as a sand. This can produce extra two research.",
"reseBonus": 2,
"conflictsWith": [
"SPACE_TIME_WARP"
],
"hidden": true
},
{
"id": "SPACE_TIME_WARP",
"name": "Space time warp",
"description": "Planet has small area where space time acts strangly. These will grant extra research per star year.",
"discoveryText": "<PLANETNAME> has small area where space time acts strangle. This can produce extra research.",
"reseBonus": 1,
"conflictsWith": [
"NANITE_SAND"
],
"hidden": true
}

]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"id": "PIRATE_WORLD",
"name": "Pirate world",
"description": "Planet had small pirate base, but they have now taken control of the planet.",
"awayTeam": false
"hidden": true
}
]

0 comments on commit 9538e8b

Please sign in to comment.