mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 05:12:01 +00:00
update gamemap, rename gamemap enum => gamemaptype
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Executor } from "../core/execution/ExecutionManager";
|
||||
import { Cell, MutableGame, PlayerID, GameMap, Difficulty, GameType } from "../core/game/Game";
|
||||
import { Cell, MutableGame, PlayerID, GameMapType, Difficulty, GameType } from "../core/game/Game";
|
||||
import { createGame } from "../core/game/GameImpl";
|
||||
import { EventBus } from "../core/EventBus";
|
||||
import { createRenderer, GameRenderer } from "./graphics/GameRenderer";
|
||||
@@ -23,7 +23,7 @@ export interface LobbyConfig {
|
||||
persistentID: string,
|
||||
gameType: GameType
|
||||
gameID: GameID,
|
||||
map: GameMap | null
|
||||
map: GameMapType | null
|
||||
difficulty: Difficulty | null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { Difficulty, GameMap, GameType } from '../core/game/Game';
|
||||
import { Difficulty, GameMapType, GameType } from '../core/game/Game';
|
||||
import { Lobby } from '../core/Schemas';
|
||||
import { consolex } from '../core/Consolex';
|
||||
|
||||
@customElement('host-lobby-modal')
|
||||
export class HostLobbyModal extends LitElement {
|
||||
@state() private isModalOpen = false;
|
||||
@state() private selectedMap: GameMap = GameMap.World;
|
||||
@state() private selectedMap: GameMapType = GameMapType.World;
|
||||
@state() private selectedDiffculty: Difficulty = Difficulty.Medium;
|
||||
@state() private lobbyId = '';
|
||||
@state() private copySuccess = false;
|
||||
@@ -116,7 +116,7 @@ export class HostLobbyModal extends LitElement {
|
||||
<div>
|
||||
<label for="map-select">Map: </label>
|
||||
<select id="map-select" @change=${this.handleMapChange}>
|
||||
${Object.entries(GameMap)
|
||||
${Object.entries(GameMapType)
|
||||
.filter(([key]) => isNaN(Number(key)))
|
||||
.map(([key, value]) => html`
|
||||
<option value=${value} ?selected=${this.selectedMap === value}>
|
||||
@@ -179,7 +179,7 @@ export class HostLobbyModal extends LitElement {
|
||||
}
|
||||
|
||||
private async handleMapChange(e: Event) {
|
||||
this.selectedMap = String((e.target as HTMLSelectElement).value) as GameMap;
|
||||
this.selectedMap = String((e.target as HTMLSelectElement).value) as GameMapType;
|
||||
consolex.log(`updating map to ${this.selectedMap}`)
|
||||
this.putGameConfig()
|
||||
}
|
||||
@@ -201,7 +201,7 @@ export class HostLobbyModal extends LitElement {
|
||||
}
|
||||
|
||||
private async startGame() {
|
||||
consolex.log(`Starting private game with map: ${GameMap[this.selectedMap]}`);
|
||||
consolex.log(`Starting private game with map: ${GameMapType[this.selectedMap]}`);
|
||||
this.close();
|
||||
const response = await fetch(`/start_private_lobby/${this.lobbyId}`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement, property, state, query } from 'lit/decorators.js';
|
||||
import { GameMap, GameType } from '../core/game/Game';
|
||||
import { GameMapType, GameType } from '../core/game/Game';
|
||||
import { consolex } from '../core/Consolex';
|
||||
|
||||
@customElement('join-private-lobby-modal')
|
||||
@@ -174,7 +174,7 @@ export class JoinPrivateLobbyModal extends LitElement {
|
||||
detail: {
|
||||
lobby: { id: lobbyId },
|
||||
gameType: GameType.Private,
|
||||
map: GameMap.World,
|
||||
map: GameMapType.World,
|
||||
},
|
||||
bubbles: true,
|
||||
composed: true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { Lobby } from "../core/Schemas";
|
||||
import { Difficulty, GameMap, GameType } from '../core/game/Game';
|
||||
import { Difficulty, GameMapType, GameType } from '../core/game/Game';
|
||||
import { consolex } from '../core/Consolex';
|
||||
|
||||
@customElement('public-lobby')
|
||||
@@ -113,7 +113,7 @@ export class PublicLobby extends LitElement {
|
||||
detail: {
|
||||
lobby: lobby,
|
||||
gameType: GameType.Public,
|
||||
map: GameMap.World,
|
||||
map: GameMapType.World,
|
||||
difficulty: Difficulty.Medium,
|
||||
},
|
||||
bubbles: true,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { Difficulty, GameMap, GameType } from '../core/game/Game';
|
||||
import { Difficulty, GameMapType, GameType } from '../core/game/Game';
|
||||
import { generateID as generateID } from '../core/Util';
|
||||
import { consolex } from '../core/Consolex';
|
||||
|
||||
@customElement('single-player-modal')
|
||||
export class SinglePlayerModal extends LitElement {
|
||||
@state() private isModalOpen = false;
|
||||
@state() private selectedMap: GameMap = GameMap.World;
|
||||
@state() private selectedMap: GameMapType = GameMapType.World;
|
||||
@state() private selectedDifficulty: Difficulty = Difficulty.Medium;
|
||||
|
||||
static styles = css`
|
||||
@@ -81,7 +81,7 @@ export class SinglePlayerModal extends LitElement {
|
||||
<div>
|
||||
<label for="map-select">Map: </label>
|
||||
<select id="map-select" @change=${this.handleMapChange}>
|
||||
${Object.entries(GameMap)
|
||||
${Object.entries(GameMapType)
|
||||
.filter(([key]) => isNaN(Number(key)))
|
||||
.map(([key, value]) => html`
|
||||
<option value=${value} ?selected=${this.selectedMap === value}>
|
||||
@@ -118,13 +118,13 @@ export class SinglePlayerModal extends LitElement {
|
||||
}
|
||||
|
||||
private handleMapChange(e: Event) {
|
||||
this.selectedMap = String((e.target as HTMLSelectElement).value) as GameMap;
|
||||
this.selectedMap = String((e.target as HTMLSelectElement).value) as GameMapType;
|
||||
}
|
||||
private handleDifficultyChange(e: Event) {
|
||||
this.selectedDifficulty = String((e.target as HTMLSelectElement).value) as Difficulty;
|
||||
}
|
||||
private startGame() {
|
||||
consolex.log(`Starting single player game with map: ${GameMap[this.selectedMap]}`);
|
||||
consolex.log(`Starting single player game with map: ${GameMapType[this.selectedMap]}`);
|
||||
this.dispatchEvent(new CustomEvent('join-lobby', {
|
||||
detail: {
|
||||
gameType: GameType.Singleplayer,
|
||||
|
||||
Reference in New Issue
Block a user