mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:50:42 +00:00
better random, improved map
This commit is contained in:
@@ -94,9 +94,9 @@
|
||||
* send boat even if touching DONE 9/4/2024
|
||||
* when attacking by boat, attack execution only starts from boat pixel DONE 9/4/2024
|
||||
* Make three terrain types: Plains, highlands, mountains DONE 9/5/2024
|
||||
* directed expansion
|
||||
* more random names for game id & client id
|
||||
* Make fake humans
|
||||
* directed expansion
|
||||
* UI: win condition & popup
|
||||
* UI: boats
|
||||
* UI: current attacks
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 822 KiB After Width: | Height: | Size: 823 KiB |
@@ -1,7 +1,4 @@
|
||||
import {getConfig} from "../core/configuration/Config";
|
||||
import {defaultConfig} from "../core/configuration/DefaultConfig";
|
||||
import {devConfig} from "../core/configuration/DevConfig";
|
||||
import {PseudoRandom} from "../core/PseudoRandom";
|
||||
import {GameID, Lobby, ServerMessage, ServerMessageSchema} from "../core/Schemas";
|
||||
import {loadTerrainMap, TerrainMap} from "../core/TerrainMapLoader";
|
||||
import {ClientGame, createClientGame} from "./ClientGame";
|
||||
@@ -9,6 +6,7 @@ import backgroundImage from '../../resources/images/TerrainMapFrontPage.png';
|
||||
import favicon from '../../resources/images/Favicon.png';
|
||||
|
||||
import './styles.css';
|
||||
import {generateUniqueId} from "../core/Util";
|
||||
|
||||
|
||||
class Client {
|
||||
@@ -69,7 +67,7 @@ class Client {
|
||||
lobbyButton.classList.toggle('highlighted', this.isLobbyHighlighted);
|
||||
}
|
||||
|
||||
if (nameElement) nameElement.textContent = `Game ${lobby.id}`;
|
||||
if (nameElement) nameElement.textContent = `Game ${lobby.id.substring(0, 3)}`;
|
||||
if (timerElement) {
|
||||
const timeRemaining = Math.max(0, Math.floor((lobby.msUntilStart) / 1000));
|
||||
timerElement.textContent = `Starts in: ${timeRemaining}s`;
|
||||
@@ -79,7 +77,7 @@ class Client {
|
||||
if (lobbies.length > 1) {
|
||||
const nextLobby = lobbies[1]
|
||||
const nextGame = document.getElementById('next-game');
|
||||
nextGame.textContent = `Next Game: ${nextLobby.id}`
|
||||
nextGame.textContent = `Next Game: ${nextLobby.id.substring(0, 3)}`
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,7 +120,7 @@ class Client {
|
||||
console.log(`got ip ${clientIP}`)
|
||||
this.game = createClientGame(
|
||||
getUsername(),
|
||||
new PseudoRandom(Date.now()).nextID(), // TODO this can cause dup ids
|
||||
generateUniqueId(),
|
||||
clientIP,
|
||||
lobby.id,
|
||||
getConfig(),
|
||||
|
||||
@@ -97,4 +97,11 @@ export function getMode(list: string[]): string {
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
export function generateUniqueId(): string {
|
||||
if (typeof crypto === 'undefined' || !crypto.randomUUID) {
|
||||
throw new Error('crypto.randomUUID is not supported in this environment');
|
||||
}
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import {PseudoRandom} from "../core/PseudoRandom";
|
||||
import WebSocket from 'ws';
|
||||
import {ClientID, GameID} from "../core/Schemas";
|
||||
import {Client} from "./Client";
|
||||
import {generateUniqueId} from "../core/Util";
|
||||
|
||||
|
||||
export class GameManager {
|
||||
@@ -37,7 +38,7 @@ export class GameManager {
|
||||
const now = Date.now()
|
||||
if (now > this.lastNewLobby + this.config.gameCreationRate()) {
|
||||
this.lastNewLobby = now
|
||||
const id = this.random.nextID()
|
||||
const id = generateUniqueId()
|
||||
lobbies.push(new GameServer(id, now, this.config))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user