Nations send emoji when declining assistance requests (#1911)

## Description:

Nations will now send emoji when declining assistance requests.

## 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
This commit is contained in:
Scott Anderson
2025-08-26 17:57:40 -04:00
committed by GitHub
parent 1a83531193
commit be447a6774
3 changed files with 36 additions and 16 deletions
+3 -3
View File
@@ -280,7 +280,7 @@ export function createRandomName(
return randomName;
}
export const emojiTable: string[][] = [
export const emojiTable = [
["😀", "😊", "🥰", "😇", "😎"],
["😞", "🥺", "😭", "😱", "😡"],
["😈", "🤡", "🖕", "🥱", "🤦‍♂️"],
@@ -292,9 +292,9 @@ export const emojiTable: string[][] = [
["⬅️", "🎯", "➡️", "🥈", "🥉"],
["↙️", "⬇️", "↘️", "❤️", "💔"],
["💰", "⚓", "⛵", "🏡", "🛡️"],
];
] as const;
// 2d to 1d array
export const flattenedEmojiTable: string[] = emojiTable.flat();
export const flattenedEmojiTable = emojiTable.flat();
/**
* JSON.stringify replacer function that converts bigint values to strings.
+3 -5
View File
@@ -1,3 +1,4 @@
import { BotBehavior, EMOJI_HECKLE } from "./utils/BotBehavior";
import {
Cell,
Difficulty,
@@ -15,8 +16,7 @@ import {
UnitType,
} from "../game/Game";
import { TileRef, euclDistFN, manhattanDistFN } from "../game/GameMap";
import { calculateBoundingBox, flattenedEmojiTable, simpleHash } from "../Util";
import { BotBehavior } from "./utils/BotBehavior";
import { calculateBoundingBox, simpleHash } from "../Util";
import { ConstructionExecution } from "./ConstructionExecution";
import { EmojiExecution } from "./EmojiExecution";
import { GameID } from "../Schemas";
@@ -43,7 +43,6 @@ export class FakeHumanExecution implements Execution {
private readonly lastEmojiSent = new Map<Player, Tick>();
private readonly lastNukeSent: [Tick, TileRef][] = [];
private readonly embargoMalusApplied = new Set<PlayerID>();
private readonly heckleEmoji: number[];
constructor(
gameID: GameID,
@@ -57,7 +56,6 @@ export class FakeHumanExecution implements Execution {
this.triggerRatio = this.random.nextInt(60, 90) / 100;
this.reserveRatio = this.random.nextInt(30, 60) / 100;
this.expandRatio = this.random.nextInt(15, 25) / 100;
this.heckleEmoji = ["🤡", "😡"].map((e) => flattenedEmojiTable.indexOf(e));
}
init(mg: Game) {
@@ -281,7 +279,7 @@ export class FakeHumanExecution implements Execution {
new EmojiExecution(
this.player,
enemy.id(),
this.random.randElement(this.heckleEmoji),
this.random.randElement(EMOJI_HECKLE),
),
);
}
+30 -8
View File
@@ -13,12 +13,34 @@ import { EmojiExecution } from "../EmojiExecution";
import { PseudoRandom } from "../../PseudoRandom";
import { flattenedEmojiTable } from "../../Util";
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 | undefined;
private readonly assistAcceptEmoji = flattenedEmojiTable.indexOf("👍");
constructor(
private readonly random: PseudoRandom,
private readonly game: Game,
@@ -111,26 +133,26 @@ export class BotBehavior {
}
assistAllies() {
outer: for (const ally of this.player.allies()) {
for (const ally of this.player.allies()) {
if (ally.targets().length === 0) continue;
if (this.player.relation(ally) < Relation.Friendly) {
// this.emoji(ally, "🤦");
this.emoji(ally, this.random.randElement(EMOJI_RELATION_TOO_LOW));
continue;
}
for (const target of ally.targets()) {
if (target === this.player) {
// this.emoji(ally, "💀");
this.emoji(ally, this.random.randElement(EMOJI_TARGET_ME));
continue;
}
if (this.player.isAlliedWith(target)) {
// this.emoji(ally, "👎");
this.emoji(ally, this.random.randElement(EMOJI_TARGET_ALLY));
continue;
}
// All checks passed, assist them
this.player.updateRelation(ally, -20);
this.setNewEnemy(target);
this.emoji(ally, this.assistAcceptEmoji);
break outer;
this.emoji(ally, this.random.randElement(EMOJI_ASSIST_ACCEPT));
return;
}
}
}