From 539a7fbc78d2dda6a594f27d46c653e2ca47f885 Mon Sep 17 00:00:00 2001 From: NicEastvillage Date: Fri, 4 Oct 2019 09:19:55 +0200 Subject: [PATCH] Now writes overlay data for Lightfall Qualifiers. --- .gitignore | 3 +++ .idea/misc.xml | 2 +- .../tournament/rlbot/MatchRunner.java | 15 ++++++++++++ .../tournament/utility/OverlayData.java | 24 +++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/dk/aau/cs/ds306e18/tournament/utility/OverlayData.java diff --git a/.gitignore b/.gitignore index 8d007cf..34241cf 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,6 @@ gradle-app.setting # Cache of project .gradletasknamecache + + +current_match.json \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6bd5763..ddaffea 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/src/dk/aau/cs/ds306e18/tournament/rlbot/MatchRunner.java b/src/dk/aau/cs/ds306e18/tournament/rlbot/MatchRunner.java index 50eccea..2d4e8a9 100644 --- a/src/dk/aau/cs/ds306e18/tournament/rlbot/MatchRunner.java +++ b/src/dk/aau/cs/ds306e18/tournament/rlbot/MatchRunner.java @@ -1,16 +1,22 @@ package dk.aau.cs.ds306e18.tournament.rlbot; +import com.google.gson.Gson; +import com.google.gson.annotations.SerializedName; import dk.aau.cs.ds306e18.tournament.model.Bot; import dk.aau.cs.ds306e18.tournament.model.BotFromConfig; import dk.aau.cs.ds306e18.tournament.model.match.Match; import dk.aau.cs.ds306e18.tournament.rlbot.configuration.MatchConfig; import dk.aau.cs.ds306e18.tournament.rlbot.configuration.ParticipantInfo; import dk.aau.cs.ds306e18.tournament.rlbot.configuration.TeamColor; +import dk.aau.cs.ds306e18.tournament.serialization.Serializer; import dk.aau.cs.ds306e18.tournament.settings.SettingsDirectory; import dk.aau.cs.ds306e18.tournament.utility.Alerts; +import dk.aau.cs.ds306e18.tournament.utility.OverlayData; import java.io.*; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; public class MatchRunner { @@ -32,6 +38,15 @@ public static boolean startMatch(MatchConfig matchConfig, Match match) { String command = String.format(COMMAND_FORMAT, pathToDirectory, pathToDirectory.toString().substring(0, 2)); System.out.println("Starting RLBot framework with command: " + command); Runtime.getRuntime().exec(command); + + // FIXME Bodge overlay data + OverlayData overlayData = new OverlayData( + ((BotFromConfig) match.getBlueTeam().getBots().get(0)).getConfig(), + ((BotFromConfig) match.getOrangeTeam().getBots().get(0)).getConfig() + ); + Serializer.gson.toJson(overlayData); + Files.write(Paths.get("current_match.json").toAbsolutePath(), new Gson().toJson(overlayData).getBytes()); + System.out.println("Printed current match to " + Paths.get("current_match.json").toAbsolutePath().toString()); return true; } catch (Exception err) { diff --git a/src/dk/aau/cs/ds306e18/tournament/utility/OverlayData.java b/src/dk/aau/cs/ds306e18/tournament/utility/OverlayData.java new file mode 100644 index 0000000..345b614 --- /dev/null +++ b/src/dk/aau/cs/ds306e18/tournament/utility/OverlayData.java @@ -0,0 +1,24 @@ +package dk.aau.cs.ds306e18.tournament.utility; + +import com.google.gson.annotations.SerializedName; +import dk.aau.cs.ds306e18.tournament.rlbot.configuration.BotConfig; + +/** + * A data class for the RLBot's current OBS overlay script + */ +public class OverlayData { + + @SerializedName("division") + private final int division = 0; // Not used + + @SerializedName("blue_config_path") + private final String blueConfig; + + @SerializedName("orange_config_path") + private final String orangeConfig; + + public OverlayData(BotConfig blueConfig, BotConfig orangeConfig) { + this.blueConfig = blueConfig.getConfigFile().getAbsolutePath(); + this.orangeConfig = orangeConfig.getConfigFile().getAbsolutePath(); + } +}