Skip to content

Commit

Permalink
[FEAT] Add parameter for ready phase duration
Browse files Browse the repository at this point in the history
This adds a cli parameter ("-r" or "--readytimeduration") to override the default league ready phase
duration.
  • Loading branch information
SGSSGene committed Jun 14, 2021
1 parent b31c2e0 commit 62a94b3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/controller/GameControllerSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class GameControllerSimulator {
+ "\n (-c | --config) <path/to/game.json> sets a custom game.json to launch the game from (uses the resource folder by default)"
+ "\n (-b | --broadcast) <ip> IP address of the broadcasting server. local broadcast by default"
+ "\n (-d | --halftimeduration) <time in seconds> Sets the time in seconds of the half time length"
+ "\n (-r | --readytimeduration) <time in seconds> Sets the time in seconds of the ready pahes at the start of a half time"
+ "\n";
private static final String COMMAND_INTERFACE = "--interface";
private static final String COMMAND_INTERFACE_SHORT = "-i";
Expand All @@ -88,6 +89,8 @@ public class GameControllerSimulator {
private static final String COMMAND_BROADCAST_SHORT = "-b";
private static final String COMMAND_HALFTIME_SHORT = "-d";
private static final String COMMAND_HALFTIME = "--halftimeduration";
private static final String COMMAND_READYTIME_SHORT = "-r";
private static final String COMMAND_READYTIME = "--readytimeduration";

/** Dynamically settable path to the config root folder */
private static final String CONFIG_ROOT = System.getProperty("CONFIG_ROOT", "");
Expand All @@ -101,6 +104,7 @@ public class GameControllerSimulator {
private static InetAddress BROADCAST_IP = null;

private static int half_time_length = 0;
private static int ready_time_length = 0;

/**
* The program starts here.
Expand Down Expand Up @@ -159,7 +163,11 @@ public static void main(String[] args) {
} else if (args[i].equals(COMMAND_HALFTIME) || args[i].equals(COMMAND_HALFTIME_SHORT)) {
half_time_length = Integer.parseInt(args[++i]);
continue parsing;
} else if (args[i].equals(COMMAND_READYTIME) || args[i].equals(COMMAND_READYTIME_SHORT)) {
ready_time_length = Integer.parseInt(args[++i]);
continue parsing;
}

String leagues = "";
for (Rules rules : Rules.LEAGUES) {
leagues += (leagues.equals("") ? "" : " | ") + rules.leagueDirectory;
Expand Down Expand Up @@ -301,6 +309,9 @@ public static void main(String[] args) {
if (half_time_length > 0) {
Rules.league.halfTime = half_time_length;
}
if (ready_time_length > 0) {
Rules.league.readyTime = ready_time_length;
}

if (match_type.equals("NORMAL")) {
gpd.setFullTimeGame(false);
Expand Down

0 comments on commit 62a94b3

Please sign in to comment.