Skip to content

Commit

Permalink
Enhanced Random-Death Reporting
Browse files Browse the repository at this point in the history
Added color-coded messaging to ensure random death events are highly noticeable to users. Imported necessary utilities and refined new day processing to utilize the enhanced reporting mechanism.
  • Loading branch information
IllianiCBT committed Sep 25, 2024
1 parent 8619d8e commit 372625b
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
*/
package mekhq.campaign.personnel.death;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.Version;
import megamek.common.annotations.Nullable;
import megamek.common.enums.Gender;
Expand All @@ -45,6 +33,20 @@
import mekhq.campaign.personnel.enums.RandomDeathMethod;
import mekhq.campaign.personnel.enums.TenYearAgeRange;
import mekhq.utilities.MHQXMLUtility;
import mekhq.utilities.ReportingUtilities;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG;

public abstract class AbstractDeath {
private static final MMLogger logger = MMLogger.create(AbstractDeath.class);
Expand Down Expand Up @@ -158,6 +160,13 @@ public boolean processNewDay(final Campaign campaign, final LocalDate today,
}

if (randomlyDies(age, person.getGender())) {
// We double-report here, to make sure the user definitely notices that a random death has occurred.
// Prior to this change, it was exceptionally easy to miss these events.
String color = MekHQ.getMHQOptions().getFontColorNegativeHexColor();
String formatOpener = ReportingUtilities.spanOpeningWithCustomColor(color);
campaign.addReport(String.format("%s has %s<b>died</b>%s.",
person.getHyperlinkedFullTitle(), formatOpener, CLOSING_SPAN_TAG));

person.changeStatus(campaign, today, getCause(person, ageGroup, age));
return person.getStatus().isDead();
} else {
Expand Down

0 comments on commit 372625b

Please sign in to comment.