mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-28 12:34:16 +00:00
Merge main into strict
This commit is contained in:
@@ -2,6 +2,7 @@ import { LitElement, html } from "lit";
|
||||
import { customElement, state } from "lit/decorators.js";
|
||||
import "./LanguageModal";
|
||||
|
||||
import ar from "../../resources/lang/ar.json";
|
||||
import bg from "../../resources/lang/bg.json";
|
||||
import bn from "../../resources/lang/bn.json";
|
||||
import de from "../../resources/lang/de.json";
|
||||
@@ -17,6 +18,7 @@ import pl from "../../resources/lang/pl.json";
|
||||
import pt_br from "../../resources/lang/pt_br.json";
|
||||
import ru from "../../resources/lang/ru.json";
|
||||
import sh from "../../resources/lang/sh.json";
|
||||
import tp from "../../resources/lang/tp.json";
|
||||
import tr from "../../resources/lang/tr.json";
|
||||
import uk from "../../resources/lang/uk.json";
|
||||
|
||||
@@ -32,6 +34,7 @@ export class LangSelector extends LitElement {
|
||||
private dKeyPressed: boolean = false;
|
||||
|
||||
private languageMap: Record<string, any> = {
|
||||
ar,
|
||||
bg,
|
||||
bn,
|
||||
de,
|
||||
@@ -48,6 +51,7 @@ export class LangSelector extends LitElement {
|
||||
ru,
|
||||
sh,
|
||||
tr,
|
||||
tp,
|
||||
uk,
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
EmojiUpdate,
|
||||
GameUpdateType,
|
||||
TargetPlayerUpdate,
|
||||
UnitIncomingUpdate,
|
||||
} from "../../../core/game/GameUpdates";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import {
|
||||
@@ -53,6 +54,7 @@ interface Event {
|
||||
priority?: number;
|
||||
duration?: Tick;
|
||||
focusID?: number;
|
||||
unitView?: UnitView;
|
||||
}
|
||||
|
||||
@customElement("events-display")
|
||||
@@ -89,6 +91,7 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
[GameUpdateType.BrokeAlliance, (u) => this.onBrokeAllianceEvent(u)],
|
||||
[GameUpdateType.TargetPlayer, (u) => this.onTargetPlayerEvent(u)],
|
||||
[GameUpdateType.Emoji, (u) => this.onEmojiMessageEvent(u)],
|
||||
[GameUpdateType.UnitIncoming, (u) => this.onUnitIncomingEvent(u)],
|
||||
]);
|
||||
|
||||
constructor() {
|
||||
@@ -424,6 +427,25 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
onUnitIncomingEvent(event: UnitIncomingUpdate) {
|
||||
const myPlayer = this.game.playerByClientID(this.clientID);
|
||||
|
||||
if (!myPlayer || myPlayer.smallID() !== event.playerID) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unitView = this.game.unit(event.unitID);
|
||||
|
||||
this.addEvent({
|
||||
description: event.message,
|
||||
type: event.messageType,
|
||||
unsafeDescription: false,
|
||||
highlight: true,
|
||||
createdAt: this.game.ticks(),
|
||||
unitView: unitView,
|
||||
});
|
||||
}
|
||||
|
||||
private getMessageTypeClasses(type: MessageType): string {
|
||||
switch (type) {
|
||||
case MessageType.SUCCESS:
|
||||
@@ -651,7 +673,15 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
>
|
||||
${this.getEventDescription(event)}
|
||||
</button>`
|
||||
: this.getEventDescription(event)}
|
||||
: event.unitView
|
||||
? html`<button
|
||||
@click=${() => {
|
||||
this.emitGoToUnitEvent(event.unitView);
|
||||
}}
|
||||
>
|
||||
${this.getEventDescription(event)}
|
||||
</button>`
|
||||
: this.getEventDescription(event)}
|
||||
${event.buttons
|
||||
? html`
|
||||
<div class="flex flex-wrap gap-1.5 mt-1">
|
||||
|
||||
@@ -6,6 +6,9 @@ export const preprodConfig = new (class extends DefaultServerConfig {
|
||||
return GameEnv.Preprod;
|
||||
}
|
||||
numWorkers(): number {
|
||||
if (process.env.SUBDOMAIN !== "main") {
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
jwtAudience(): string {
|
||||
|
||||
@@ -81,7 +81,8 @@ export class MirvExecution implements Execution {
|
||||
this.separateDst = this.mg.ref(x, y);
|
||||
this.pathFinder.computeControlPoints(spawn, this.separateDst);
|
||||
|
||||
this.mg.displayMessage(
|
||||
this.mg.displayIncomingUnit(
|
||||
this.nuke.id(),
|
||||
`⚠️⚠️⚠️ ${this.player.name()} - MIRV INBOUND ⚠️⚠️⚠️`,
|
||||
MessageType.ERROR,
|
||||
this.targetPlayer.id(),
|
||||
|
||||
@@ -119,14 +119,16 @@ export class NukeExecution implements Execution {
|
||||
if (this.mg.hasOwner(this.dst)) {
|
||||
const target = this.mg.owner(this.dst) as Player;
|
||||
if (this.type === UnitType.AtomBomb) {
|
||||
this.mg.displayMessage(
|
||||
this.mg.displayIncomingUnit(
|
||||
this.nuke.id(),
|
||||
`${this.player.name()} - atom bomb inbound`,
|
||||
MessageType.ERROR,
|
||||
target.id(),
|
||||
);
|
||||
}
|
||||
if (this.type === UnitType.HydrogenBomb) {
|
||||
this.mg.displayMessage(
|
||||
this.mg.displayIncomingUnit(
|
||||
this.nuke.id(),
|
||||
`${this.player.name()} - hydrogen bomb inbound`,
|
||||
MessageType.ERROR,
|
||||
target.id(),
|
||||
@@ -142,7 +144,7 @@ export class NukeExecution implements Execution {
|
||||
);
|
||||
}
|
||||
|
||||
// after sending an nuke set the missilesilo on cooldown
|
||||
// after sending a nuke set the missilesilo on cooldown
|
||||
const silo = this.player
|
||||
.units(UnitType.MissileSilo)
|
||||
.find((silo) => silo.tile() === spawn);
|
||||
|
||||
@@ -67,15 +67,6 @@ export class TransportShipExecution implements Execution {
|
||||
|
||||
this.attacker = mg.player(this.attackerID);
|
||||
|
||||
// Notify the target player about the incoming naval invasion
|
||||
if (this.targetID && this.targetID !== mg.terraNullius().id()) {
|
||||
mg.displayMessage(
|
||||
`Naval invasion incoming from ${this.attacker.displayName()}`,
|
||||
MessageType.WARN,
|
||||
this.targetID,
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
this.attacker.units(UnitType.TransportShip).length >=
|
||||
mg.config().boatMaxNumber()
|
||||
@@ -145,6 +136,16 @@ export class TransportShipExecution implements Execution {
|
||||
this.boat = this.attacker.buildUnit(UnitType.TransportShip, this.src, {
|
||||
troops: this.troops,
|
||||
});
|
||||
|
||||
// Notify the target player about the incoming naval invasion
|
||||
if (this.targetID && this.targetID !== mg.terraNullius().id()) {
|
||||
mg.displayIncomingUnit(
|
||||
this.boat.id(),
|
||||
`Naval invasion incoming from ${this.attacker.displayName()}`,
|
||||
MessageType.WARN,
|
||||
this.targetID,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
tick(ticks: number) {
|
||||
|
||||
@@ -545,6 +545,12 @@ export interface Game extends GameMap {
|
||||
type: MessageType,
|
||||
playerID: PlayerID | null,
|
||||
): void;
|
||||
displayIncomingUnit(
|
||||
unitID: number,
|
||||
message: string,
|
||||
type: MessageType,
|
||||
playerID: PlayerID,
|
||||
): void;
|
||||
|
||||
displayChat(
|
||||
message: string,
|
||||
|
||||
@@ -635,6 +635,24 @@ export class GameImpl implements Game {
|
||||
recipient: recipient,
|
||||
});
|
||||
}
|
||||
|
||||
displayIncomingUnit(
|
||||
unitID: number,
|
||||
message: string,
|
||||
type: MessageType,
|
||||
playerID: PlayerID,
|
||||
): void {
|
||||
const id = this.player(playerID).smallID();
|
||||
|
||||
this.addUpdate({
|
||||
type: GameUpdateType.UnitIncoming,
|
||||
unitID: unitID,
|
||||
message: message,
|
||||
messageType: type,
|
||||
playerID: id,
|
||||
});
|
||||
}
|
||||
|
||||
addUnit(u: Unit) {
|
||||
this.unitGrid.addUnit(u);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export enum GameUpdateType {
|
||||
Emoji,
|
||||
Win,
|
||||
Hash,
|
||||
UnitIncoming,
|
||||
}
|
||||
|
||||
export type GameUpdate =
|
||||
@@ -53,7 +54,8 @@ export type GameUpdate =
|
||||
| TargetPlayerUpdate
|
||||
| EmojiUpdate
|
||||
| WinUpdate
|
||||
| HashUpdate;
|
||||
| HashUpdate
|
||||
| UnitIncomingUpdate;
|
||||
|
||||
export interface TileUpdateWrapper {
|
||||
type: GameUpdateType.Tile;
|
||||
@@ -182,3 +184,11 @@ export interface HashUpdate {
|
||||
tick: Tick;
|
||||
hash: number;
|
||||
}
|
||||
|
||||
export interface UnitIncomingUpdate {
|
||||
type: GameUpdateType.UnitIncoming;
|
||||
unitID: number;
|
||||
message: string;
|
||||
messageType: MessageType;
|
||||
playerID: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user