Make world & europe maps more likely for public multiplayer

This commit is contained in:
Evan
2025-02-18 20:36:00 -08:00
parent c4aaa619af
commit 5f26cf72c8
+21 -3
View File
@@ -79,10 +79,28 @@ export class GameManager {
}
private getNextMap(): GameMapType {
if (this.mapsPlaylist.length == 0) {
this.mapsPlaylist = this.random.shuffleArray(Object.values(GameMapType));
if (this.mapsPlaylist.length > 0) {
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() {