Skip to content

Commit 97486f3

Browse files
author
Julien Poulton
committed
Merge branch 'master' into 'config-checker'
# Conflicts: # playground/misc/misc-3-release-notes.md
2 parents 74babbc + 8054cf5 commit 97486f3

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

engine/core/src/main/java/com/codingame/gameengine/core/GameManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,13 @@ public final void putMetadata(String key, String value) {
371371
*
372372
* @param frameDuration
373373
* The frame duration in milliseconds.
374+
* @throws IllegalArgumentException
375+
* if frameDuration <= 0
374376
*/
375377
public void setFrameDuration(int frameDuration) {
376-
if (this.frameDuration != frameDuration) {
378+
if (frameDuration <= 0) {
379+
throw new IllegalArgumentException("Invalid frame duration: only positive frame duration is supported");
380+
} else if (this.frameDuration != frameDuration) {
377381
this.frameDuration = frameDuration;
378382
currentViewData.addProperty("duration", frameDuration);
379383
}

playground/misc/misc-3-release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ The CodinGame SDK is regularly updated and improved. This document lets you know
66

77
### 🐞 Bug fix
88

9+
- Included missing `addAgent` polymorphism – custom nickname with default avatar.
910
- Improved display of player output in local test page.
1011
- Better handling of errors from initializing modules
1112
- Unused `title` property no longer mandatory in `config.ini`
13+
- `setFrameDuration()` now throws an exception on non-positive values.
1214

1315
## 3.3.1
1416

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)