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

Implemented Random Mercenary Company Name Generator #4640

Merged
merged 15 commits into from
Aug 16, 2024

Conversation

IllianiCBT
Copy link
Collaborator

@IllianiCBT IllianiCBT commented Aug 15, 2024

This PR does a couple of things: predominately it implements a random name generator to generate a mercenary company name.

When a player starts a new campaign a random name will be generated in place of the previous 'My Campaign'. Additional company names can be generated via button in Campaign Options. New company names can be generated in active campaigns via the GM Tools dialog. This tech was needed for the upcoming Random Backgrounds Module, as we need to known the origin company name for characters with the 'Mercenary' origin.

Finally, whenever players have a contract against the Mercenary faction mhq will generate a random name for that enemy, instead of using faction name. This tech was needed for a future project currently in pre-development.

There are 6 types of random name: Corporate, Mercenary (Vanity type 1 and 2), Mercenary (Generic), and Pre-Fab (type 1 and 2). If a vanity name is generated mhq will use the name of the current campaign commander, if set, otherwise a random Callsign will be generated.

Examples of the kinds of names generated follows:

  • Juggernaut's Centurions
  • The Storm Outlaws
  • Envision Associates
  • Boomtube's Legends
  • Raptor Investments
  • Barnacle's Wolfpack Gunslingers
  • Drillbit's Raven Tactical
  • The Starfire Tempests
  • Koschei's Midnight Marauders
  • The Spectral Legionnaires
  • Wallaby's Punchline Platoon
  • The Stackpole Survivors

Introduced new enumeration classes for Mercenary company name generation, including `MiddleWordMercenary`, `EndWordCorporate`, and `EndWordMercenary`. Implemented functionality to randomly select names from these enums and added corresponding resource bundles for text values.
Implemented a button in the Campaign Options Pane to generate random company names using the BackgroundsController. The button updates the company name field with a newly generated name, enhancing usability for end-users.
Updated the panInfo's border title to reflect the current campaign's name if the border is an instance of TitledBorder. This enhances the GUI by dynamically displaying the relevant campaign name, improving user experience.
Introduced support for definite articles in random mercenary company names. Updated BackgroundsController to use resources for definite articles and consolidated string construction for name generation.
Enhanced the GUI with a new panel for generating and assigning random mercenary company names. Updated relevant methods and properties to support this functionality.
Added a variety of humorous names to the RandomMercenaryCompanyNameGenerator.properties file. This enhances the variety and entertainment value when generating random mercenary company names.
Added a try-catch block to handle NullPointerException, allowing the method to be tested without needing to mock RandomCallsignGenerator. Returning an empty string if an exception occurs ensures stability during tests.
Introduced the enemyName field to AtBContract to track enemy names. Updated XML read/write methods to include enemyName. Enhanced getEnemyName to ensure enemyName is set and provided a marshallEnemyName method for direct retrieval.
@IllianiCBT IllianiCBT added the Campaign Options Relates to, or includes, campaign option changes label Aug 15, 2024
@IllianiCBT IllianiCBT self-assigned this Aug 15, 2024
MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java Fixed Show resolved Hide resolved
MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java Dismissed Show dismissed Hide dismissed
@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.65%. Comparing base (f2c4b80) to head (50ad0c2).
Report is 48 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4640      +/-   ##
============================================
+ Coverage      9.89%   10.65%   +0.76%     
- Complexity     5678     5702      +24     
============================================
  Files           945      950       +5     
  Lines        129805   131271    +1466     
  Branches      19119    19134      +15     
============================================
+ Hits          12845    13988    +1143     
- Misses       115745   116059     +314     
- Partials       1215     1224       +9     

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

Removed the unnecessary parameter from the createGenerateNameButton method. This simplifies the method signature and aligns its usage with other similar button creation methods in the code.
Added code to clear the old enemy name before updating it with the current year's enemy faction name in AtBContract. This ensures that the enemy name is always refreshed correctly during each contract update.
Copy link
Member

@HammerGS HammerGS left a comment

Choose a reason for hiding this comment

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

Tested and seems to work. Added some of the missing names we see for merc units.

Also can this generated a numbered unit, i.e 21st Stormbringer Legion

Expanded the Mercenary Company Name Generator with additional end words. This enhancement provides more variety and flavor for generated mercenary company names.
Integrated numerical name generation with appropriate suffixes for mercenary company names. Refactored the naming logic to include different prefixes and updated the resource bundle with new suffix entries.
@IllianiCBT
Copy link
Collaborator Author

Tested and seems to work. Added some of the missing names we see for merc units.

Also can this generated a numbered unit, i.e 21st Stormbringer Legion

It does now! :D

@IllianiCBT IllianiCBT requested a review from HammerGS August 16, 2024 01:12
@IllianiCBT
Copy link
Collaborator Author

Added numerical name prefixes, allowing us to generate names like "The 22nd Beef Brigade"

IllianiCBT and others added 2 commits August 15, 2024 20:13
Replaced `marshallEnemyName` with a more robust `generateEnemyName` method to ensure the enemy name is set properly. Added proper handling for missing data and fallback mechanisms to avoid null values.
@IllianiCBT IllianiCBT merged commit 575d9d7 into MegaMek:master Aug 16, 2024
3 checks passed
Copy link
Member

@HammerGS HammerGS left a comment

Choose a reason for hiding this comment

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

Tested and seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Campaign Options Relates to, or includes, campaign option changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants