Skip to content

Commit

Permalink
Restored Logic for Facilities to Reveal StratCon Tracks
Browse files Browse the repository at this point in the history
Restored the `revealTrack` property in facilities and integrated it into the StratCon logic to determine visibility. Restored drawing and visibility checks accordingly to account for facilities that enable track-wide reveals.

This ensures we have two facility modifiers relating to hex reveal: Scan Range (which increases line of sight), and Reveal Track (which reveals the whole Sector). The latter is not currently used by any Facilities, but might be useful for player custom facilities.
  • Loading branch information
IllianiCBT committed Jan 5, 2025
1 parent 8dbf74b commit de31744
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
11 changes: 11 additions & 0 deletions MekHQ/src/mekhq/campaign/stratcon/StratconFacility.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public enum FacilityType {
private List<String> sharedModifiers = new ArrayList<>();
private List<String> localModifiers = new ArrayList<>();
private String capturedDefinition;
private boolean revealTrack;
private boolean increaseScanRange;
private int scenarioOddsModifier;
private int monthlySPModifier;
Expand Down Expand Up @@ -93,6 +94,7 @@ public StratconFacility clone() {
clone.sharedModifiers = new ArrayList<>(sharedModifiers);
clone.localModifiers = new ArrayList<>(localModifiers);
clone.setCapturedDefinition(capturedDefinition);
clone.revealTrack = revealTrack;
clone.increaseScanRange = increaseScanRange;
clone.scenarioOddsModifier = scenarioOddsModifier;
clone.monthlySPModifier = monthlySPModifier;
Expand All @@ -112,6 +114,7 @@ public void copyRulesDataFrom(StratconFacility facility) {
setLocalModifiers(new ArrayList<>(facility.getLocalModifiers()));
setSharedModifiers(new ArrayList<>(facility.getSharedModifiers()));
setOwner(facility.getOwner());
setRevealTrack(facility.getRevealTrack());
setIncreaseScanRange(facility.getIncreaseScanRange());
setScenarioOddsModifier(facility.getScenarioOddsModifier());
setMonthlySPModifier(facility.getMonthlySPModifier());
Expand Down Expand Up @@ -237,6 +240,14 @@ public void setCapturedDefinition(String capturedDefinition) {
this.capturedDefinition = capturedDefinition;
}

public boolean getRevealTrack() {
return revealTrack;
}

public void setRevealTrack(boolean revealTrack) {
this.revealTrack = revealTrack;
}

public boolean getIncreaseScanRange() {
return increaseScanRange;
}
Expand Down
7 changes: 7 additions & 0 deletions MekHQ/src/mekhq/campaign/stratcon/StratconTrackState.java
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,13 @@ public void failObjective(StratconCoords coords) {
}
}

/**
* @return Whether or not this track has a facility on it that reveals the track.
*/
public boolean hasActiveTrackReveal() {
return getFacilities().values().stream().anyMatch(StratconFacility::getRevealTrack);
}

/**
* Determines the number of facilities on this track that actively reveal the track.
*
Expand Down
15 changes: 11 additions & 4 deletions MekHQ/src/mekhq/gui/StratconPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ private boolean drawHexes(Graphics2D g2D, DrawHexType drawHexType) {
Font newFont = pushFont.deriveFont(Font.BOLD, pushFont.getSize());
g2D.setFont(newFont);

boolean trackRevealed = currentTrack.hasActiveTrackReveal();

for (int x = 0; x < currentTrack.getWidth(); x++) {
for (int y = 0; y < currentTrack.getHeight(); y++) {
StratconCoords currentCoords = new StratconCoords(x, y);
Expand Down Expand Up @@ -406,7 +408,7 @@ private boolean drawHexes(Graphics2D g2D, DrawHexType drawHexType) {
}

// draw fog of war if applicable
if (!currentTrack.coordsRevealed(x, y)) {
if (!trackRevealed && !currentTrack.coordsRevealed(x, y)) {
BufferedImage fogOfWarLayerImage = getImage(StratconBiomeManifest.FOG_OF_WAR,
ImageType.TerrainTile);
if (fogOfWarLayerImage != null) {
Expand Down Expand Up @@ -553,6 +555,8 @@ private void drawScenarios(Graphics2D g2D) {

Polygon graphHex = generateGraphHex();

boolean trackRevealed = currentTrack.hasActiveTrackReveal();

for (int x = 0; x < currentTrack.getWidth(); x++) {
for (int y = 0; y < currentTrack.getHeight(); y++) {
StratconCoords currentCoords = new StratconCoords(x, y);
Expand All @@ -566,7 +570,7 @@ private void drawScenarios(Graphics2D g2D) {
(scenario.isStrategicObjective()
&& currentTrack.getRevealedCoords().contains(currentCoords))
||
currentTrack.isGmRevealed())) {
currentTrack.isGmRevealed() || trackRevealed)) {
g2D.setColor(MekHQ.getMHQOptions().getFontColorNegative());

BufferedImage scenarioImage = getImage(StratconBiomeManifest.FORCE_HOSTILE, ImageType.TerrainTile);
Expand Down Expand Up @@ -612,12 +616,14 @@ private void drawFacilities(Graphics2D g2D) {

Polygon graphHex = generateGraphHex();

boolean trackRevealed = currentTrack.hasActiveTrackReveal();

for (int x = 0; x < currentTrack.getWidth(); x++) {
for (int y = 0; y < currentTrack.getHeight(); y++) {
StratconCoords currentCoords = new StratconCoords(x, y);
StratconFacility facility = currentTrack.getFacility(currentCoords);

if ((facility != null) && (facility.isVisible() || currentTrack.isGmRevealed())) {
if ((facility != null) && (facility.isVisible() || trackRevealed || currentTrack.isGmRevealed())) {
g2D.setColor(facility.getOwner() == Allied ? Color.CYAN : Color.RED);

BufferedImage facilityImage = getFacilityImage(facility);
Expand Down Expand Up @@ -869,7 +875,8 @@ private String buildSelectedHexInfo(Campaign campaign) {
infoBuilder.append(currentTrack.getTerrainTile(boardState.getSelectedCoords()));
infoBuilder.append("<br/>");

boolean coordsRevealed = currentTrack.getRevealedCoords().contains(boardState.getSelectedCoords());
boolean coordsRevealed = currentTrack.hasActiveTrackReveal()
|| currentTrack.getRevealedCoords().contains(boardState.getSelectedCoords());
if (coordsRevealed) {
infoBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorPositiveHexColor())
.append("'><i>Recon Complete</i></span><br/>");
Expand Down

0 comments on commit de31744

Please sign in to comment.