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

add additional board auto tags #6216

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from all 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
53 changes: 48 additions & 5 deletions megamek/src/megamek/utilities/BoardsTagger.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import java.util.*;
import java.util.stream.Collectors;

import megamek.common.Board;
import megamek.common.Building;
import megamek.common.Configuration;
import megamek.common.Hex;
import megamek.common.*;
import megamek.logging.MMLogger;

/**
Expand Down Expand Up @@ -86,7 +83,16 @@ public enum Tags {
TAG_WATER("Water"),
TAG_ICE("IceTerrain"),
TAG_FLAT("Flat"),
TAG_SNOWTERRAIN("SnowTerrain");
TAG_SNOWTERRAIN("SnowTerrain"),
TAG_HANGAR("Hangar"),
TAG_FORTRESS("Fortress"),
TAG_GUNEMPLACEMENT("GunEmplacement"),
TAG_HEAVYBUILDING("HeavyBuilding"),
TAG_HARDENEDBUILDING("HardenedBuilding"),
TAG_ARMOREDBUILDING("ArmoredBuilding"),
TAG_IMPASSABLE("Impassable"),
TAG_ELEVATOR("Elevator"),
TAG_MULTIPLETHEME("MultipleTheme");

private String tagName;
private static final Map<String, Tags> internalTagMap;
Expand Down Expand Up @@ -218,6 +224,15 @@ private static void tagBoard(File boardFile) {
int water = 0;
int ice = 0;
int snowTerrain = 0;
int hangar = 0;
int fortress = 0;
int gunEnplacement = 0;
int heavyBuilding = 0;
int hardenedBuilding = 0;
int armoredBuilding = 0;
int impassable = 0;
int elevator = 0;
int multipleTheme = 0;

for (int x = 0; x < board.getWidth(); x++) {
for (int y = 0; y < board.getHeight(); y++) {
Expand Down Expand Up @@ -266,6 +281,16 @@ private static void tagBoard(File boardFile) {
lowBuildings += (height <= 2) ? 1 : 0;
highBuildings += (height > 2) ? 1 : 0;
}
if (hex.containsTerrain(BUILDING)) {
hangar += hex.terrainLevel(BLDG_CLASS) == Building.HANGAR ? 1 : 0;
fortress += hex.terrainLevel(BLDG_CLASS) == Building.FORTRESS ? 1 : 0;
gunEnplacement += hex.terrainLevel(BLDG_CLASS) == Building.GUN_EMPLACEMENT ? 1 : 0;
heavyBuilding += hex.terrainLevel(BUILDING) == Building.HEAVY ? 1 : 0;
hardenedBuilding += hex.terrainLevel(BUILDING) == Building.HARDENED ? 1 : 0;
armoredBuilding += hex.containsTerrain(BLDG_ARMOR) && hex.terrainLevel(Terrains.BLDG_ARMOR) > 0 ? 1 : 0;
}
impassable += hex.containsTerrain(IMPASSABLE) ? 1 : 0;
elevator += hex.containsTerrain(ELEVATOR) ? 1 : 0;
}
}

Expand Down Expand Up @@ -316,6 +341,24 @@ private static void tagBoard(File boardFile) {
matchingTags.put(Tags.TAG_HEAVYURBAN, (stdBuildings >= normSide * 4) && (roads > normSide / 3));
matchingTags.put(Tags.TAG_SNOWTERRAIN, (snowTerrain > normSide * 2));
matchingTags.put(Tags.TAG_FLAT, (levelExtent <= 2) && (weighedLevels < normSide * 5));
matchingTags.put(Tags.TAG_HANGAR, hangar > 10);
matchingTags.put(Tags.TAG_FORTRESS, fortress > 10);
matchingTags.put(Tags.TAG_GUNEMPLACEMENT, gunEnplacement > 10);
matchingTags.put(Tags.TAG_HEAVYBUILDING, heavyBuilding > 10);
matchingTags.put(Tags.TAG_HARDENEDBUILDING, hardenedBuilding > 10);
matchingTags.put(Tags.TAG_ARMOREDBUILDING, armoredBuilding > 10);
matchingTags.put(Tags.TAG_IMPASSABLE, impassable > 0);
matchingTags.put(Tags.TAG_ELEVATOR, elevator > 0);

multipleTheme = 0;
multipleTheme += deserts > 0 ? 1 : 0;
multipleTheme += lunar > 0 ? 1 : 0;
multipleTheme += grass > 0 ? 1 : 0;
multipleTheme += tropical > 0 ? 1 : 0;
multipleTheme += mars > 0 ? 1 : 0;
multipleTheme += snowTheme > 0 ? 1 : 0;
multipleTheme += volcanic > 0 ? 1 : 0;
matchingTags.put(Tags.TAG_MULTIPLETHEME, multipleTheme > 1);

// Remove (see below) any auto tags that might be present so that auto tags that
// no longer apply
Expand Down