|
| 1 | +/* |
| 2 | + * Copyright (C) 2025 The MegaMek Team. All Rights Reserved. |
| 3 | + * |
| 4 | + * This file is part of MekHQ. |
| 5 | + * |
| 6 | + * MekHQ is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License (GPL), |
| 8 | + * version 3 or (at your option) any later version, |
| 9 | + * as published by the Free Software Foundation. |
| 10 | + * |
| 11 | + * MekHQ is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty |
| 13 | + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 | + * See the GNU General Public License for more details. |
| 15 | + * |
| 16 | + * A copy of the GPL should have been included with this project; |
| 17 | + * if not, see <https://www.gnu.org/licenses/>. |
| 18 | + * |
| 19 | + * NOTICE: The MegaMek organization is a non-profit group of volunteers |
| 20 | + * creating free software for the BattleTech community. |
| 21 | + * |
| 22 | + * MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks |
| 23 | + * of The Topps Company, Inc. All Rights Reserved. |
| 24 | + * |
| 25 | + * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of |
| 26 | + * InMediaRes Productions, LLC. |
| 27 | + * |
| 28 | + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under |
| 29 | + * Microsoft's "Game Content Usage Rules" |
| 30 | + * <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or |
| 31 | + * affiliated with Microsoft. |
| 32 | + */ |
| 33 | +package mekhq.campaign.universe.factionStanding; |
| 34 | + |
| 35 | +import java.time.LocalDate; |
| 36 | +import java.time.Month; |
| 37 | +import java.util.Map; |
| 38 | + |
| 39 | +import megamek.common.enums.Gender; |
| 40 | +import mekhq.campaign.Campaign; |
| 41 | +import mekhq.campaign.personnel.Person; |
| 42 | +import mekhq.campaign.personnel.enums.PersonnelRole; |
| 43 | +import mekhq.gui.dialog.factionStanding.FactionStandingUltimatumDialog; |
| 44 | + |
| 45 | +/** |
| 46 | + * Handles the orchestration and presentation of faction standing ultimatum events. |
| 47 | + * |
| 48 | + * <p>This class manages the association between significant historical dates and their respective Faction Standing |
| 49 | + * ultimatum scenarios, triggering appropriate in-game dialogs and transitions when such events are detected for the |
| 50 | + * campaign's current faction. It ensures scenarios such as major faction splits or leadership transitions (e.g., the |
| 51 | + * Federated Commonwealth Civil War, ComStar Schism) are detected and surfaced to the player, accompanied by unique |
| 52 | + * dialog sequences involving prominent historical personalities.</p> |
| 53 | + * |
| 54 | + * <p>Key responsibilities include:</p> |
| 55 | + * <ul> |
| 56 | + * <li>Tracking historically significant faction ultimatum dates and their context.</li> |
| 57 | + * <li>Providing static checks for whether an ultimatum event is relevant to a given date and faction.</li> |
| 58 | + * <li>Validating campaign and faction alignment before presenting a scenario dialog to the player.</li> |
| 59 | + * <li>Constructing {@link Person} representations of event participants for use in dialogs.</li> |
| 60 | + * </ul> |
| 61 | + * |
| 62 | + * <p>See also: {@link FactionStandingUltimatumData} and {@link FactionStandingAgitatorData} for structure of scenario |
| 63 | + * and participant data.</p> |
| 64 | + * |
| 65 | + * @author Illiani |
| 66 | + * @since 0.50.07 |
| 67 | + */ |
| 68 | +public class FactionStandingUltimatum { |
| 69 | + /** |
| 70 | + * Represents the date marking the beginning of the Federated Commonwealth Civil War. |
| 71 | + * |
| 72 | + * <p>I opted to go with the month Katherine Steiner-Davion chose to secede from the alliance.</p> |
| 73 | + */ |
| 74 | + private static final LocalDate FED_COM_CIVIL_WAR = LocalDate.of(3057, Month.SEPTEMBER, 18); |
| 75 | + private static final FactionStandingAgitatorData KATRINA_STEINER = |
| 76 | + new FactionStandingAgitatorData("Archon Katrina Steiner", PersonnelRole.NOBLE, "LA"); |
| 77 | + private static final FactionStandingAgitatorData VICTOR_STEINER_DAVION = |
| 78 | + new FactionStandingAgitatorData("Archon-Prince Victor Steiner-Davion", PersonnelRole.NOBLE, "FS"); |
| 79 | + /** |
| 80 | + * Represents the date commemorating the schism within ComStar. |
| 81 | + * |
| 82 | + * <p>Primus Myndo Waterly was killed June 6th 3025, a week later (June 13th) Sharilar Mori was elected as Primus. |
| 83 | + * This caused Precentor Demona Aziz to head to Atreus (FWL) and kick off the ComStar Schism. It's a 100-day journey |
| 84 | + * from Terra to Atreus, which is how we got this date.</p> |
| 85 | + * |
| 86 | + * <p>There is an argument to be made that Precentor Aziz probably could have traveled via command circuit or |
| 87 | + * similar. I think that's very valid, however, I still went with the below date as it factors time needed to get a |
| 88 | + * meeting with Thomas Marik and then to arrange the HPG message that officially starts the schism.</p> |
| 89 | + */ |
| 90 | + private static final LocalDate COMSTAR_SCHISM = LocalDate.of(3052, Month.SEPTEMBER, 21); |
| 91 | + private static final FactionStandingAgitatorData DEMONA_AZIZ = |
| 92 | + new FactionStandingAgitatorData("Precentor Demona Aziz", PersonnelRole.RELIGIOUS_LEADER, "WOB"); |
| 93 | + private static final FactionStandingAgitatorData ANASTASIUS_FOCHT = |
| 94 | + new FactionStandingAgitatorData("Precentor Martial Anastasius Focht", PersonnelRole.NOBLE, "CS"); |
| 95 | + |
| 96 | + /** |
| 97 | + * A mapping of specific historical dates to their corresponding faction standing ultimatum events. |
| 98 | + * |
| 99 | + * <p>This map associates significant events in faction history with their respective data regarding the faction |
| 100 | + * affected, the challenger, the incumbent leader, and whether the transition is non-violent.</p> |
| 101 | + * |
| 102 | + * <p>Each entry in the map uses a {@link LocalDate} as the key, representing the date of the faction ultimatum, |
| 103 | + * and a {@link FactionStandingUltimatumData} object as the value, capturing the relevant contextual data for the |
| 104 | + * ultimatum event.</p> |
| 105 | + */ |
| 106 | + private final static Map<LocalDate, FactionStandingUltimatumData> FACTION_STANDING_ULTIMATUMS = Map.of( |
| 107 | + FED_COM_CIVIL_WAR, new FactionStandingUltimatumData("FC", KATRINA_STEINER, VICTOR_STEINER_DAVION, false), |
| 108 | + COMSTAR_SCHISM, new FactionStandingUltimatumData("CS", DEMONA_AZIZ, ANASTASIUS_FOCHT, true) |
| 109 | + ); |
| 110 | + |
| 111 | + private final Campaign campaign; |
| 112 | + |
| 113 | + /** |
| 114 | + * Checks whether a faction ultimatum is associated with the given date and matches the specified campaign faction |
| 115 | + * code. |
| 116 | + * |
| 117 | + * <p>This method provides a fast way to determine if a specific campaign faction has an ultimatum on a given date, |
| 118 | + * without requiring initialization of the full {@link FactionStandingUltimatum} class.</p> |
| 119 | + * |
| 120 | + * @param date the date to check for a faction ultimatum |
| 121 | + * @param campaignFactionCode the faction code to check for association with the ultimatum |
| 122 | + * |
| 123 | + * @return {@code true} if an ultimatum for the given date matches the specified faction code, {@code false} |
| 124 | + * otherwise |
| 125 | + */ |
| 126 | + public static boolean checkUltimatumForDate(final LocalDate date, final String campaignFactionCode) { |
| 127 | + FactionStandingUltimatumData ultimatum = FACTION_STANDING_ULTIMATUMS.get(date); |
| 128 | + return ultimatum != null && campaignFactionCode.equals(ultimatum.affectedFactionCode()); |
| 129 | + } |
| 130 | + |
| 131 | + public FactionStandingUltimatum(final LocalDate date, final Campaign campaign) { |
| 132 | + this.campaign = campaign; |
| 133 | + |
| 134 | + FactionStandingUltimatumData ultimatum = FACTION_STANDING_ULTIMATUMS.get(date); |
| 135 | + |
| 136 | + // We should have used 'checkUltimatumForDate' before initializing 'FactionStandingUltimatum', so we should |
| 137 | + // never return here. However, I opted to include this check as added security. |
| 138 | + if (ultimatum == null) { |
| 139 | + return; |
| 140 | + } |
| 141 | + |
| 142 | + // Or here... |
| 143 | + String affectedFactionCode = FACTION_STANDING_ULTIMATUMS.get(date).affectedFactionCode(); |
| 144 | + String campaignFactionCode = campaign.getFaction().getShortName(); |
| 145 | + if (!campaignFactionCode.equals(affectedFactionCode)) { |
| 146 | + return; |
| 147 | + } |
| 148 | + |
| 149 | + // Security checks out of the way, process the ultimatum |
| 150 | + Person challenger = createAgitator(ultimatum.challenger()); |
| 151 | + Person incumbent = createAgitator(ultimatum.incumbent()); |
| 152 | + new FactionStandingUltimatumDialog(campaign, challenger, incumbent, ultimatum.isViolentTransition()); |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Creates a {@link Person} entity within the campaign from the provided agitator data. |
| 157 | + * |
| 158 | + * <p>The agitator will receive the specified name, role, and faction code; surname and bloodname fields are set |
| 159 | + * to empty strings. As this information is pushed into the givenName, instead.</p> |
| 160 | + * |
| 161 | + * @param agitator the data record containing the agitator's name, role, and faction code |
| 162 | + * |
| 163 | + * @return a new {@link Person} instance initialized with the specified attributes |
| 164 | + * |
| 165 | + * @author Illiani |
| 166 | + * @since 0.50.07 |
| 167 | + */ |
| 168 | + private Person createAgitator(FactionStandingAgitatorData agitator) { |
| 169 | + String name = agitator.name(); |
| 170 | + PersonnelRole role = agitator.role(); |
| 171 | + String factionCode = agitator.factionCode(); |
| 172 | + |
| 173 | + Person person = campaign.newPerson(role, factionCode, Gender.MALE); // Gender is irrelevant here |
| 174 | + |
| 175 | + person.setGivenName(name); |
| 176 | + person.setSurname(""); |
| 177 | + person.setBloodname(""); |
| 178 | + |
| 179 | + return person; |
| 180 | + } |
| 181 | +} |
0 commit comments