Skip to content

Commit

Permalink
Merge pull request #4879 from IllianiCBT/randomDeath_report
Browse files Browse the repository at this point in the history
Enhanced Random-Death Reporting
  • Loading branch information
HammerGS authored Sep 25, 2024
2 parents dee0a8b + 09572b1 commit 89bdf0d
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2020-2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
Expand All @@ -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 89bdf0d

Please sign in to comment.