mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 00:28:14 +00:00
Make world & europe maps more likely for public multiplayer
This commit is contained in:
@@ -79,10 +79,28 @@ export class GameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getNextMap(): GameMapType {
|
private getNextMap(): GameMapType {
|
||||||
if (this.mapsPlaylist.length == 0) {
|
if (this.mapsPlaylist.length > 0) {
|
||||||
this.mapsPlaylist = this.random.shuffleArray(Object.values(GameMapType));
|
return this.mapsPlaylist.shift();
|
||||||
}
|
}
|
||||||
return this.mapsPlaylist.shift();
|
while (true) {
|
||||||
|
this.mapsPlaylist = Object.values(GameMapType);
|
||||||
|
this.mapsPlaylist.push(GameMapType.World);
|
||||||
|
this.mapsPlaylist.push(GameMapType.Europe);
|
||||||
|
this.random.shuffleArray(this.mapsPlaylist);
|
||||||
|
if (this.allNonConsecutive(this.mapsPlaylist)) {
|
||||||
|
return this.mapsPlaylist.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private allNonConsecutive(maps: GameMapType[]): boolean {
|
||||||
|
// Check for consecutive duplicates in the maps array
|
||||||
|
for (let i = 0; i < maps.length - 1; i++) {
|
||||||
|
if (maps[i] === maps[i + 1]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
|
|||||||
Reference in New Issue
Block a user