8000 Improvement: Moved Faction Standing Ultimatum Data into YAML Format by IllianiBird · Pull Request #7302 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improvement: Moved Faction Standing Ultimatum Data into YAML Format #7302

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

Merged
merged 3 commits into from
Jul 7, 2025

Conversation

IllianiBird
Copy link
Collaborator

This was based on a suggestion from @Sleet01 requesting that we move the ultimatum data from hardcoded values and into the data folder.

@IllianiBird IllianiBird self-assigned this Jul 6, 2025
@IllianiBird IllianiBird added the Data Hammertime label Jul 6, 2025
@IllianiBird IllianiBird requested a review from a team as a code owner July 6, 2025 19:03
@IllianiBird IllianiBird added the Improvement to Existing Feature Used with the RFE tag to indicate an improvement to an existing feature label Jul 6, 2025
Copy link
codecov bot commented Jul 6, 2025

Codecov Report

Attention: Patch coverage is 54.54545% with 20 lines in your changes missing coverage. Please review.

Project coverage is 12.70%. Comparing base (3d40586) to head (35fc28f).
Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
...tionStanding/FactionStandingUltimatumsLibrary.java 60.71% 11 Missing ⚠️
...erse/factionStanding/FactionStandingUltimatum.java 0.00% 6 Missing ⚠️
MekHQ/src/mekhq/campaign/Campaign.java 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7302      +/-   ##
============================================
+ Coverage     12.68%   12.70%   +0.01%     
- Complexity     7572     7585      +13     
============================================
  Files          1171     1173       +2     
  Lines        149175   149225      +50     
  Branches      22890    22894       +4     
============================================
+ Hits          18923    18959      +36     
- Misses       128223   128242      +19     
+ Partials       2029     2024       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* @author Illiani
* @since 0.50.07
*/
public Map<LocalDate, FactionStandingUltimatumData> getUltimatums() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will only support one ultimatum per given date; do you think we will ever want to have multiple events on the same date?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that occurred to me. I'm torn, because by using dates as keys we can very cheaply and reliably confirm whether an ultimatum is occurring in a given day for a given faction without using a loop.

If you don't mind taking a look at the ultimatum code in src/campaign/universe/faction standing I'd welcome your thoughts on alternative models.

The key thing is that I have a method that just checks whether an ultimatum is occurring before we call the class constructor. As that allows us to avoid passing in Campaign unnecessarily. It's all fully commented, so if you have the time to look I would appreciate your insight.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I've got a workable solution.

Copy link
Collaborator
@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

Looks great, nice work!
Just one question about future capabilities but it can be answered or updated later

@IllianiBird
Copy link
Collaborator Author

So, I employed my brain noodles and managed to fathom a workable solution without too much labor.

Previously, we structured the ultimatums library as Map<LocalDate, Ultimatum>, this had the obvious limitation of preventing multiple ultimatums occurring on the same date. While it's unlikely that would ever cause issues, you never know and a problem solved now is a problem that doesn't exist in the future.

I shifted the library to be structured as an embedded map: Map<LocalDate, Map<Affected Faction, Ultimatum>>. This means that to find out whether an ultimatum exists on any given day, we input the LocalDate - which fetches all the ultimatums for that day, and then just cross-reference the affected faction. This will return null if no ultimatum exists for that date and faction combo. Otherwise, it will return the relevant ultimatum.

The main benefit here - and the big thing I wanted to avoid, resulting in the original implementation - is that this is accomplished without needing to use a loop:

image image

# Conflicts:
#	MekHQ/src/mekhq/campaign/Campaign.java
@IllianiBird IllianiBird merged commit 3878fde into MegaMek:master Jul 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Hammertime Improvement to Existing Feature Used with the RFE tag to indicate an improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0