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

feat: add new chat commands, updates a bit the commands gui, give nukes to GMs #6245

Merged
merged 1 commit into from
Dec 15, 2024

Conversation

Scoppio
Copy link
Collaborator

@Scoppio Scoppio commented Dec 5, 2024

Even more GM tools

Change player team

This GM command allow the GM to change players from teams manually, no need for doing it just one player per turn. It is still done at the end of the round, but the teams can be reassigned freely until them.

End game

This command from the GM just ends the game, no need for voting, it may also be forced to end immediatelly. It also declares one team as victorious, but things like MHQ will keep doing what it does to decide who won the game.

Nuclear Strike & Nuclear Strike Custom

Just more modern implementations of the old command "Nuke", these can only be called by the GM.

GameListener gamePlayerStrategicAction

Triggers an event that can be picked up by MHQ whenever a player uses a nuclear strike or something else.

GUI commands

Implements some intelligence/automation for GUI Commands (the chat commands shown in a GUI). If So now there are the PlayerArgument, UnitArgument, TeamArgument, so they list the players, teams and units. This allows for a more rich experience when using those tools instead of just random numbers appearing out of nowhere.

Draw nuke

Now nukes from Arty should be drawn on the game too.

}

private JComponent getArgumentComponent(Argument<?> argument) {
if (argument instanceof CoordXArgument intArg) {

Check notice

Code scanning / CodeQL

Chain of 'instanceof' tests Note

This if block performs a chain of 13 type tests - consider alternatives, e.g. polymorphism or the visitor pattern.
1));
}

private JSpinner createSpinner(CoordXArgument coordX) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'coordX' is never used.
1));
}

private JSpinner createSpinner(CoordYArgument coordY) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'coordY' is never used.
1));
}

private JComboBox<String> createPlayerComboBox(PlayerArgument playerArgument) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'playerArgument' is never used.
return comboBox;
}

private JComboBox<String> createUnitComboBox(UnitArgument unitArgument) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'unitArgument' is never used.
return comboBox;
}

private JComboBox<String> createTeamsComboBox(TeamArgument teamArgument) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'teamArgument' is never used.
@@ -73,4 +73,6 @@
* @param event
*/
default void gameUnitChange(GameEvent event) { }

default void gamePlayerStrategicAction(GamePlayerStrategicActionEvent e) { }

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'e' is never used.
@@ -364,8 +398,23 @@
return requestedTeam;
}

/**

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
TWGameManager.legacyProcessTeamChangeRequest
should be avoided because it has been deprecated.
@Scoppio Scoppio force-pushed the even-more-gm-tools branch from e2d0846 to b224fc2 Compare December 5, 2024 22:49
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.94%. Comparing base (def6259) to head (b224fc2).
Report is 18 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6245      +/-   ##
============================================
- Coverage     28.97%   28.94%   -0.04%     
- Complexity    13983    13984       +1     
============================================
  Files          2652     2669      +17     
  Lines        268509   268820     +311     
  Branches      47828    47815      -13     
============================================
+ Hits          77802    77805       +3     
- Misses       186824   187131     +307     
- Partials       3883     3884       +1     

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

@Scoppio Scoppio added the GM Tools All things related to the GM Tools project. label Dec 6, 2024
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 be working.

@HammerGS
Copy link
Member

HammerGS commented Dec 9, 2024

@Scoppio Just want to confirm this is complete and ready to merge.

private void addTitleAndDescription() {

var title = new JLabel(command.getLongName());
title.setFont(new Font("Arial", Font.BOLD, 18));
Copy link
Member

Choose a reason for hiding this comment

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

I suggest calling
new FlatLafStyleBuilder().size(1.5).bold().apply(title);
instead. This will make it scale appropriately. Also suggest not hardcoding Arial.

add(spinner, gridBagConstraints);
return spinner;
} else if (argument instanceof OptionalIntegerArgument intArg) {
JLabel label = new JLabel(argument.getName() + ":");
Copy link
Member

Choose a reason for hiding this comment

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

The blocks OptionalIntegerArgument and IntegerArgument and probably others are excatly the same, arent they? Suggest combining those.

* @return The entity with the given id number or throw a no such element exception.
*/
public Entity getEntityOrThrow(final int id) {
InGameObject possibleEntity = inGameObjects.get(id);
Copy link
Member

Choose a reason for hiding this comment

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

I think the entire method body can be replaced by
return (Entity) getInGameObject(id).orElseThrow();
A slight difference is that if the object were to be not an Entity (shouldn't happen in a TW game), this would throw a class cast exception instead of a nosuch but I suppose that would be ok?

@@ -2546,6 +2557,24 @@ public boolean isForceVictory() {
return forceVictory;
}

/**
* Getter for property ignorePlayerDefeatVotes.
Copy link
Member

Choose a reason for hiding this comment

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

I suggest not investing these javadoc lines unless they add something interesting over the method signature information. If there's nothing to say for a getter, that's alright.

*
* @param endImmediately New value of property endImmediately.
*/
public void setEndImmediately(boolean endImmediately) {
Copy link
Member

Choose a reason for hiding this comment

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

It appears obvious that this is a setter for something. In this case it might be worth mentioning what the result of setting this to true is. Does it force victory? And what does "immediately" mean?

@HammerGS HammerGS merged commit 159c478 into MegaMek:master Dec 15, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GM Tools All things related to the GM Tools project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants