Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

274: Moving Era Definitions to Data #2805

Merged
merged 6 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions MekHQ/data/universe/eras.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Each Era consists of the following fields:
Code: The unique String code for the era.
Name: The display name for the era.
End: The end date for the era. This can be in the formats "yyyy-MM-dd", "yyyy-MM" (assuming first day of the month), and "yyyy" (assuming first day of the year). One era should have this value missing, which will put it as the final era.
Flag: The internal flags for the base eras. You can have multiple flag fields (multiple lines each with a single flag) per custom era, which isn't used in base MekHQ, but allows one to customize things.

Note that internal use of this setup is minimal at best, at least as of 0.49.3.
-->
<eras>
<era>
<code>PSF</code>
<name>Pre-Spaceflight</name>
<end>1950</end>
<flag>PRE_SPACEFLIGHT</flag>
</era>
<era>
<code>ESF</code>
<name>Early Spaceflight</name>
<end>2005</end>
<flag>EARLY_SPACEFLIGHT</flag>
</era>
<era>
<code>AOW</code>
<name>Age of War</name>
<end>2570</end>
<flag>AGE_OF_WAR</flag>
</era>
<era>
<code>SL</code>
<name>Star League</name>
<end>2780</end>
<flag>STAR_LEAGUE</flag>
</era>
<era>
<code>ESW</code>
<name>Early Succession Wars</name>
<end>2900</end>
<flag>EARLY_SUCCESSION_WARS</flag>
</era>
<era>
<code>LSWL</code>
<name>Late Succession War - LosTech</name>
<end>3019</end>
<flag>LATE_SUCCESSION_WARS_LOSTECH</flag>
</era>
<era>
<code>LSWR</code>
<name>Late Succession War - Renaissance</name>
<end>3049</end>
<flag>LATE_SUCCESSION_WARS_RENAISSANCE</flag>
</era>
<era>
<code>CI</code>
<name>Clan Invasion</name>
<end>3061</end>
<flag>CLAN_INVASION</flag>
</era>
<era>
<code>CW</code>
<name>Civil War</name>
<end>3067</end>
<flag>CIVIL_WAR</flag>
</era>
<era>
<code>J</code>
<name>Jihad</name>
<end>3085</end>
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
<flag>JIHAD</flag>
</era>
<era>
<code>ER</code>
<name>Early Republic</name>
<end>3100</end>
<flag>EARLY_REPUBLIC</flag>
</era>
<era>
<code>LR</code>
<name>Late Republic</name>
<end>3130</end>
<flag>LATE_REPUBLIC</flag>
</era>
<era>
<code>DA</code>
<name>Dark Ages</name>
<end>3150</end>
<flag>DARK_AGES</flag>
</era>
<era>
<code>ILC</code>
<name>ilClan</name>
<flag>ILCLAN</flag>
</era>
</eras>
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/MekHqConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public final class MekHqConstants {
public static final String LAYERED_FORCE_ICON_FRAME_PATH = "Pieces/Frames/";
public static final String LAYERED_FORCE_ICON_LOGO_PATH = "Pieces/Logos/";
public static final String AWARDS_DIRECTORY_PATH = "data/universe/awards/";
public static final String RATINFO_DIR = "data/universe/ratdata";
public static final String RATINFO_DIR = "data/universe/ratdata/";
public static final String ERAS_FILE_PATH = "data/universe/eras.xml";
public static final String FACTION_HINTS_FILE = "data/universe/factionhints.xml";
public static final String RANKS_FILE_PATH = "data/universe/ranks.xml";
public static final String USER_RANKS_FILE_PATH = "userdata/data/universe/ranks.xml";
Expand Down
19 changes: 8 additions & 11 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import mekhq.campaign.personnel.ranks.RankSystem;
import mekhq.campaign.personnel.ranks.RankValidator;
import mekhq.campaign.personnel.ranks.Ranks;
import mekhq.campaign.universe.eras.Eras;
import mekhq.service.AutosaveService;
import mekhq.service.IAutosaveService;

Expand Down Expand Up @@ -148,7 +149,7 @@
import mekhq.campaign.universe.AbstractPlanetSelector;
import mekhq.campaign.universe.DefaultFactionSelector;
import mekhq.campaign.universe.DefaultPlanetSelector;
import mekhq.campaign.universe.Era;
import mekhq.campaign.universe.eras.Era;
import mekhq.campaign.universe.Faction;
import mekhq.campaign.universe.Factions;
import mekhq.campaign.universe.IUnitGenerator;
Expand Down Expand Up @@ -381,18 +382,14 @@ public void setName(String s) {
this.name = s;
}

public String getEraName() {
return Era.getEraNameFromYear(getGameYear());
}

public int getEra() {
return Era.getEra(getGameYear());
public Era getEra() {
return Eras.getInstance().getEra(getLocalDate());
}

public String getTitle() {
return getName() + " (" + getFactionName() + ")" + " - "
+ MekHQ.getMekHQOptions().getLongDisplayFormattedDate(getLocalDate())
+ " (" + getEraName() + ")";
+ " (" + getEra() + ")";
}

public LocalDate getLocalDate() {
Expand Down Expand Up @@ -3691,16 +3688,16 @@ public void removeForce(Force force) {
if (null != force.getParentForce()) {
force.getParentForce().removeSubForce(fid);
}

// clear out StratCon force assignments
for (AtBContract contract : getActiveAtBContracts()) {
if (contract.getStratconCampaignState() != null) {
for (StratconTrackState track : contract.getStratconCampaignState().getTracks()) {
track.unassignForce(fid);
}
}
}
}

ArrayList<Force> subs = new ArrayList<>(force.getSubForces());
for (Force sub : subs) {
removeForce(sub);
Expand Down
Loading