diff --git a/src/core/Util.ts b/src/core/Util.ts index c16ecd465..d74d27b11 100644 --- a/src/core/Util.ts +++ b/src/core/Util.ts @@ -270,12 +270,11 @@ export const emojiTable = [ ["↙️", "⬇️", "↘️", "❤️", "💔"], ["💰", "⚓", "⛵", "🏡", "🛡️"], ] as const; - -export type Emoji = (typeof emojiTable)[number][number]; - // 2d to 1d array export const flattenedEmojiTable = emojiTable.flat(); +export type Emoji = (typeof flattenedEmojiTable)[number]; + /** * JSON.stringify replacer function that converts bigint values to strings. */ diff --git a/src/core/execution/nation/structureSpawnTileValue.ts b/src/core/execution/nation/structureSpawnTileValue.ts index e1a716e7c..5c8edae45 100644 --- a/src/core/execution/nation/structureSpawnTileValue.ts +++ b/src/core/execution/nation/structureSpawnTileValue.ts @@ -30,7 +30,9 @@ export function structureSpawnTileValue( } // Prefer to be away from other structures of the same type - const otherTiles: Set = new Set(otherUnits.map((u) => u.tile())); + const otherTiles: Set = new Set( + otherUnits.map((u) => u.tile()), + ); otherTiles.delete(tile); const closestOther = closestTwoTiles(mg, otherTiles, [tile]); if (closestOther !== null) { @@ -47,7 +49,9 @@ export function structureSpawnTileValue( let w = 0; // Prefer to be away from other structures of the same type - const otherTiles: Set = new Set(otherUnits.map((u) => u.tile())); + const otherTiles: Set = new Set( + otherUnits.map((u) => u.tile()), + ); otherTiles.delete(tile); const closestOther = closestTwoTiles(mg, otherTiles, [tile]); if (closestOther !== null) { @@ -82,12 +86,15 @@ export function structureSpawnTileValue( neighbors.add(neighbor); } for (const neighbor of neighbors) { - w += borderSpacing * (Relation.Friendly - player.relation(neighbor)); + w += + borderSpacing * (Relation.Friendly - player.relation(neighbor)); } } // Prefer to be away from other structures of the same type - const otherTiles: Set = new Set(otherUnits.map((u) => u.tile())); + const otherTiles: Set = new Set( + otherUnits.map((u) => u.tile()), + ); otherTiles.delete(tile); const closestOther = closestTwoTiles(mg, otherTiles, [tile]); if (closestOther !== null) { @@ -125,7 +132,9 @@ export function structureSpawnTileValue( } // Prefer to be away from other structures of the same type - const otherTiles: Set = new Set(otherUnits.map((u) => u.tile())); + const otherTiles: Set = new Set( + otherUnits.map((u) => u.tile()), + ); otherTiles.delete(tile); const closestOther = closestTwoTiles(mg, otherTiles, [tile]); if (closestOther !== null) { diff --git a/src/core/execution/utils/BotBehavior.ts b/src/core/execution/utils/BotBehavior.ts index 0774ee102..b3b9378f7 100644 --- a/src/core/execution/utils/BotBehavior.ts +++ b/src/core/execution/utils/BotBehavior.ts @@ -13,33 +13,17 @@ import { AllianceExtensionExecution } from "../alliance/AllianceExtensionExecuti import { AttackExecution } from "../AttackExecution"; import { EmojiExecution } from "../EmojiExecution"; -const emojiId = (e: typeof flattenedEmojiTable[number]) => flattenedEmojiTable.indexOf(e); -const EMOJI_ASSIST_ACCEPT = ([ - "👍", - "⛵", - "🤝", - "🎯", -] as const).map(emojiId); -const EMOJI_RELATION_TOO_LOW = ([ - "🥱", - "🤦‍♂️", -] as const).map(emojiId); -const EMOJI_TARGET_ME = ([ - "🥺", - "💀", -] as const).map(emojiId); -const EMOJI_TARGET_ALLY = ([ - "🕊️", - "👎", -] as const).map(emojiId); -export const EMOJI_HECKLE = ([ - "🤡", - "😡", -] as const).map(emojiId); +const emojiId = (e: (typeof flattenedEmojiTable)[number]) => + flattenedEmojiTable.indexOf(e); +const EMOJI_ASSIST_ACCEPT = (["👍", "⛵", "🤝", "🎯"] as const).map(emojiId); +const EMOJI_RELATION_TOO_LOW = (["🥱", "🤦‍♂️"] as const).map(emojiId); +const EMOJI_TARGET_ME = (["🥺", "💀"] as const).map(emojiId); +const EMOJI_TARGET_ALLY = (["🕊️", "👎"] as const).map(emojiId); +export const EMOJI_HECKLE = (["🤡", "😡"] as const).map(emojiId); export class BotBehavior { private enemy: Player | null = null; - private enemyUpdated: Tick; + private enemyUpdated: Tick | undefined; constructor( private random: PseudoRandom, @@ -98,7 +82,7 @@ export class BotBehavior { forgetOldEnemies() { // Forget old enemies - if (this.game.ticks() - this.enemyUpdated > 100) { + if (this.game.ticks() - (this.enemyUpdated ?? 0) > 100) { this.clearEnemy(); } }