mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:30:43 +00:00
Remove shield icon from bots (#986)
## Description: Bots have much different meta than nations or humans, so their defense number is misleading. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: <DISCORD USERNAME>
This commit is contained in:
@@ -10,7 +10,13 @@ import traitorIcon from "../../../../resources/images/TraitorIcon.svg";
|
||||
import { PseudoRandom } from "../../../core/PseudoRandom";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import { Theme } from "../../../core/configuration/Config";
|
||||
import { AllPlayers, Cell, nukeTypes, UnitType } from "../../../core/game/Game";
|
||||
import {
|
||||
AllPlayers,
|
||||
Cell,
|
||||
nukeTypes,
|
||||
PlayerType,
|
||||
UnitType,
|
||||
} from "../../../core/game/Game";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { createCanvas, renderNumber, renderTroops } from "../../Utils";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
@@ -214,27 +220,29 @@ export class NameLayer implements Layer {
|
||||
troopsDiv.style.marginTop = "-5%";
|
||||
element.appendChild(troopsDiv);
|
||||
|
||||
const shieldDiv = document.createElement("div");
|
||||
shieldDiv.classList.add("player-shield");
|
||||
shieldDiv.style.zIndex = "3";
|
||||
shieldDiv.style.marginTop = "-5%";
|
||||
shieldDiv.style.display = "flex";
|
||||
shieldDiv.style.alignItems = "center";
|
||||
shieldDiv.style.gap = "0px";
|
||||
const shieldImg = document.createElement("img");
|
||||
shieldImg.src = this.shieldIconImage.src;
|
||||
shieldImg.style.width = "16px";
|
||||
shieldImg.style.height = "16px";
|
||||
if (player.type() !== PlayerType.Bot) {
|
||||
const shieldDiv = document.createElement("div");
|
||||
shieldDiv.classList.add("player-shield");
|
||||
shieldDiv.style.zIndex = "3";
|
||||
shieldDiv.style.marginTop = "-5%";
|
||||
shieldDiv.style.display = "flex";
|
||||
shieldDiv.style.alignItems = "center";
|
||||
shieldDiv.style.gap = "0px";
|
||||
const shieldImg = document.createElement("img");
|
||||
shieldImg.src = this.shieldIconImage.src;
|
||||
shieldImg.style.width = "16px";
|
||||
shieldImg.style.height = "16px";
|
||||
|
||||
const shieldSpan = document.createElement("span");
|
||||
shieldSpan.textContent = "0";
|
||||
shieldSpan.style.color = "black";
|
||||
shieldSpan.style.fontSize = "10px";
|
||||
shieldSpan.style.marginTop = "-2px";
|
||||
const shieldSpan = document.createElement("span");
|
||||
shieldSpan.textContent = "0";
|
||||
shieldSpan.style.color = "black";
|
||||
shieldSpan.style.fontSize = "10px";
|
||||
shieldSpan.style.marginTop = "-2px";
|
||||
|
||||
shieldDiv.appendChild(shieldImg);
|
||||
shieldDiv.appendChild(shieldSpan);
|
||||
element.appendChild(shieldDiv);
|
||||
shieldDiv.appendChild(shieldImg);
|
||||
shieldDiv.appendChild(shieldSpan);
|
||||
element.appendChild(shieldDiv);
|
||||
}
|
||||
|
||||
// Start off invisible so it doesn't flash at 0,0
|
||||
element.style.display = "none";
|
||||
@@ -303,11 +311,10 @@ export class NameLayer implements Layer {
|
||||
const density = renderNumber(
|
||||
render.player.troops() / render.player.numTilesOwned(),
|
||||
);
|
||||
const shieldDiv = render.element.querySelector(
|
||||
".player-shield",
|
||||
) as HTMLDivElement;
|
||||
const shieldImg = shieldDiv.querySelector("img");
|
||||
const shieldNumber = shieldDiv.querySelector("span");
|
||||
const shieldDiv: HTMLDivElement | null =
|
||||
render.element.querySelector(".player-shield");
|
||||
const shieldImg = shieldDiv?.querySelector("img");
|
||||
const shieldNumber = shieldDiv?.querySelector("span");
|
||||
if (shieldImg) {
|
||||
shieldImg.style.width = `${render.fontSize * 0.8}px`;
|
||||
shieldImg.style.height = `${render.fontSize * 0.8}px`;
|
||||
|
||||
Reference in New Issue
Block a user