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: New GM Commands, princess commands on map menu, graphics for some explosions #6183

Merged
merged 26 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7c4ab9b
feat: adds slash kill command for GMs
Scoppio Nov 6, 2024
f614557
feat: added nosmoke and change weather commands, disaster is currentl…
Scoppio Nov 6, 2024
f7d8a48
feat: added change ownership command, disaster is still WIP
Scoppio Nov 6, 2024
b797123
feat: added multiple GM commands, including kill, change planetary co…
Scoppio Nov 8, 2024
ffe5736
Merge branch 'master' into feature/kill-command
Scoppio Nov 8, 2024
feeca5a
Merge branch 'master' into feature/kill-command
Scoppio Nov 10, 2024
cb1d927
Merge branch 'master' into feature/kill-command
Scoppio Nov 10, 2024
300dc96
Merge branch 'master' into feature/kill-command
Scoppio Nov 11, 2024
fc2e5ac
chore: gm improving gm commands, removing unnecessary options
Scoppio Nov 12, 2024
4c3864e
feat: commands need a second pass for test and eval
Scoppio Nov 14, 2024
02e9645
feat: new commands implemented
Scoppio Nov 15, 2024
4d3ecda
chore: gm improving gm commands, removing unnecessary options
Scoppio Nov 12, 2024
36b6b37
feat: commands need a second pass for test and eval
Scoppio Nov 14, 2024
9f36d77
feat: update server commands for gm
Scoppio Nov 15, 2024
231657f
fix: fixr armor tech rating persistance
Scoppio Nov 16, 2024
a4c6b6a
feat: server commands added
Scoppio Nov 16, 2024
1bc2276
feat: fire fight arguments added
Scoppio Nov 16, 2024
a28fd13
feat: added rescue command
Scoppio Nov 16, 2024
b4b004a
feat: added nuke graphics
Scoppio Nov 17, 2024
5b203a4
feat: added nuke drawing for player commited war crimes
Scoppio Nov 17, 2024
36e30b5
Merge branch 'master' into feature/kill-command
Scoppio Nov 17, 2024
29fd04e
fix: uses bomb hit in case of non-default radius for ortillery, no we…
Scoppio Nov 17, 2024
948e5ea
fix: removed hailstorm, fixed text on ice storm
Scoppio Nov 17, 2024
cf27860
fix: space disasters
Scoppio Nov 17, 2024
7d47cbb
fix: fixed error where random disaster could endup with invalid value
Scoppio Nov 18, 2024
7da1ad0
feat: improved on the enum for disasters
Scoppio Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/common/options/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ GameOptionsInfo.option.allow_nukes.displayableName=Allow command-line nukes.
GameOptionsInfo.option.allow_nukes.description=This must be checked to allow players to throw nukes from the command line. If this is not checked, nukes are still available as advanced munitions.
GameOptionsInfo.option.really_allow_nukes.displayableName=REALLY allow command-line nukes.
GameOptionsInfo.option.really_allow_nukes.description=This must be checked to allow players to throw nukes from the command line. If this is not checked, nukes are still available as advanced munitions.
GameOptionsInfo.option.gm_can_kill_units.displayableName=Allow command-line kill (GM only).
Scoppio marked this conversation as resolved.
Show resolved Hide resolved
GameOptionsInfo.option.gm_can_kill_units.description=This must be checked to allow the GM to kill units using command line. If this is not checked, the command is disabled.


GameOptionsInfo.group.advancedRules.displayableName=Advanced Rules
Expand Down
1 change: 1 addition & 0 deletions megamek/src/megamek/common/options/GameOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public synchronized void initialize() {
addOption(allowed, OptionsConstants.ALLOWED_NO_CLAN_PHYSICAL, false);
addOption(allowed, OptionsConstants.ALLOWED_ALLOW_NUKES, false);
addOption(allowed, OptionsConstants.ALLOWED_REALLY_ALLOW_NUKES, false);
addOption(allowed, OptionsConstants.ALLOWED_GM_CAN_KILL_UNITS, false);

IBasicOptionGroup advancedRules = addGroup("advancedRules");
addOption(advancedRules, OptionsConstants.ADVANCED_MINEFIELDS, false);
Expand Down
1 change: 1 addition & 0 deletions megamek/src/megamek/common/options/OptionsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ public class OptionsConstants {
public static final String ALLOWED_NO_CLAN_PHYSICAL = "no_clan_physical";
public static final String ALLOWED_ALLOW_NUKES = "allow_nukes";
public static final String ALLOWED_REALLY_ALLOW_NUKES = "really_allow_nukes";
public static final String ALLOWED_GM_CAN_KILL_UNITS = "gm_can_kill_units";
public static final String ADVANCED_MINEFIELDS = "minefields";
public static final String ADVANCED_HIDDEN_UNITS = "hidden_units";
public static final String ADVANCED_BLACK_ICE= "black_ice";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AllowGameMasterCommand extends ServerCommand {

public AllowGameMasterCommand(Server server, TWGameManager gameManager) {
super(server, "allowGM", "Allows a player become Game Master "
+ "Usage: /allowGameMaster used in respond to another " +
+ "Usage: /allowGM used in respond to another " +
"Player's request to become Game Master. All players assigned to" +
" a team must allow the change.");
this.gameManager = gameManager;
Expand Down
76 changes: 76 additions & 0 deletions megamek/src/megamek/server/commands/ChangeOwnershipCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.server.commands;

import megamek.common.Entity;
import megamek.common.Player;
import megamek.server.Server;
import megamek.server.totalwarfare.TWGameManager;

/**
* The Server Command "/changeOwner" that will switch an entity's owner to another player.
*
* @author Luana Scoppio
*/
public class ChangeOwnershipCommand extends ServerCommand {

private final TWGameManager gameManager;

public ChangeOwnershipCommand(Server server, TWGameManager gameManager) {
super(server,
"changeOwner",
"Switches ownership of a player's entity to another player during the end phase. "
+ "Usage: /changeOwner <Unit ID> <Player ID> "
+ "The following is an example of changing unit ID 7 to player ID 2: /changeOwner 7 2 ");
this.gameManager = gameManager;
}

/**
* Run this command with the arguments supplied
*
* @see ServerCommand#run(int, String[])
*/
@Override
public void run(int connId, String[] args) {
try {
var currentPlayer = server.getGame().getPlayer(connId);
if (!currentPlayer.isGameMaster()) {
server.sendServerChat(connId, "You are not a Game Master.");
return;
}

int eid = Integer.parseInt(args[1]);
Entity ent = gameManager.getGame().getEntity(eid);
int pid = Integer.parseInt(args[2]);
Player player = server.getGame().getPlayer(pid);
if (null == ent) {
server.sendServerChat(connId, "No such entity.");
} else if (null == player) {
server.sendServerChat(connId, "No such player.");
} else if (player.getTeam() == Player.TEAM_UNASSIGNED) {
server.sendServerChat(connId, "Player must be assigned a team.");
} else {
server.sendServerChat(connId, ent.getDisplayName() + " will switch to " + player.getName() + "'s side at the end of this turn.");
ent.setTraitorId(pid);
}
} catch (NumberFormatException ignored) {
}
}

}
130 changes: 130 additions & 0 deletions megamek/src/megamek/server/commands/ChangeWeatherCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.server.commands;

import megamek.common.planetaryconditions.*;
import megamek.server.Server;
import megamek.server.totalwarfare.TWGameManager;

/**
* @author Luana Scoppio
*/
public class ChangeWeatherCommand extends ServerCommand {

private final TWGameManager gameManager;

/** Creates new ChangeWeatherCommand */
public ChangeWeatherCommand(Server server, TWGameManager gameManager) {
super(server, "weather", "GM changes (weather) planetary conditions. The parameters are optional and unordered " +
"and the effects are applied at the beggining of the next turn. The square brackets means that argument is optional. " +
"Usage format: /weather [fog=0-2] [wind=0-6] [winddir=0-6] [light=0-6] [atmo=0-5] [blowsand=0-1] [weather=0-14] " +
"light= 0: daylight, 1: dusk, 2: full moon, 3: glare, 4: moonless night, 5: solar flare, 6: pitch black " +
"fog= 0: none, 1: light, 2: heavy " +
"wind= 0: calm, 1: light gale, 2: moderate gale, 3: strong gale, 4: storm, 5: tornado F1-F3, 6: tornado F4 " +
"winddir= 0: south, 1: southwest, 2: northwest, 3: north, 4: northeast, 5: southeast, 6: random " +
"atmo= 0: vacuum, 1: trace, 2: thin, 3: standard, 4: high, 5: very high " +
"blowsand= 0: no, 1: yes " +
"weather= 0: clear, 1: light rain, 2: moderate rain, 3: heavy rain, 4: gusting rain, 5: downpour, 6: light snow " +
"7: moderate snow, 8: snow flurries, 9: heavy snow, 10: sleet, 11: ice storm, 12: light hail, 13: heavy hail " +
"14: lightning storm");
this.gameManager = gameManager;
}

/**
* Run this command with the arguments supplied
*/
@Override
public void run(int connId, String[] args) {
if (!server.getPlayer(connId).getGameMaster()) {
server.sendServerChat(connId, "You are not a Game Master.");
return;
}

// Check argument integrity.
if (args.length > 1) {
// Check command
var planetaryConditions = gameManager.getGame().getPlanetaryConditions();

for (var arg : args) {
if (arg.startsWith("fog=")) {
var fog = Integer.parseInt(arg.substring(4));
Fixed Show fixed Hide fixed
if (fog >= 0 && fog < Fog.values().length) {
planetaryConditions.setFog(Fog.values()[fog]);
server.sendServerChat(connId, "The fog has changed.");
} else {
server.sendServerChat(connId, "Invalid fog value. Must be between 0 and " + Fog.values().length);
}
} else if (arg.startsWith("wind=")) {
var wind = Integer.parseInt(arg.substring(5));
Fixed Show fixed Hide fixed
if (wind >= 0 && wind < Wind.values().length) {
planetaryConditions.setWind(Wind.values()[wind]);
server.sendServerChat(connId, "The wind strength has changed.");
} else {
server.sendServerChat(connId, "Invalid wind value. Must be between 0 and " + Wind.values().length);
}
} else if (arg.startsWith("winddir=")) {
var windDir = Integer.parseInt(arg.substring(8));
Fixed Show fixed Hide fixed
if (windDir >= 0 && windDir < WindDirection.values().length) {
planetaryConditions.setWindDirection(WindDirection.values()[windDir]);
server.sendServerChat(connId, "The wind direction has changed.");
} else {
server.sendServerChat(connId, "Invalid wind direction value. Must be between 0 and " + WindDirection.values().length);
}
} else if (arg.startsWith("light=")) {
var light = Integer.parseInt(arg.substring(6));
Fixed Show fixed Hide fixed
if (light >= 0 && light < Light.values().length) {
planetaryConditions.setLight(Light.values()[light]);
server.sendServerChat(connId, "The light has changed.");
} else {
server.sendServerChat(connId, "Invalid light value. Must be between 0 and " + Light.values().length);
}
} else if (arg.startsWith("atmo=")) {
var atmo = Integer.parseInt(arg.substring(5));
Fixed Show fixed Hide fixed
if (atmo >= 0 && atmo < Atmosphere.values().length) {
planetaryConditions.setAtmosphere(Atmosphere.values()[atmo]);
server.sendServerChat(connId, atmo == 0 ? "The air has vanished, put your vac suits!" : "The air is changing.");
} else {
server.sendServerChat(connId, "Invalid atmosphere value. Must be between 0 and " + Atmosphere.values().length);
}
} else if (arg.startsWith("blowsand=")) {
var blowSand = Integer.parseInt(arg.substring(9));
Fixed Show fixed Hide fixed
if (blowSand >= 0 && blowSand < BlowingSand.values().length) {
planetaryConditions.setBlowingSand(BlowingSand.values()[blowSand]);
server.sendServerChat(connId, blowSand == 1 ? "Sand started blowing." : "The sand has settled.");
} else {
server.sendServerChat(connId, "Invalid blowsand value. Must be between 0 and " + BlowingSand.values().length);
}
} else if (arg.startsWith("weather=")) {
var weather = Integer.parseInt(arg.substring(8));
Fixed Show fixed Hide fixed
if (weather >= 0 && weather < Weather.values().length) {
planetaryConditions.setWeather(Weather.values()[weather]);
server.sendServerChat(connId, "The weather has changed.");
} else {
server.sendServerChat(connId, "Invalid weather value. Must be between 0 and " + Weather.values().length);
}
}
}

gameManager.getGame().setPlanetaryConditions(planetaryConditions);
} else {
// Error out; it's not a valid call.
server.sendServerChat(connId, "weather command failed.");
}
}
}
62 changes: 62 additions & 0 deletions megamek/src/megamek/server/commands/DisasterCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.server.commands;

import megamek.server.Server;
import megamek.server.totalwarfare.TWGameManager;

/**
* @author Luana Scoppio
*/
public class DisasterCommand extends ServerCommand {

private final TWGameManager gameManager;

/** Creates new DisasterCommand */
public DisasterCommand(Server server, TWGameManager gameManager) {
super(server, "disaster", "GM calls a disaster at random, arguments in square brackets are optional. Usage: /disaster [type] " +
"if not type is passed, one is chosen at random. " +
"type= 0: hurricane, 1: lightning storm, 2: meteor shower, 3: orbital bombardment, 4: wildfire, 5: sandstorm, 6: hailstorm, " +
"7: heatwave");
this.gameManager = gameManager;
}

/**
* Run this command with the arguments supplied
*/
@Override
public void run(int connId, String[] args) {
if (!server.getPlayer(connId).getGameMaster()) {
server.sendServerChat(connId, "You are not a Game Master.");
return;
}

// Check argument integrity.
if (args.length == 1) {
// Check command
// NOT IMPLEMENTED
server.sendServerChat(connId, "Oh no...");
} else if (args.length == 2) {
// Error out; it's not a valid call.
server.sendServerChat(connId, "Oh no...");
} else {
server.sendServerChat(connId, "disaster command failed (1).");
}
}
}
77 changes: 77 additions & 0 deletions megamek/src/megamek/server/commands/KillCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.server.commands;

import megamek.common.options.OptionsConstants;
import megamek.server.Server;
import megamek.server.totalwarfare.TWGameManager;

/**
* @author Luana Scoppio
*/
public class KillCommand extends ServerCommand {

private final TWGameManager gameManager;

/** Creates new KillCommand */
public KillCommand(Server server, TWGameManager gameManager) {
super(server, "kill", "Allows a GM to destroy a single unit instantly" +
"Usage: "+
"/kill <id> " +
"where id is the units ID. The units ID can be found by hovering over the unit.");
this.gameManager = gameManager;
}

/**
* Run this command with the arguments supplied
*/
@Override
public void run(int connId, String[] args) {

// Check to make sure gm kills are allowed!
if (!(server.getGame().getOptions().booleanOption(OptionsConstants.ALLOWED_GM_CAN_KILL_UNITS))) {
server.sendServerChat(connId, "Command-line kill is not enabled in this game.");
return;
}
if (!server.getPlayer(connId).getGameMaster()) {
server.sendServerChat(connId, "You are not a Game Master.");
return;
}
// Check argument integrity.
if (args.length == 2) {
// Check command
try {
int unitId = Integer.parseInt(args[1]);
// is the unit on the board?
var unit = gameManager.getGame().getEntity(unitId);
if (unit == null) {
server.sendServerChat(connId, "Specified unit is not on the board.");
return;
}
gameManager.destroyEntity(unit, "Act of God", false, false);
server.sendServerChat(connId, unit.getDisplayName() + " has been destroyed.");
} catch (NumberFormatException e) {
server.sendServerChat(connId, "Kill command failed (2). Proper format is \"/kill <id>\" where id is the units numerical ID");
}
} else {
// Error out; it's not a valid call.
server.sendServerChat(connId, "Kill command failed (1). Proper format is \"/kill <id>\" where id is the units ID");
}
}
}
Loading