From 837b344159361935726f87eaa57acfa65b975414 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 25 Sep 2024 10:22:54 -0500 Subject: [PATCH 1/3] Enhanced Random-Death Reporting 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. --- .../personnel/death/AbstractDeath.java | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java index 53988dce0b..1a5500bcac 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java @@ -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; @@ -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); @@ -116,7 +118,7 @@ public Map>> get /** * This is used to determine if a person can die. - * + * * @param person the person to determine for * @param ageGroup the age group of the person in question * @param randomDeath if this is for random death or manual death @@ -144,7 +146,7 @@ public Map>> get // region New Day /** * Processes new day random death for an individual. - * + * * @param campaign the campaign to process * @param today the current day * @param person the person to process @@ -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 %sdied%s.", + person.getHyperlinkedFullTitle(), formatOpener, CLOSING_SPAN_TAG)); + person.changeStatus(campaign, today, getCause(person, ageGroup, age)); return person.getStatus().isDead(); } else { From 8619d8ef09e1c8c7899ba6ab7ffaa9326c10c096 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 25 Sep 2024 10:25:09 -0500 Subject: [PATCH 2/3] Roll-back Accidental Push to Master --- .../personnel/death/AbstractDeath.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java index 1a5500bcac..29ee8487de 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java @@ -18,6 +18,18 @@ */ 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; @@ -33,20 +45,6 @@ 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); @@ -160,13 +158,6 @@ 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 %sdied%s.", - person.getHyperlinkedFullTitle(), formatOpener, CLOSING_SPAN_TAG)); - person.changeStatus(campaign, today, getCause(person, ageGroup, age)); return person.getStatus().isDead(); } else { From b8ec1c0bc73f9be7673eeeaaae8d10658d9c2ab9 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 25 Sep 2024 10:57:20 -0500 Subject: [PATCH 3/3] Added Mission Check for 'prisonerofwar' Award Eligibility Moved the 'prisoner of war' type of Misc Award to be issued only at the end of a Mission. --- .../personnel/autoAwards/MiscAwards.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java b/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java index 0fdc54f05c..6dcac12bec 100644 --- a/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java +++ b/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java @@ -19,13 +19,6 @@ package mekhq.campaign.personnel.autoAwards; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; -import java.util.UUID; - import megamek.common.annotations.Nullable; import mekhq.MekHQ; import mekhq.campaign.Campaign; @@ -38,14 +31,16 @@ import mekhq.campaign.universe.PlanetarySystem; import mekhq.campaign.universe.RandomFactionGenerator; +import java.time.LocalDate; +import java.util.*; + public class MiscAwards { /** * This function processes miscellaneous awards for a given person in a * campaign. * It checks the eligibility of the person for each type of award and returns a - * map - * of eligible awards grouped by their respective IDs. + * map of eligible awards grouped by their respective IDs. * * @param campaign the current campaign * @param mission the mission just completed (null if no mission @@ -64,9 +59,8 @@ public class MiscAwards { * @return a map of eligible awards grouped by their respective IDs */ public static Map> MiscAwardsProcessor(Campaign campaign, @Nullable Mission mission, - UUID person, List awards, - Boolean missionWasSuccessful, boolean isCivilianHelp, @Nullable Integer killCount, - @Nullable Integer injuryCount, @Nullable UUID supportPersonOfTheYear) { + UUID person, List awards, Boolean missionWasSuccessful, boolean isCivilianHelp, + @Nullable Integer killCount, @Nullable Integer injuryCount, @Nullable UUID supportPersonOfTheYear) { List eligibleAwards = new ArrayList<>(); for (Award award : awards) { @@ -102,7 +96,7 @@ public static Map> MiscAwardsProcessor(Campaign campaign, } } case "prisonerofwar" -> { - if (prisonerOfWar(campaign, award, person)) { + if (mission != null && prisonerOfWar(campaign, award, person)) { eligibleAwards.add(award); } }