-
Notifications
You must be signed in to change notification settings - Fork 176
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
Fixed maps - MekHQ #2769
Conversation
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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; | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 Report
@@ 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
Continue to review full report at Codecov.
|
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.