diff --git a/TODO.txt b/TODO.txt index b992201da..f72741dd9 100644 --- a/TODO.txt +++ b/TODO.txt @@ -116,8 +116,9 @@ * UI: basic win condition & popup DONE 9/16/2024 * right click popup alliance option DONE 9/17/2024 * BUG: can't ally same person twice DONE 9/18/2024 -* break alliance makes you a traitor -* add traitor icon +* break alliance makes you a traitor DONE 9/18/2024 +* add traitor icon DONE 9/18/2024 +* make alliance icon * alert play when they become traitor * make fake humans easier * click alliance sends alliance request @@ -146,5 +147,5 @@ * add offline mode * REFACTOR: give terranullius an ID, game.player() returns terranullius * REFACTOR: ocean is considered TerraNullius ? - +* Make icons svgs testing webhook \ No newline at end of file diff --git a/resources/images/TraitorIcon.png b/resources/images/TraitorIcon.png new file mode 100644 index 000000000..23f5d252a Binary files /dev/null and b/resources/images/TraitorIcon.png differ diff --git a/resources/images/TraitorIcon2.png b/resources/images/TraitorIcon2.png new file mode 100644 index 000000000..d5f113f69 Binary files /dev/null and b/resources/images/TraitorIcon2.png differ diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index d9946e18b..bc0889674 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -6,6 +6,8 @@ import {Layer} from "./Layer" import {placeName} from "../NameBoxCalculator" import {TransformHandler} from "../TransformHandler" import {renderTroops} from "../Utils" +import traitorIcon from '../../../../resources/images/TraitorIcon.png'; + class RenderInfo { public isVisible = true @@ -27,10 +29,14 @@ export class NameLayer implements Layer { private rand = new PseudoRandom(10) private renders: RenderInfo[] = [] private seenPlayers: Set = new Set() + private traitorIconImage: HTMLImageElement; + constructor(private game: Game, private theme: Theme, private transformHandler: TransformHandler) { - + this.traitorIconImage = new Image(); + this.traitorIconImage.src = traitorIcon; } + shouldTransform(): boolean { return true } @@ -112,6 +118,20 @@ export class NameLayer implements Layer { const nameCenterX = Math.floor(render.location.x - this.game.width() / 2) const nameCenterY = Math.floor(render.location.y - this.game.height() / 2) + const iconSize = render.fontSize * 2; // Adjust size as needed + // const iconX = nameCenterX + render.fontSize * 2; // Position to the right of the name + // const iconY = nameCenterY - render.fontSize / 2; + + if (render.player.isTraitor() && this.traitorIconImage.complete) { + context.drawImage( + this.traitorIconImage, + nameCenterX - iconSize / 2, + nameCenterY - iconSize / 2, + iconSize, + iconSize + ); + } + context.textRendering = "optimizeSpeed"; context.font = `${render.fontSize}px ${this.theme.font()}`; diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 73269db88..39a1fa23a 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -111,7 +111,6 @@ export class AttackExecution implements Execution { } if (this.breakAlliance) { this.breakAlliance = false - alert('set player traitor') this._owner.breakAllianceWith(this.target as Player) } diff --git a/src/core/execution/BotExecution.ts b/src/core/execution/BotExecution.ts index 2727f36b5..fe3f88695 100644 --- a/src/core/execution/BotExecution.ts +++ b/src/core/execution/BotExecution.ts @@ -41,7 +41,11 @@ export class BotExecution implements Execution { } this.bot.incomingAllianceRequests().forEach(ar => { - ar.accept() + if (ar.requestor().isTraitor()) { + ar.reject() + } else { + ar.accept() + } }) if (this.neighborsTerraNullius) {