mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 00:15:23 +00:00
format using prettier
This commit is contained in:
@@ -13,6 +13,7 @@ import { AllPlayers, PlayerActions } from "../../../core/game/Game";
|
||||
import { TileRef } from "../../../core/game/GameMap";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { flattenedEmojiTable } from "../../../core/Util";
|
||||
import Countries from "../../data/countries.json";
|
||||
import { CloseViewEvent, MouseUpEvent } from "../../InputHandler";
|
||||
import {
|
||||
SendAllianceRequestIntentEvent,
|
||||
@@ -26,7 +27,6 @@ import {
|
||||
import { renderNumber, renderTroops } from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
import { ChatModal } from "./ChatModal";
|
||||
import Countries from "../../data/countries.json";
|
||||
import { EmojiTable } from "./EmojiTable";
|
||||
import { Layer } from "./Layer";
|
||||
|
||||
@@ -247,7 +247,10 @@ export class PlayerPanel extends LitElement implements Layer {
|
||||
|
||||
//flag icon in the playerPanel
|
||||
const flagCode = other.cosmetics.flag;
|
||||
const country = typeof flagCode === "string" ? Countries.find((c) => c.code === flagCode) : undefined;
|
||||
const country =
|
||||
typeof flagCode === "string"
|
||||
? Countries.find((c) => c.code === flagCode)
|
||||
: undefined;
|
||||
const flagName = country?.name;
|
||||
|
||||
return html`
|
||||
@@ -295,7 +298,12 @@ export class PlayerPanel extends LitElement implements Layer {
|
||||
bg-opacity-50 bg-gray-700 text-opacity-90 text-white
|
||||
rounded text-sm lg:text-xl w-full"
|
||||
>
|
||||
${flagName} <img src="/flags/${flagCode}.svg" width=60 height=60>
|
||||
${flagName}
|
||||
<img
|
||||
src="/flags/${flagCode}.svg"
|
||||
width="60"
|
||||
height="60"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -149,7 +149,10 @@ export class RadialMenu implements Layer {
|
||||
.style("position", "absolute")
|
||||
.style("top", "50%")
|
||||
.style("left", "50%")
|
||||
.style("transition", `top ${this.config.menuTransitionDuration}ms ease, left ${this.config.menuTransitionDuration}ms ease`)
|
||||
.style(
|
||||
"transition",
|
||||
`top ${this.config.menuTransitionDuration}ms ease, left ${this.config.menuTransitionDuration}ms ease`,
|
||||
)
|
||||
.style("transform", "translate(-50%, -50%)")
|
||||
.style("pointer-events", "all")
|
||||
.on("click", (event) => this.hideRadialMenu());
|
||||
@@ -1053,13 +1056,17 @@ export class RadialMenu implements Layer {
|
||||
const vh = window.innerHeight;
|
||||
|
||||
// If the menu cannot fully fit on an axis, pin it to the viewport center on that axis.
|
||||
const clampedX = 2 * margin > vw ? vw / 2 : Math.min(Math.max(this.anchorX, margin), vw - margin);
|
||||
const clampedY = 2 * margin > vh ? vh / 2 : Math.min(Math.max(this.anchorY, margin), vh - margin);
|
||||
const clampedX =
|
||||
2 * margin > vw
|
||||
? vw / 2
|
||||
: Math.min(Math.max(this.anchorX, margin), vw - margin);
|
||||
const clampedY =
|
||||
2 * margin > vh
|
||||
? vh / 2
|
||||
: Math.min(Math.max(this.anchorY, margin), vh - margin);
|
||||
|
||||
const svgSel = this.menuElement.select("svg");
|
||||
svgSel
|
||||
.style("top", `${clampedY}px`)
|
||||
.style("left", `${clampedX}px`);
|
||||
svgSel.style("top", `${clampedY}px`).style("left", `${clampedX}px`);
|
||||
}
|
||||
|
||||
private handleResize = () => {
|
||||
|
||||
@@ -207,7 +207,9 @@ export class TeamStats extends LitElement implements Layer {
|
||||
this.requestUpdate();
|
||||
}}
|
||||
>
|
||||
${this.showUnits ? translateText("leaderboard.show_control") : translateText("leaderboard.show_units")}
|
||||
${this.showUnits
|
||||
? translateText("leaderboard.show_control")
|
||||
: translateText("leaderboard.show_units")}
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -474,7 +474,7 @@ export class FakeHumanExecution implements Execution {
|
||||
return bestTile;
|
||||
}
|
||||
|
||||
private * arraySampler<T>(a: T[], sampleSize = 50): Generator<T> {
|
||||
private *arraySampler<T>(a: T[], sampleSize = 50): Generator<T> {
|
||||
if (a.length <= sampleSize) {
|
||||
// Return all elements
|
||||
yield* a;
|
||||
@@ -495,7 +495,9 @@ export class FakeHumanExecution implements Execution {
|
||||
const mg = this.mg;
|
||||
const otherUnits = this.player.units(type);
|
||||
// Prefer spacing structures out of atom bomb range
|
||||
const borderSpacing = this.mg.config().nukeMagnitudes(UnitType.AtomBomb).outer;
|
||||
const borderSpacing = this.mg
|
||||
.config()
|
||||
.nukeMagnitudes(UnitType.AtomBomb).outer;
|
||||
const structureSpacing = borderSpacing * 2;
|
||||
switch (type) {
|
||||
case UnitType.Port:
|
||||
@@ -503,7 +505,9 @@ export class FakeHumanExecution implements Execution {
|
||||
let w = 0;
|
||||
|
||||
// Prefer to be far away from other structures of the same type
|
||||
const otherTiles: Set<TileRef> = new Set(otherUnits.map((u) => u.tile()));
|
||||
const otherTiles: Set<TileRef> = new Set(
|
||||
otherUnits.map((u) => u.tile()),
|
||||
);
|
||||
otherTiles.delete(tile);
|
||||
const closestOther = closestTwoTiles(mg, otherTiles, [tile]);
|
||||
if (closestOther !== null) {
|
||||
@@ -530,7 +534,9 @@ export class FakeHumanExecution implements Execution {
|
||||
}
|
||||
|
||||
// Prefer to be away from other structures of the same type
|
||||
const otherTiles: Set<TileRef> = new Set(otherUnits.map((u) => u.tile()));
|
||||
const otherTiles: Set<TileRef> = new Set(
|
||||
otherUnits.map((u) => u.tile()),
|
||||
);
|
||||
otherTiles.delete(tile);
|
||||
const closestOther = closestTwoTiles(mg, otherTiles, [tile]);
|
||||
if (closestOther !== null) {
|
||||
|
||||
Reference in New Issue
Block a user