Changed consolex to console logging (#1036)

## Description:
Changed from consolex to console
## 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:

@qqkedsi
This commit is contained in:
falc
2025-06-10 16:10:47 -07:00
committed by evanpelle
parent 8912e4a68c
commit e952c122b0
42 changed files with 104 additions and 197 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import { Execution, Game, Player, PlayerID, UnitType } from "../game/Game";
export class BoatRetreatExecution implements Execution {
@@ -33,7 +32,7 @@ export class BoatRetreatExecution implements Execution {
);
if (!unit) {
consolex.warn(`Didn't find outgoing boat with id ${this.unitID}`);
console.warn(`Didn't find outgoing boat with id ${this.unitID}`);
this.active = false;
return;
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import { Game, PlayerInfo, PlayerType } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom";
@@ -22,7 +21,7 @@ export class BotSpawner {
let tries = 0;
while (this.bots.length < numBots) {
if (tries > 10000) {
consolex.log("too many retries while spawning bots, giving up");
console.log("too many retries while spawning bots, giving up");
return this.bots;
}
const botName = this.randomBotName();
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -34,7 +33,7 @@ export class CityExecution implements Execution {
if (this.city === null) {
const spawnTile = this.player.canBuild(UnitType.City, this.tile);
if (spawnTile === false) {
consolex.warn("cannot build city");
console.warn("cannot build city");
this.active = false;
return;
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -55,7 +54,7 @@ export class ConstructionExecution implements Execution {
}
const spawnTile = this.player.canBuild(this.constructionType, this.tile);
if (spawnTile === false) {
consolex.warn(`cannot build ${this.constructionType}`);
console.warn(`cannot build ${this.constructionType}`);
this.active = false;
return;
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -63,7 +62,7 @@ export class DefensePostExecution implements Execution {
if (this.post === null) {
const spawnTile = this.player.canBuild(UnitType.DefensePost, this.tile);
if (spawnTile === false) {
consolex.warn("cannot build Defense Post");
console.warn("cannot build Defense Post");
this.active = false;
return;
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import { Execution, Game, Gold, Player, PlayerID } from "../game/Game";
export class DonateGoldExecution implements Execution {
@@ -40,7 +39,7 @@ export class DonateGoldExecution implements Execution {
) {
this.recipient.updateRelation(this.sender, 50);
} else {
consolex.warn(
console.warn(
`cannot send gold from ${this.sender.name()} to ${this.recipient.name()}`,
);
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import { Execution, Game, Player, PlayerID } from "../game/Game";
export class DonateTroopsExecution implements Execution {
@@ -43,7 +42,7 @@ export class DonateTroopsExecution implements Execution {
) {
this.recipient.updateRelation(this.sender, 50);
} else {
consolex.warn(
console.warn(
`cannot send troops from ${this.sender} to ${this.recipient}`,
);
}
+2 -3
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
AllPlayers,
Execution,
@@ -43,7 +42,7 @@ export class EmojiExecution implements Execution {
tick(ticks: number): void {
const emojiString = flattenedEmojiTable[this.emoji];
if (emojiString === undefined) {
consolex.warn(
console.warn(
`cannot send emoji ${this.emoji} from ${this.requestor} to ${this.recipient}`,
);
} else if (this.requestor.canSendEmoji(this.recipient)) {
@@ -56,7 +55,7 @@ export class EmojiExecution implements Execution {
this.recipient.updateRelation(this.requestor, -100);
}
} else {
consolex.warn(
console.warn(
`cannot send emoji from ${this.requestor} to ${this.recipient}`,
);
}
+2 -3
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Cell,
Difficulty,
@@ -117,7 +116,7 @@ export class FakeHumanExecution implements Execution {
if (this.mg.inSpawnPhase()) {
const rl = this.randomLand();
if (rl === null) {
consolex.warn(`cannot spawn ${this.nation.playerInfo.name}`);
console.warn(`cannot spawn ${this.nation.playerInfo.name}`);
return;
}
this.mg.addExecution(new SpawnExecution(this.nation.playerInfo, rl));
@@ -488,7 +487,7 @@ export class FakeHumanExecution implements Execution {
}
const canBuild = this.player.canBuild(UnitType.Warship, targetTile);
if (canBuild === false) {
consolex.warn("cannot spawn destroyer");
console.warn("cannot spawn destroyer");
return false;
}
this.mg.addExecution(
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -64,7 +63,7 @@ export class MirvExecution implements Execution {
if (this.nuke === null) {
const spawn = this.player.canBuild(UnitType.MIRV, this.dst);
if (spawn === false) {
consolex.warn(`cannot build MIRV`);
console.warn(`cannot build MIRV`);
this.active = false;
return;
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -38,7 +37,7 @@ export class MissileSiloExecution implements Execution {
if (this.silo === null) {
const spawn = this.player.canBuild(UnitType.MissileSilo, this.tile);
if (spawn === false) {
consolex.warn(
console.warn(
`player ${this.player} cannot build missile silo at ${this.tile}`,
);
this.active = false;
+2 -3
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -109,7 +108,7 @@ export class NukeExecution implements Execution {
if (this.nuke === null) {
const spawn = this.src ?? this.player.canBuild(this.type, this.dst);
if (spawn === false) {
consolex.warn(`cannot build Nuke`);
console.warn(`cannot build Nuke`);
this.active = false;
return;
}
@@ -161,7 +160,7 @@ export class NukeExecution implements Execution {
// make the nuke unactive if it was intercepted
if (!this.nuke.isActive()) {
consolex.log(`Nuke destroyed before reaching target`);
console.log(`Nuke destroyed before reaching target`);
this.active = false;
return;
}
+1 -2
View File
@@ -1,6 +1,5 @@
import { renderNumber } from "../../client/Utils";
import { Config } from "../configuration/Config";
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -116,7 +115,7 @@ export class PlayerExecution implements Execution {
this.removeClusters();
const end = performance.now();
if (end - start > 1000) {
consolex.log(`player ${this.player.name()}, took ${end - start}ms`);
console.log(`player ${this.player.name()}, took ${end - start}ms`);
}
}
}
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -43,7 +42,7 @@ export class PortExecution implements Execution {
const player = this.mg.player(this._owner);
const spawn = player.canBuild(UnitType.Port, tile);
if (spawn === false) {
consolex.warn(`player ${player} cannot build port at ${this.tile}`);
console.warn(`player ${player} cannot build port at ${this.tile}`);
this.active = false;
return;
}
+3 -4
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import { Execution, Game, Player, PlayerID } from "../game/Game";
export class QuickChatExecution implements Execution {
@@ -18,12 +17,12 @@ export class QuickChatExecution implements Execution {
init(mg: Game, ticks: number): void {
this.mg = mg;
if (!mg.hasPlayer(this.senderID)) {
consolex.warn(`QuickChatExecution: sender ${this.senderID} not found`);
console.warn(`QuickChatExecution: sender ${this.senderID} not found`);
this.active = false;
return;
}
if (!mg.hasPlayer(this.recipientID)) {
consolex.warn(
console.warn(
`QuickChatExecution: recipient ${this.recipientID} not found`,
);
this.active = false;
@@ -55,7 +54,7 @@ export class QuickChatExecution implements Execution {
this.recipient.name(),
);
consolex.log(
console.log(
`[QuickChat] ${this.sender.name}${this.recipient.name}: ${message}`,
);
+1 -2
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -102,7 +101,7 @@ export class SAMLauncherExecution implements Execution {
}
const spawnTile = this.player.canBuild(UnitType.SAMLauncher, this.tile);
if (spawnTile === false) {
consolex.warn("cannot build SAM Launcher");
console.warn("cannot build SAM Launcher");
this.active = false;
return;
}
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import { Execution, Game, Player, PlayerID } from "../game/Game";
export class SetTargetTroopRatioExecution implements Execution {
@@ -22,7 +21,7 @@ export class SetTargetTroopRatioExecution implements Execution {
tick(ticks: number): void {
if (this.targetTroopsRatio < 0 || this.targetTroopsRatio > 1) {
consolex.warn(
console.warn(
`target troop ratio of ${this.targetTroopsRatio} for player ${this.player} invalid`,
);
} else {
+2 -3
View File
@@ -1,5 +1,4 @@
import { renderNumber } from "../../client/Utils";
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -41,7 +40,7 @@ export class TradeShipExecution implements Execution {
this.srcPort.tile(),
);
if (spawn === false) {
consolex.warn(`cannot build trade ship`);
console.warn(`cannot build trade ship`);
this.active = false;
return;
}
@@ -115,7 +114,7 @@ export class TradeShipExecution implements Execution {
this.tradeShip.move(result.tile);
break;
case PathFindResultType.PathNotFound:
consolex.warn("captured trade ship cannot find route");
console.warn("captured trade ship cannot find route");
if (this.tradeShip.isActive()) {
this.tradeShip.delete(false);
}
+3 -4
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -100,7 +99,7 @@ export class TransportShipExecution implements Execution {
this.dst = targetTransportTile(this.mg, this.ref);
if (this.dst === null) {
consolex.warn(
console.warn(
`${this.attacker} cannot send ship to ${this.target}, cannot find attack tile`,
);
this.active = false;
@@ -112,7 +111,7 @@ export class TransportShipExecution implements Execution {
this.dst,
);
if (closestTileSrc === false) {
consolex.warn(`can't build transport ship`);
console.warn(`can't build transport ship`);
this.active = false;
return;
}
@@ -215,7 +214,7 @@ export class TransportShipExecution implements Execution {
break;
case PathFindResultType.PathNotFound:
// TODO: add to poisoned port list
consolex.warn(`path not found to dst`);
console.warn(`path not found to dst`);
this.attacker.addTroops(this.troops);
this.boat.delete(false);
this.active = false;
+2 -3
View File
@@ -1,4 +1,3 @@
import { consolex } from "../Consolex";
import {
Execution,
Game,
@@ -192,7 +191,7 @@ export class WarshipExecution implements Execution {
this.warship.touch();
break;
case PathFindResultType.PathNotFound:
consolex.log(`path not found to target`);
console.log(`path not found to target`);
break;
}
}
@@ -222,7 +221,7 @@ export class WarshipExecution implements Execution {
this.warship.touch();
return;
case PathFindResultType.PathNotFound:
consolex.warn(`path not found to target tile`);
console.warn(`path not found to target tile`);
this.warship.setTargetTile(undefined);
break;
}
@@ -1,4 +1,3 @@
import { consolex } from "../../Consolex";
import { Execution, Game, Player, PlayerID } from "../../game/Game";
export class AllianceRequestExecution implements Execution {
@@ -36,9 +35,9 @@ export class AllianceRequestExecution implements Execution {
throw new Error("Not initialized");
}
if (this.requestor.isFriendly(this.recipient)) {
consolex.warn("already allied");
console.warn("already allied");
} else if (!this.requestor.canSendAllianceRequest(this.recipient)) {
consolex.warn("recent or pending alliance request");
console.warn("recent or pending alliance request");
} else {
this.requestor.createAllianceRequest(this.recipient);
}
@@ -1,4 +1,3 @@
import { consolex } from "../../Consolex";
import { Execution, Game, Player, PlayerID } from "../../game/Game";
export class AllianceRequestReplyExecution implements Execution {
@@ -36,13 +35,13 @@ export class AllianceRequestReplyExecution implements Execution {
throw new Error("Not initialized");
}
if (this.requestor.isFriendly(this.recipient)) {
consolex.warn("already allied");
console.warn("already allied");
} else {
const request = this.requestor
.outgoingAllianceRequests()
.find((ar) => ar.recipient() === this.recipient);
if (request === undefined) {
consolex.warn("no alliance request found");
console.warn("no alliance request found");
} else {
if (this.accept) {
request.accept();
@@ -1,4 +1,3 @@
import { consolex } from "../../Consolex";
import { Execution, Game, Player, PlayerID } from "../../game/Game";
export class BreakAllianceExecution implements Execution {
@@ -42,7 +41,7 @@ export class BreakAllianceExecution implements Execution {
}
const alliance = this.requestor.allianceWith(this.recipient);
if (alliance === null) {
consolex.warn("cant break alliance, not allied");
console.warn("cant break alliance, not allied");
} else {
this.requestor.breakAlliance(alliance);
this.recipient.updateRelation(this.requestor, -200);