Skip to content

Commit d05a871

Browse files
committed
More nation emoji
1 parent db6eeb8 commit d05a871

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

src/core/execution/FakeHumanExecution.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BotBehavior, EMOJI_HECKLE } from "./utils/BotBehavior";
12
import {
23
Cell,
34
Difficulty,
@@ -15,8 +16,7 @@ import {
1516
UnitType,
1617
} from "../game/Game";
1718
import { TileRef, euclDistFN, manhattanDistFN } from "../game/GameMap";
18-
import { calculateBoundingBox, flattenedEmojiTable, simpleHash } from "../Util";
19-
import { BotBehavior } from "./utils/BotBehavior";
19+
import { calculateBoundingBox, simpleHash } from "../Util";
2020
import { ConstructionExecution } from "./ConstructionExecution";
2121
import { EmojiExecution } from "./EmojiExecution";
2222
import { GameID } from "../Schemas";
@@ -42,7 +42,6 @@ export class FakeHumanExecution implements Execution {
4242
private readonly lastEmojiSent = new Map<Player, Tick>();
4343
private readonly lastNukeSent: [Tick, TileRef][] = [];
4444
private readonly embargoMalusApplied = new Set<PlayerID>();
45-
private readonly heckleEmoji: number[];
4645

4746
constructor(
4847
gameID: GameID,
@@ -56,7 +55,6 @@ export class FakeHumanExecution implements Execution {
5655
this.triggerRatio = this.random.nextInt(60, 90) / 100;
5756
this.reserveRatio = this.random.nextInt(30, 60) / 100;
5857
this.expandRatio = this.random.nextInt(15, 25) / 100;
59-
this.heckleEmoji = ["🤡", "😡"].map((e) => flattenedEmojiTable.indexOf(e));
6058
}
6159

6260
init(mg: Game) {
@@ -270,7 +268,7 @@ export class FakeHumanExecution implements Execution {
270268
new EmojiExecution(
271269
this.player,
272270
enemy.id(),
273-
this.random.randElement(this.heckleEmoji),
271+
this.random.randElement(EMOJI_HECKLE),
274272
),
275273
);
276274
}

src/core/execution/utils/BotBehavior.ts

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,34 @@ import { EmojiExecution } from "../EmojiExecution";
1414
import { PseudoRandom } from "../../PseudoRandom";
1515
import { flattenedEmojiTable } from "../../Util";
1616

17+
const emojiId = (e: string) => flattenedEmojiTable.indexOf(e);
18+
const EMOJI_ASSIST_ACCEPT = [
19+
"👍",
20+
"⛵",
21+
"🤝",
22+
"🎯",
23+
].map(emojiId);
24+
const EMOJI_RELATION_TOO_LOW = [
25+
"🥱",
26+
"🤦",
27+
].map(emojiId);
28+
const EMOJI_TARGET_ME = [
29+
"🥺",
30+
"💀",
31+
].map(emojiId);
32+
const EMOJI_TARGET_ALLY = [
33+
"🕊️",
34+
"👎",
35+
].map(emojiId);
36+
export const EMOJI_HECKLE = [
37+
"🤡",
38+
"😡",
39+
].map(emojiId);
40+
1741
export class BotBehavior {
1842
private enemy: Player | null = null;
1943
private enemyUpdated: Tick | undefined;
2044

21-
private readonly assistAcceptEmoji = flattenedEmojiTable.indexOf("👍");
22-
2345
constructor(
2446
private readonly random: PseudoRandom,
2547
private readonly game: Game,
@@ -155,26 +177,29 @@ export class BotBehavior {
155177
}
156178

157179
assistAllies() {
158-
outer: for (const ally of this.player.allies()) {
180+
for (const ally of this.player.allies()) {
159181
if (ally.targets().length === 0) continue;
160182
if (this.player.relation(ally) < Relation.Friendly) {
161-
// this.emoji(ally, "🤦");
183+
const emoji = this.random.randElement(EMOJI_RELATION_TOO_LOW);
184+
this.emoji(ally, emoji);
162185
continue;
163186
}
164187
for (const target of ally.targets()) {
165188
if (target === this.player) {
166-
// this.emoji(ally, "💀");
189+
const emoji = this.random.randElement(EMOJI_TARGET_ME);
190+
this.emoji(ally, emoji);
167191
continue;
168192
}
169193
if (this.player.isAlliedWith(target)) {
170-
// this.emoji(ally, "👎");
194+
const emoji = this.random.randElement(EMOJI_TARGET_ALLY);
195+
this.emoji(ally, emoji);
171196
continue;
172197
}
173198
// All checks passed, assist them
174199
this.player.updateRelation(ally, -20);
175200
this.setNewEnemy(target);
176-
this.emoji(ally, this.assistAcceptEmoji);
177-
break outer;
201+
this.emoji(ally, EMOJI_ASSIST_ACCEPT);
202+
return;
178203
}
179204
}
180205
}

0 commit comments

Comments
 (0)