Skip to content

Commit

Permalink
#700 Fixes tectonic quake status.
Browse files Browse the repository at this point in the history
Now same status is added only once.
Tectonic quake cannot kill zero gravity beings.
Fixed city in fire picture.
  • Loading branch information
tuomount committed May 11, 2024
1 parent a3edcd8 commit 3f5ca42
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ private static BufferedImage paintImage(final BufferedImage workImage,
if (VIRUSES.equals(image)) {
drawImg = IOUtilities.loadImage(GuiStatics.IMAGE_VIRUSES);
}
if (VIRUSES.equals(image)) {
if (CITY_IN_FIRE.equals(image)) {
drawImg = IOUtilities.loadImage(GuiStatics.IMAGE_FIRE_IN_CITY);
}
if (SIGNAL.equals(image)) {
Expand Down
50 changes: 45 additions & 5 deletions src/main/java/org/openRealmOfStars/starMap/planet/Planet.java
Original file line number Diff line number Diff line change
Expand Up @@ -3848,6 +3848,32 @@ public boolean addStatus(final AppliedStatus status) {
return statuses.add(status);
}

/**
* Tries to add applied status on planet. It checks possible conflict and
* that status is unique. How ever even if status is unique it does not
* mean that apply could not happen. There can be multiple tectonic events
* but only one status is needed for them.
* @param status Applied status to apply
* @return True applied status was added to applied statuses list.
*/
public boolean addAppliedStatus(final AppliedStatus status) {
var statusesArray = new PlanetaryStatus[statuses.size()];
for (int i = 0; i < statusesArray.length; i++) {
statusesArray[i] = statuses.get(i).getStatus();
}
var conflicting = PlanetaryStatus.isConflictingWith(status.getStatus(),
statusesArray);

if (conflicting) {
return false;
}
for (AppliedStatus comp : statuses) {
if (comp.getStatusId().equals(status.getStatusId())) {
return false;
}
}
return statuses.add(status);
}
/**
* Return true if Planet has status with given ID
* @param statusId ID of status
Expand Down Expand Up @@ -4633,7 +4659,7 @@ EventType.PLANET_COLONIZED, getCoordinate(), getName(),
}
continue;
}
if (statuses.add(applied) && planetOwnerInfo != null) {
if (addAppliedStatus(applied) && planetOwnerInfo != null) {
// Need to improve text for new status
String text = status.getStatus().getDiscoveryText();
text = text.replaceAll("<PLANETNAME>", getName());
Expand Down Expand Up @@ -4686,12 +4712,24 @@ EventType.PLANET_COLONIZED, getCoordinate(), getName(),
sb.append(building.getName());
and = true;
}
boolean onGround = true;
if (planetOwnerInfo.getRace().hasTrait(TraitIds.ZERO_GRAVITY_BEING)) {
onGround = false;
}
if (getTotalPopulation() > 1 && chance < getTotalPopulation()) {
killOneWorker();
if (and) {
sb.append(" and");
if (onGround) {
killOneWorker();
if (and) {
sb.append(" and");
}
sb.append(" kills one population");
} else {
if (and) {
sb.append(" and");
}
sb.append(" does not affect on population since they are"
+ " safe in orbital");
}
sb.append(" kills one population");
}
sb.append(".");
ImageInstruction imageInst = new ImageInstruction();
Expand All @@ -4704,6 +4742,7 @@ EventType.PLANET_COLONIZED, getCoordinate(), getName(),
msg.setMatchByString(getName());
msg.setCoordinate(getCoordinate());
planetOwnerInfo.getMsgList().addNewMessage(msg);
removeList.add(status);
}
if (status.getStatus().getId().equals(StatusIds.VOLCANIC_ERUPTION)) {
StringBuilder sb = new StringBuilder();
Expand All @@ -4722,6 +4761,7 @@ EventType.PLANET_COLONIZED, getCoordinate(), getName(),
msg.setMatchByString(getName());
msg.setCoordinate(getCoordinate());
planetOwnerInfo.getMsgList().addNewMessage(msg);
removeList.add(status);
}
}
}
Expand Down

0 comments on commit 3f5ca42

Please sign in to comment.