Skip to content

Commit 6643548

Browse files
Merge branch 'doc-sdk-first-turn' into 'master'
feat(sdk): add a method to edit the timeout of the first turn of a game See merge request codingame/game-engine!227
2 parents e3630ba + f60b03a commit 6643548

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,12 @@ public int getMaxTurns() {
439439
}
440440

441441
/**
442-
* Set the timeout delay for every players. This value can be updated during a game and will be used by execute(). Default is 50ms.
442+
* Set the timeout delay for every player. This value can be updated during a game and will be used by execute(). Default is 50ms.
443443
*
444444
* @param turnMaxTime
445445
* Duration in milliseconds.
446446
* @throws IllegalArgumentException
447-
* if turnMaxTime ≤ 0
447+
* if turnMaxTime < 50 or > 25000
448448
*/
449449
public void setTurnMaxTime(int turnMaxTime) throws IllegalArgumentException {
450450
if (turnMaxTime < MIN_TURN_TIME) {
@@ -454,15 +454,41 @@ public void setTurnMaxTime(int turnMaxTime) throws IllegalArgumentException {
454454
}
455455
this.turnMaxTime = turnMaxTime;
456456
}
457+
458+
/**
459+
* Set the timeout delay of the first turn for every player. Default is 1000ms.
460+
*
461+
* @param firstTurnMaxTime
462+
* Duration in milliseconds.
463+
* @throws IllegalArgumentException
464+
* if firstTurnMaxTime &lt; 50 or &gt; 25000
465+
*/
466+
public void setFirstTurnMaxTime(int firstTurnMaxTime) throws IllegalArgumentException {
467+
if (firstTurnMaxTime < MIN_TURN_TIME) {
468+
throw new IllegalArgumentException("Invalid turn max time : stay above 50ms");
469+
} else if (firstTurnMaxTime > MAX_TURN_TIME) {
470+
throw new IllegalArgumentException("Invalid turn max time : stay under 25s");
471+
}
472+
this.firstTurnMaxTime = firstTurnMaxTime;
473+
}
457474

458475
/**
459-
* Get the timeout delay for every players.
476+
* Get the timeout delay for every player.
460477
*
461478
* @return the current timeout duration in milliseconds.
462479
*/
463480
public int getTurnMaxTime() {
464481
return turnMaxTime;
465482
}
483+
484+
/**
485+
* Get the timeout delay of the first turn for every player.
486+
*
487+
* @return the first turn timeout duration in milliseconds.
488+
*/
489+
public int getFirstTurnMaxTime() {
490+
return firstTurnMaxTime;
491+
}
466492

467493
/**
468494
* Set data for use by the viewer, for the current frame.

0 commit comments

Comments
 (0)