Skip to content

Commit 290ef37

Browse files
author
Julien
committed
fix(SDK): Enable adding a player with a custom nickname but the default avatar
1 parent 4b50d43 commit 290ef37

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

runner/src/main/java/com/codingame/gameengine/runner/MultiplayerGameRunner.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,32 @@ public void addAgent(Class<?> playerClass, String nickname, String avatarUrl) {
106106
public void addAgent(String commandLine, String nickname, String avatarUrl) {
107107
addAgent(new CommandLinePlayerAgent(commandLine), nickname, avatarUrl);
108108
}
109+
110+
/**
111+
* Adds an AI to the next game to run, with the specified nickname.
112+
*
113+
* @param playerClass
114+
* the Java class of an AI for your game.
115+
* @param nickname
116+
* the player's nickname
117+
*/
118+
public void addAgent(Class<?> playerClass, String nickname) {
119+
addAgent(new JavaPlayerAgent(playerClass.getName()), nickname, null);
120+
}
121+
122+
/**
123+
* Adds an AI to the next game to run, with the specified nickname.
124+
* <p>
125+
* The given command will be executed with <code>Runtime.getRuntime().exec()</code>.
126+
*
127+
* @param commandLine
128+
* the system command line to run the AI.
129+
* @param nickname
130+
* the player's nickname
131+
*/
132+
public void addAgent(String commandLine, String nickname) {
133+
addAgent(new CommandLinePlayerAgent(commandLine), nickname, null);
134+
}
109135

110136
@Override
111137
protected void buildInitCommand(Command initCommand) {

0 commit comments

Comments
 (0)