Add next game to menu

This commit is contained in:
evanpelle
2024-09-02 11:22:16 -07:00
parent 866934db68
commit adac26a44f
6 changed files with 23 additions and 44 deletions
+1 -2
View File
@@ -79,9 +79,8 @@
* make mediterranion ocean, fix panama canal DONE 9/1/2024
* remove tiny islands DONE 9/1/2024
* Create exit to menu button DONE 9/2/2024
* show next game in menu
* show next game in menu DONE 9/2/2024
* BUG: attacks starts slow but gets faster
* BUG: sometimes doesn't connect to lobby
* test & deploy game
--- v2 Release
+7 -14
View File
@@ -11,26 +11,15 @@ import favicon from '../../resources/images/Favicon.png';
import './styles.css';
// import WebSocket from 'ws';
class Client {
private hasJoined = false
private socket: WebSocket | null = null;
private terrainMap: Promise<TerrainMap>
private game: ClientGame
private lobbiesContainer: HTMLElement | null;
private lobbiesInterval: NodeJS.Timeout | null = null;
private isLobbyHighlighted: boolean = false;
private random = new PseudoRandom(1234)
private ip: Promise<string | null> = null
constructor() {
this.lobbiesContainer = document.getElementById('lobbies-container');
}
initialize(): void {
@@ -86,6 +75,13 @@ class Client {
timerElement.textContent = `Starts in: ${timeRemaining}s`;
}
if (playerCountElement) playerCountElement.textContent = `Players: ${lobby.numClients}`;
if (lobbies.length > 1) {
const nextLobby = lobbies[1]
const nextGame = document.getElementById('next-game');
nextGame.textContent = `Next Game: ${nextLobby.id}`
}
}
async fetchLobbies(): Promise<Lobby[]> {
@@ -161,7 +157,6 @@ function setupUsernameCallback(callback: (username: string) => void): void {
}
}
async function getClientIP(timeoutMs: number = 1000): Promise<string | null> {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
@@ -193,8 +188,6 @@ async function getClientIP(timeoutMs: number = 1000): Promise<string | null> {
}
}
// Initialize the client when the DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
new Client().initialize();
+3 -24
View File
@@ -21,29 +21,7 @@
<div id="player-count" class="player-count"></div>
</button>
</div>
<!-- <div id="dev-log">
<h4>DEVLOG: 8/18/2024 - 8/26/2024</h4>
<ul id="dev-log">
<li>Create dev server at <a href="https://www.openfront.dev">openfront.dev</a></li>
<li>fix invert zoom</li>
<li>better algorithm for name render placement</li>
<li>show how many players in each lobby</li>
<li>make boats larger</li>
<li>boats same color as owner</li>
<li>make coasts look better</li>
<li>have boats not get close to shore</li>
<li>improve terrain colors</li>
<li>FIXED: boat doesn't work if on lake if other player not on same lake</li>
<li>Allow boats to attack unowned land</li>
<li>add vintage theme</li>
<li>Created Panama Canal and Bosphorus Strait</li>
<li>Make lobby background the terrain map</li>
<li>Created favicon</li>
<li>improve menu (keep highlighted when click, allow deselect lobby)</li>
<li>Can respawn at start of game</li>
<li>Added spawn timer</li>
</ul>
</div> -->
<h3 id="next-game"> </h3>
</div>
<style>
@@ -61,7 +39,8 @@
<!-- Cloudflare Web Analytics -->
<script defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "03d93e6fefb349c28ee69b408fa25a13"}'></script><!-- End Cloudflare Web Analytics -->
data-cf-beacon='{"token": "03d93e6fefb349c28ee69b408fa25a13"}'></script>
<!-- End Cloudflare Web Analytics -->
</body>
</html>
+9 -1
View File
@@ -41,7 +41,15 @@ h2 {
font-family: Arial, serif;
text-align: center;
color: #2e2e2e;
font-size: 4em;
font-size: 3em;
margin-bottom: 30px;
}
h3 {
font-family: Arial, serif;
text-align: center;
color: #000000;
font-size: 2.3em;
margin-bottom: 30px;
}
+1 -1
View File
@@ -22,7 +22,7 @@ export class DefaultConfig implements Config {
return 100
}
gameCreationRate(): number {
return 20 * 1000
return 10 * 1000
}
lobbyLifetime(): number {
return 20 * 1000
+2 -2
View File
@@ -6,10 +6,10 @@ export const devConfig = new class extends DefaultConfig {
return 40
}
gameCreationRate(): number {
return 3 * 1000
return 2 * 1000
}
lobbyLifetime(): number {
return 3 * 1000
return 4 * 1000
}
turnIntervalMs(): number {
return 100