Skip to content

Commit

Permalink
save boardType to xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Apr 22, 2024
1 parent d90511f commit 25ef17e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/AtBGameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public void run() {
mapSettings.getBoardsSelectedVector().clear();

// if the scenario is taking place in space, do space settings instead
if (scenario.getBoardType() == Scenario.T_SPACE) {
if (scenario.getBoardType() == Scenario.T_SPACE
|| scenario.getTerrainType().equals("Space")) {
mapSettings.setMedium(MapSettings.MEDIUM_SPACE);
mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED);
} else if (scenario.isUsingFixedMap()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,11 @@ public static void setScenarioMapSize(AtBDynamicScenario scenario) {
* the given threshold, replace the scenario's generated map with a fixed map from data/boards
*/
private static void setScenarioMap(AtBDynamicScenario scenario, int mapChance) {
if ((scenario.getMapSizeX() > 0) && (scenario.getMapSizeY() > 0) && (Compute.randomInt(100) <= mapChance)) {
if (scenario.getBoardType() != Scenario.T_SPACE
&& scenario.getTerrainType().equals("Space")
&& (scenario.getMapSizeX() > 0)
&& (scenario.getMapSizeY() > 0)
&& (Compute.randomInt(100) <= mapChance)) {
BoardClassifier bc = BoardClassifier.getInstance();
List<String> maps = bc.getMatchingBoards(scenario.getMapSizeX(), scenario.getMapSizeY(), 5, 5, new ArrayList<>());

Expand Down
16 changes: 10 additions & 6 deletions MekHQ/src/mekhq/campaign/mission/AtBScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,17 @@ public int getBaseMapY() {
}

public void setMapFile(String terrainType) {
Map<String, StratconBiomeManifest.MapTypeList> mapTypes = SB.getBiomeMapTypes();
StratconBiomeManifest.MapTypeList value = mapTypes.get(terrainType);
if (value != null) {
List<String> mapTypeList = value.mapTypes;
setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size())));
if (terrainType.equals("Space")) {
setMap("Space");
} else {
setMap("Savannah");
Map<String, StratconBiomeManifest.MapTypeList> mapTypes = SB.getBiomeMapTypes();
StratconBiomeManifest.MapTypeList value = mapTypes.get(terrainType);
if (value != null) {
List<String> mapTypeList = value.mapTypes;
setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size())));
} else {
setMap("Savannah");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions MekHQ/src/mekhq/campaign/mission/Scenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ protected int writeToXMLBegin(final PrintWriter pw, int indent) {

MHQXMLUtility.writeSimpleXMLTag(pw, indent, "date", date);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "cloaked", isCloaked());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "boardType", boardType);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "terrainType", terrainType);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "hasTrack", hasTrack);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "usingFixedMap", isUsingFixedMap());
Expand Down

0 comments on commit 25ef17e

Please sign in to comment.