From c13bb1eef9a5b32bbcbebbc10245ea05cf6e639e Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 11 Dec 2024 16:49:23 -0800 Subject: [PATCH] don't display unit deleted message when tranpsort ship lands --- TODO.txt | 6 +++++- src/core/Util.ts | 7 ++++--- src/core/configuration/DevConfig.ts | 16 +++++----------- src/core/execution/NukeExecution.ts | 2 +- src/core/execution/TransportShipExecution.ts | 6 +++--- src/core/game/Game.ts | 2 +- src/core/game/UnitImpl.ts | 4 ++-- 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/TODO.txt b/TODO.txt index fcbb1be99..9c4f70c81 100644 --- a/TODO.txt +++ b/TODO.txt @@ -230,9 +230,14 @@ * only check islands/clusters when being attacked DONE 12/10/2024 * only calculate name if tile changes DONE 12/10/2024 * store in BigQuery DONE 12/10/2024 +* remove dash from game id DONE 12/11/2024 +* bug: transport display event when it lands DONE 12/11/2024 +* bug: name not updating location in spawn phase +* have crash print stacktrace * allow longer names and allow them to be displayed in the Rank UI not be cut * make boats work on lakes (& oceania) * record game winner +* record player ip in bigquery * add panama canal NA * repaint canvas after tab away to prevent blank screen * on mobile can't click away from build menu @@ -241,7 +246,6 @@ * remove alliance when player dies * put delay on adjust troop ratio to reduce number of messages * make clientID & playerID smaller -* remove dash from game id * pause button in single player * when hovering over another player have the name not appear ontop of the exit cross * have a visual thing of who your attacking and how many boats you sent diff --git a/src/core/Util.ts b/src/core/Util.ts index 813f0b143..8851284da 100644 --- a/src/core/Util.ts +++ b/src/core/Util.ts @@ -6,7 +6,7 @@ import DOMPurify from 'dompurify'; import { Cell, Game, Player, TerraNullius, Tile, Unit } from "./game/Game"; import { number } from 'zod'; import { GameConfig, GameID, GameRecord, Turn } from './Schemas'; -import { nanoid } from 'nanoid'; +import { customAlphabet, nanoid } from 'nanoid'; export function manhattanDist(c1: Cell, c2: Cell): number { return Math.abs(c1.x - c2.x) + Math.abs(c1.y - c2.y); @@ -262,6 +262,7 @@ export function assertNever(x: never): never { throw new Error('Unexpected value: ' + x); } -export function generateGameID(): string { - return nanoid(8) +export function generateGameID(): GameID { + const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 8) + return nanoid() } \ No newline at end of file diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index dc15f27d3..5ef7f905f 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -8,16 +8,13 @@ export const devConfig = new class extends DefaultConfig { info.cost = (p: Player) => oldCost(p) / 1000000 return info } - maxUnitCost(): number { - return 10000 - } percentageTilesOwnedToWin(): number { return 95 } numSpawnPhaseTurns(gameType: GameType): number { - return 40 - // return 100 + // return 40 + return 1000 } gameCreationRate(): number { return 10 * 1000 @@ -25,12 +22,9 @@ export const devConfig = new class extends DefaultConfig { lobbyLifetime(): number { return 10 * 1000 } - turnIntervalMs(): number { - return 100 - } - tradeShipSpawnRate(): number { - return 10 - } + // tradeShipSpawnRate(): number { + // return 10 + // } boatMaxDistance(): number { return 5000 } diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index 4b7083a08..5f904f560 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -111,7 +111,7 @@ export class NukeExecution implements Execution { // .filter(b => euclideanDist(this.cell, b.tile().cell()) < this.magnitude + 50) // .forEach(b => b.delete()) this.active = false - this.nuke.delete() + this.nuke.delete(false) } owner(): MutablePlayer { diff --git a/src/core/execution/TransportShipExecution.ts b/src/core/execution/TransportShipExecution.ts index bc0569d75..f1ce4d19f 100644 --- a/src/core/execution/TransportShipExecution.ts +++ b/src/core/execution/TransportShipExecution.ts @@ -102,7 +102,7 @@ export class TransportShipExecution implements Execution { case PathFindResultType.Completed: if (this.dst.owner() == this.attacker) { this.attacker.addTroops(this.troops) - this.boat.delete() + this.boat.delete(false) this.active = false return } @@ -114,7 +114,7 @@ export class TransportShipExecution implements Execution { new AttackExecution(this.troops, this.attacker.id(), this.targetID, this.dst.cell(), null, false) ) } - this.boat.delete() + this.boat.delete(false) this.active = false return case PathFindResultType.NextTile: @@ -125,7 +125,7 @@ export class TransportShipExecution implements Execution { case PathFindResultType.PathNotFound: // TODO: add to poisoned port list console.warn(`path not found tot dst`) - this.boat.delete() + this.boat.delete(false) this.active = false return diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 5d85cbe90..67bfac745 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -199,7 +199,7 @@ export interface MutableUnit extends Unit { move(tile: Tile): void owner(): MutablePlayer setTroops(troops: number): void - delete(): void + delete(displayerMessage?: boolean): void } export interface TerraNullius { diff --git a/src/core/game/UnitImpl.ts b/src/core/game/UnitImpl.ts index 85b34f548..5d5559dc5 100644 --- a/src/core/game/UnitImpl.ts +++ b/src/core/game/UnitImpl.ts @@ -57,14 +57,14 @@ export class UnitImpl implements MutableUnit { ) } - delete(): void { + delete(displayMessage: boolean = true): void { if (!this.isActive()) { throw new Error(`cannot delete ${this} not active`) } this._owner._units = this._owner._units.filter(b => b != this); this._active = false; this.g.fireUnitUpdateEvent(this, this._tile); - if (this.type() != UnitType.AtomBomb && this.type() != UnitType.HydrogenBomb) { + if (displayMessage) { this.g.displayMessage(`Your ${this.type()} was destroyed`, MessageType.ERROR, this.owner().id()) } }