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

Fixed maps - MekHQ #2769

Merged
merged 4 commits into from
Jul 29, 2021
Merged

Fixed maps - MekHQ #2769

merged 4 commits into from
Jul 29, 2021

Conversation

NickAragua
Copy link
Member

Bottom line - sometimes, at a user-configurable rate, StratCon will use an appropriately sized (and possibly terrain-typed) map from the data/boards directory instead of a generated map.

MekHQ component of the fixed maps feature, requires companion MegaMek PR.

@@ -493,3 +493,5 @@ chkAeroRecruitsHaveUnits.text=Treat Aerospace pilots like MechWarriors
chkAeroRecruitsHaveUnits.toolTipText=Aerospace pilot recruits can have fighters, and those that do will take a fighter with them when retiring/defecting.
chkAssignPortraitOnRoleChange.text=Automatically assign portrait on role change
chkAssignPortraitOnRoleChange.toolTipText=With this enabled, a person without a portrait will automatically gain a random portrait when their primary role is switched to one of those selected below
lblFixedMapChance.text=Fixed Map Chance
lblFixedMapChance.toolTipText=The likelyhood, in percent, that a fixed user-made map will be used in place of a generated map.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lblFixedMapChance.toolTipText=The likelyhood, in percent, that a fixed user-made map will be used in place of a generated map.
lblFixedMapChance.toolTipText=The likelihood, in percent, that a fixed user-made map will be used in place of a generated map.

Comment on lines 873 to 888
if ((scenario.getMapSizeX() > 0) && (scenario.getMapSizeY() > 0)) {
BoardClassifier bc = BoardClassifier.getInstance();
List<String> maps = bc.getMatchingBoards(scenario.getMapSizeX(), scenario.getMapSizeY(), 5, 5, new ArrayList<>());

if (!maps.isEmpty() && (Compute.randomInt(100) <= mapChance)) {
String mapPath = Utilities.getRandomItem(maps);
MegaMekFile mapFile = new MegaMekFile(mapPath);
BoardDimensions dimensions = Board.getSize(mapFile.getFile());

scenario.setMap(bc.getBoardPaths().get(mapPath));
scenario.setMapSizeX(dimensions.width());
scenario.setMapSizeY(dimensions.height());
scenario.setUsingFixedMap(true);
return;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really check if we should attempt (the compute check) before determining if there are potential maps for performance reasons.

Copy link
Contributor

@Windchild292 Windchild292 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hit the wrong button, meant to do this earlier

@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #2769 (9034acc) into master (a91686f) will decrease coverage by 0.01%.
The diff coverage is 5.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2769      +/-   ##
============================================
- Coverage     10.61%   10.59%   -0.02%     
+ Complexity     3869     3860       -9     
============================================
  Files           719      719              
  Lines        100083   100137      +54     
  Branches      16400    16405       +5     
============================================
- Hits          10620    10609      -11     
- Misses        88086    88141      +55     
- Partials       1377     1387      +10     
Impacted Files Coverage Δ
MekHQ/src/mekhq/AtBGameThread.java 0.00% <0.00%> (ø)
...hq/campaign/mission/AtBDynamicScenarioFactory.java 1.60% <0.00%> (-0.03%) ⬇️
MekHQ/src/mekhq/campaign/mission/AtBScenario.java 0.00% <0.00%> (ø)
...HQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java 0.00% <0.00%> (ø)
MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java 0.00% <0.00%> (ø)
MekHQ/src/mekhq/campaign/CampaignOptions.java 26.53% <42.85%> (+0.05%) ⬆️
...ekhq/campaign/universe/RandomFactionGenerator.java 56.57% <0.00%> (-1.60%) ⬇️
...ekHQ/src/mekhq/campaign/market/ContractMarket.java 57.94% <0.00%> (-1.01%) ⬇️
MekHQ/src/mekhq/campaign/universe/Systems.java 41.43% <0.00%> (-0.80%) ⬇️
.../mekhq/campaign/mission/enums/AtBContractType.java 12.58% <0.00%> (-0.70%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a91686f...9034acc. Read the comment docs.

@NickAragua NickAragua merged commit b4ffc49 into MegaMek:master Jul 29, 2021
@NickAragua NickAragua deleted the fixed_maps branch July 29, 2021 20:47
@HammerGS HammerGS added the StratCon Bugs relating strictly to StratCon label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
StratCon Bugs relating strictly to StratCon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants