-
Notifications
You must be signed in to change notification settings - Fork 291
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
Conversation
} | ||
|
||
private JComponent getArgumentComponent(Argument<?> argument) { | ||
if (argument instanceof CoordXArgument intArg) { |
Check notice
Code scanning / CodeQL
Chain of 'instanceof' tests Note
1)); | ||
} | ||
|
||
private JSpinner createSpinner(CoordXArgument coordX) { |
Check notice
Code scanning / CodeQL
Useless parameter Note
1)); | ||
} | ||
|
||
private JSpinner createSpinner(CoordYArgument coordY) { |
Check notice
Code scanning / CodeQL
Useless parameter Note
1)); | ||
} | ||
|
||
private JComboBox<String> createPlayerComboBox(PlayerArgument playerArgument) { |
Check notice
Code scanning / CodeQL
Useless parameter Note
return comboBox; | ||
} | ||
|
||
private JComboBox<String> createUnitComboBox(UnitArgument unitArgument) { |
Check notice
Code scanning / CodeQL
Useless parameter Note
return comboBox; | ||
} | ||
|
||
private JComboBox<String> createTeamsComboBox(TeamArgument teamArgument) { |
Check notice
Code scanning / CodeQL
Useless parameter Note
@@ -73,4 +73,6 @@ | |||
* @param event | |||
*/ | |||
default void gameUnitChange(GameEvent event) { } | |||
|
|||
default void gamePlayerStrategicAction(GamePlayerStrategicActionEvent e) { } |
Check notice
Code scanning / CodeQL
Useless parameter Note
@@ -364,8 +398,23 @@ | |||
return requestedTeam; | |||
} | |||
|
|||
/** |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
TWGameManager.legacyProcessTeamChangeRequest
e2d0846
to
b224fc2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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.
Tested and seems to be working.
@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)); |
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.
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() + ":"); |
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.
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); |
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.
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. |
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.
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) { |
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.
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?
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.