Skip to content

Commit

Permalink
#676 Adds climate cooldown status.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomount committed May 13, 2024
1 parent 45c987b commit 3142455
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
46 changes: 46 additions & 0 deletions src/main/java/org/openRealmOfStars/starMap/planet/Planet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,22 @@ public void setTemperatureType(final TemperatureType temperatureType) {
this.temperatureType = temperatureType;
}

/**
* Decrease temperature type.
*/
public void decreaseTemperatureType() {
switch (this.temperatureType) {
case INFERNO: setTemperatureType(TemperatureType.VOLCANIC); break;
case VOLCANIC: setTemperatureType(TemperatureType.HOT); break;
case HOT: setTemperatureType(TemperatureType.TROPICAL); break;
case TROPICAL: setTemperatureType(TemperatureType.TEMPERATE); break;
default:
case TEMPERATE: setTemperatureType(TemperatureType.COLD); break;
case COLD: setTemperatureType(TemperatureType.ARCTIC); break;
case ARCTIC: setTemperatureType(TemperatureType.FROZEN); break;
case FROZEN: setTemperatureType(TemperatureType.FROZEN); break;
}
}
/**
* Get planet's water level
* @return the waterLevel
Expand Down Expand Up @@ -4752,6 +4768,9 @@ EventType.PLANET_COLONIZED, getCoordinate(), getName(),
sb.append("Temprature raises into intolerable levels.");
if (planetOwnerInfo.getRace().hasTrait(TraitIds.ZERO_GRAVITY_BEING)) {
sb.append(" Population is safe at the orbital.");
} else if (planetOwnerInfo.getRace()
.hasTrait(TraitIds.TOLERATE_LAVA)) {
sb.append(" Population can still survive in volcanic planet.");
} else {
sb.append(" Population starts dying...");
}
Expand All @@ -4773,6 +4792,33 @@ EventType.PLANET_COLONIZED, getCoordinate(), getName(),
planetOwnerInfo.getMsgList().addNewMessage(msg);
removeList.add(status);
}
if (status.getStatus().getId().equals(StatusIds.CLIMATE_COOLDOWN)) {
StringBuilder sb = new StringBuilder();
decreaseTemperatureType();
generateWorldType();
sb.append("Climate on ");
sb.append(getName());
sb.append(" cool downs and is now ");
sb.append(temperatureType.toString());
sb.append(".");
if (isColonizeablePlanet(planetOwnerInfo)) {
sb.append(" Population starts freezing...");
}
ImageInstruction imageInst = new ImageInstruction();
imageInst.addBackground(ImageInstruction.BACKGROUND_STARS);
imageInst.addPlanet(ImageInstruction.POSITION_CENTER,
getPlanetType().getImageInstructions(),
ImageInstruction.SIZE_FULL);
map.setTile(getX(), getY(), getPlanetType().getTileIndex());
Message msg = new Message(MessageType.PLANETARY,
sb.toString(),
Icons.getIconByName(Icons.ICON_DEATH));
msg.setMatchByString(getName());
msg.setCoordinate(getCoordinate());
msg.setImageInstructions(imageInst.build());
planetOwnerInfo.getMsgList().addNewMessage(msg);
removeList.add(status);
}
}
}
if (removeList.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public final class StatusIds {
/** Planet has massive vulcanic eruption. */
public static final String VOLCANIC_ERUPTION = "VOLCANIC_ERUPTION";

/** Planet has climate cool down. */
public static final String CLIMATE_COOLDOWN = "CLIMATE_COOLDOWN";

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

Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/resources/data/planet_statuses/timed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
},
{
"id": "VOLCANIC_ERUPTION",
"name": "VOlcanic eruption",
"name": "Volcanic eruption",
"description": "Massive volcanic eruption happens on planet, and rapidly changing planet to volcanic.",
"hidden": true
}

},
{
"id": "CLIMATE_COOLDOWN",
"name": "Climate cooldown",
"description": "Climate suddenly cool downs, this could be catastorphic for life on planet.",
"hidden": true
}
]
2 changes: 1 addition & 1 deletion src/main/resources/resources/data/scenarios/doomed.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
],
"StartingCredit": 0,
"Description": "Planet is going to turn volcanic world in 80-120 star years."
}
}
]

0 comments on commit 3142455

Please sign in to comment.