mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 23:54:35 +00:00
can create alliance between humans
This commit is contained in:
@@ -12,6 +12,7 @@ import {TerrainLayer} from "./graphics/layers/TerrainLayer";
|
||||
import {WinCheckExecution} from "../core/execution/WinCheckExecution";
|
||||
import {SendAllianceRequestUIEvent} from "./graphics/layers/UILayer";
|
||||
import {createCanvas} from "./graphics/Utils";
|
||||
import {AllianceRequestReplyUIEvent as SendAllianceRequestReplyUIEvent} from "./graphics/layers/EventsDisplay";
|
||||
|
||||
|
||||
|
||||
@@ -125,6 +126,7 @@ export class ClientGame {
|
||||
this.eventBus.on(PlayerEvent, (e) => this.playerEvent(e))
|
||||
this.eventBus.on(MouseUpEvent, (e) => this.inputEvent(e))
|
||||
this.eventBus.on(SendAllianceRequestUIEvent, (e) => this.onSendAllianceRequest(e))
|
||||
this.eventBus.on(SendAllianceRequestReplyUIEvent, (e) => this.onAllianceRequestReplyUIEvent(e))
|
||||
|
||||
this.renderer.initialize()
|
||||
this.input.initialize()
|
||||
@@ -282,6 +284,16 @@ export class ClientGame {
|
||||
})
|
||||
}
|
||||
|
||||
private onAllianceRequestReplyUIEvent(event: SendAllianceRequestReplyUIEvent) {
|
||||
this.sendIntent({
|
||||
type: "allianceRequestReply",
|
||||
clientID: this.id,
|
||||
requestor: event.allianceRequest.requestor().id(),
|
||||
recipient: event.allianceRequest.recipient().id(),
|
||||
accept: event.accepted,
|
||||
})
|
||||
}
|
||||
|
||||
private sendSpawnIntent(cell: Cell) {
|
||||
this.sendIntent({
|
||||
type: "spawn",
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import {nullable} from "zod";
|
||||
import {EventBus} from "../../../core/EventBus";
|
||||
import {AllianceRequestEvent, AllianceRequestReplyEvent, Game} from "../../../core/game/Game";
|
||||
import {EventBus, GameEvent} from "../../../core/EventBus";
|
||||
import {AllianceRequest, AllianceRequestEvent, AllianceRequestReplyEvent, Game} from "../../../core/game/Game";
|
||||
import {ClientID} from "../../../core/Schemas";
|
||||
import {Layer} from "./Layer";
|
||||
|
||||
export class AllianceRequestReplyUIEvent implements GameEvent {
|
||||
constructor(
|
||||
public readonly allianceRequest: AllianceRequest,
|
||||
public readonly accepted: boolean,
|
||||
) { }
|
||||
}
|
||||
|
||||
interface Event {
|
||||
description: string;
|
||||
buttons?: {
|
||||
@@ -72,12 +79,12 @@ export class EventsDisplay implements Layer {
|
||||
{
|
||||
text: "Accept",
|
||||
className: "btn",
|
||||
action: () => alert('accepted'),
|
||||
action: () => this.eventBus.emit(new AllianceRequestReplyUIEvent(event.allianceRequest, true)),
|
||||
},
|
||||
{
|
||||
text: "Reject",
|
||||
className: "btn btn-info",
|
||||
action: () => alert('rejected'),
|
||||
action: () => this.eventBus.emit(new AllianceRequestReplyUIEvent(event.allianceRequest, false)),
|
||||
}
|
||||
],
|
||||
highlight: true
|
||||
|
||||
Reference in New Issue
Block a user