mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:32:21 +00:00
[Bugfix] Force end 170mins (#3326)
## Description: instead of just killing the server, lets save 10m before, then kill the server at 3hr mark, so at least we have a proper savegame. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n
This commit is contained in:
@@ -19,6 +19,10 @@ export class WinCheckExecution implements Execution {
|
||||
|
||||
private mg: Game | null = null;
|
||||
|
||||
// Hard time limit (in seconds) to force a winner before the server's
|
||||
// maxGameDuration hard kill. 170mins (10 mins before 3hrs)
|
||||
private static readonly HARD_TIME_LIMIT_SECONDS = 170 * 60;
|
||||
|
||||
constructor() {}
|
||||
|
||||
init(mg: Game, ticks: number) {
|
||||
@@ -68,7 +72,8 @@ export class WinCheckExecution implements Execution {
|
||||
(max.numTilesOwned() / numTilesWithoutFallout) * 100 >
|
||||
this.mg.config().percentageTilesOwnedToWin() ||
|
||||
(this.mg.config().gameConfig().maxTimerValue !== undefined &&
|
||||
timeElapsed - this.mg.config().gameConfig().maxTimerValue! * 60 >= 0)
|
||||
timeElapsed - this.mg.config().gameConfig().maxTimerValue! * 60 >= 0) ||
|
||||
timeElapsed >= WinCheckExecution.HARD_TIME_LIMIT_SECONDS
|
||||
) {
|
||||
this.mg.setWinner(max, this.mg.stats().stats());
|
||||
console.log(`${max.name()} has won the game`);
|
||||
@@ -103,7 +108,8 @@ export class WinCheckExecution implements Execution {
|
||||
if (
|
||||
percentage > this.mg.config().percentageTilesOwnedToWin() ||
|
||||
(this.mg.config().gameConfig().maxTimerValue !== undefined &&
|
||||
timeElapsed - this.mg.config().gameConfig().maxTimerValue! * 60 >= 0)
|
||||
timeElapsed - this.mg.config().gameConfig().maxTimerValue! * 60 >= 0) ||
|
||||
timeElapsed >= WinCheckExecution.HARD_TIME_LIMIT_SECONDS
|
||||
) {
|
||||
if (max[0] === ColoredTeams.Bot) return;
|
||||
this.mg.setWinner(max[0], this.mg.stats().stats());
|
||||
|
||||
Reference in New Issue
Block a user