mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-09 13:08:04 +00:00
create troop slider
This commit is contained in:
+21
-5
@@ -1,8 +1,8 @@
|
||||
import {Config} from "../core/configuration/Config"
|
||||
import {EventBus, GameEvent} from "../core/EventBus"
|
||||
import {AllianceRequest, AllPlayers, Cell, Player, PlayerID, PlayerType} from "../core/game/Game"
|
||||
import {ClientID, ClientIntentMessageSchema, ClientJoinMessageSchema, ClientLeaveMessageSchema, GameID, Intent, ServerMessage, ServerMessageSchema} from "../core/Schemas"
|
||||
import {LocalServer} from "./LocalServer"
|
||||
import { Config } from "../core/configuration/Config"
|
||||
import { EventBus, GameEvent } from "../core/EventBus"
|
||||
import { AllianceRequest, AllPlayers, Cell, Player, PlayerID, PlayerType } from "../core/game/Game"
|
||||
import { ClientID, ClientIntentMessageSchema, ClientJoinMessageSchema, ClientLeaveMessageSchema, GameID, Intent, ServerMessage, ServerMessageSchema } from "../core/Schemas"
|
||||
import { LocalServer } from "./LocalServer"
|
||||
|
||||
|
||||
export class SendAllianceRequestIntentEvent implements GameEvent {
|
||||
@@ -76,6 +76,12 @@ export class SendNukeIntentEvent implements GameEvent {
|
||||
) { }
|
||||
}
|
||||
|
||||
export class SendSetTargetTroopRatioEvent implements GameEvent {
|
||||
constructor(
|
||||
public readonly ratio: number,
|
||||
) { }
|
||||
}
|
||||
|
||||
export class Transport {
|
||||
|
||||
private socket: WebSocket
|
||||
@@ -108,6 +114,7 @@ export class Transport {
|
||||
this.eventBus.on(SendEmojiIntentEvent, (e) => this.onSendEmojiIntent(e))
|
||||
this.eventBus.on(SendDonateIntentEvent, (e) => this.onSendDonateIntent(e))
|
||||
this.eventBus.on(SendNukeIntentEvent, (e) => this.onSendNukeIntent(e))
|
||||
this.eventBus.on(SendSetTargetTroopRatioEvent, (e) => this.onSendSetTargetTroopRatioEvent(e))
|
||||
}
|
||||
|
||||
connect(onconnect: () => void, onmessage: (message: ServerMessage) => void) {
|
||||
@@ -298,6 +305,15 @@ export class Transport {
|
||||
})
|
||||
}
|
||||
|
||||
private onSendSetTargetTroopRatioEvent(event: SendSetTargetTroopRatioEvent) {
|
||||
this.sendIntent({
|
||||
type: "troop_ratio",
|
||||
clientID: this.clientID,
|
||||
player: this.playerID,
|
||||
ratio: event.ratio,
|
||||
})
|
||||
}
|
||||
|
||||
private sendIntent(intent: Intent) {
|
||||
if (this.isLocal || this.socket.readyState === WebSocket.OPEN) {
|
||||
const msg = ClientIntentMessageSchema.parse({
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import {AllPlayers, Cell, Game, Player, PlayerType} from "../../../core/game/Game"
|
||||
import {PseudoRandom} from "../../../core/PseudoRandom"
|
||||
import {calculateBoundingBox} from "../../../core/Util"
|
||||
import {Theme} from "../../../core/configuration/Config"
|
||||
import {Layer} from "./Layer"
|
||||
import {placeName} from "../NameBoxCalculator"
|
||||
import {TransformHandler} from "../TransformHandler"
|
||||
import {renderTroops} from "../Utils"
|
||||
import { AllPlayers, Cell, Game, Player, PlayerType } from "../../../core/game/Game"
|
||||
import { PseudoRandom } from "../../../core/PseudoRandom"
|
||||
import { calculateBoundingBox } from "../../../core/Util"
|
||||
import { Theme } from "../../../core/configuration/Config"
|
||||
import { Layer } from "./Layer"
|
||||
import { placeName } from "../NameBoxCalculator"
|
||||
import { TransformHandler } from "../TransformHandler"
|
||||
import { renderTroops } from "../Utils"
|
||||
import traitorIcon from '../../../../resources/images/TraitorIcon.png';
|
||||
import allianceIcon from '../../../../resources/images/AllianceIcon.png';
|
||||
import crownIcon from '../../../../resources/images/CrownIcon.png';
|
||||
import targetIcon from '../../../../resources/images/TargetIcon.png';
|
||||
import {ClientID} from "../../../core/Schemas"
|
||||
import { ClientID } from "../../../core/Schemas"
|
||||
|
||||
|
||||
class RenderInfo {
|
||||
@@ -19,7 +19,7 @@ class RenderInfo {
|
||||
public player: Player,
|
||||
public lastRenderCalc: number,
|
||||
public lastBoundingCalculated: number,
|
||||
public boundingBox: {min: Cell, max: Cell},
|
||||
public boundingBox: { min: Cell, max: Cell },
|
||||
public location: Cell,
|
||||
public fontSize: number
|
||||
) { }
|
||||
|
||||
Reference in New Issue
Block a user