Skip to content

Commit

Permalink
Now writes overlay data for Lightfall Qualifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicEastvillage committed Oct 4, 2019
1 parent a4de118 commit 539a7fb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,6 @@ gradle-app.setting

# Cache of project
.gradletasknamecache


current_match.json
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/dk/aau/cs/ds306e18/tournament/rlbot/MatchRunner.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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) {
Expand Down
24 changes: 24 additions & 0 deletions src/dk/aau/cs/ds306e18/tournament/utility/OverlayData.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 539a7fb

Please sign in to comment.