Skip to content

Commit df3e5d7

Browse files
VariableVincePhantasm0009
authored andcommitted
Special bot names (openfrontio#2552)
## Description: Special bot names. If the solution seems convoluted for such an easy thing, that is because: not all bots find a spawn position, so only assign a candidate name after finding a spawn. And the first few are almost always overwritten by Nation spawns so the first 20 just get a random name. Only then do we assign from the provided lists. For the random names, some might get the same name but that's not an issue as no-one will notice and they're off the map quite fast anyway. ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33
1 parent dec23ce commit df3e5d7

File tree

2 files changed

+229
-7
lines changed

2 files changed

+229
-7
lines changed

src/core/execution/BotSpawner.ts

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ import { PseudoRandom } from "../PseudoRandom";
44
import { GameID } from "../Schemas";
55
import { simpleHash } from "../Util";
66
import { SpawnExecution } from "./SpawnExecution";
7-
import { BOT_NAME_PREFIXES, BOT_NAME_SUFFIXES } from "./utils/BotNames";
7+
import {
8+
COMMUNITY_FULL_ELF_NAMES,
9+
COMMUNITY_PREFIXES,
10+
SPECIAL_FULL_ELF_NAMES,
11+
} from "./utils/BotNames";
812

913
export class BotSpawner {
1014
private random: PseudoRandom;
1115
private bots: SpawnExecution[] = [];
16+
private nameIndex = 0;
1217

1318
constructor(
1419
private gs: Game,
@@ -24,9 +29,13 @@ export class BotSpawner {
2429
console.log("too many retries while spawning bots, giving up");
2530
return this.bots;
2631
}
27-
const botName = this.randomBotName();
28-
const spawn = this.spawnBot(botName);
32+
const candidate = this.nextCandidateName();
33+
const spawn = this.spawnBot(candidate.name);
2934
if (spawn !== null) {
35+
// Only use candidate name once bot successfully spawned
36+
if (candidate.source === "list") {
37+
this.nameIndex++;
38+
}
3039
this.bots.push(spawn);
3140
} else {
3241
tries++;
@@ -51,10 +60,42 @@ export class BotSpawner {
5160
);
5261
}
5362

54-
private randomBotName(): string {
55-
const prefixIndex = this.random.nextInt(0, BOT_NAME_PREFIXES.length);
56-
const suffixIndex = this.random.nextInt(0, BOT_NAME_SUFFIXES.length);
57-
return `${BOT_NAME_PREFIXES[prefixIndex]} ${BOT_NAME_SUFFIXES[suffixIndex]}`;
63+
private nextCandidateName(): {
64+
name: string;
65+
source: "list" | "random";
66+
} {
67+
if (this.bots.length < 20) {
68+
//first few usually overwritten by Nation spawn
69+
return { name: this.getRandomElf(), source: "random" };
70+
}
71+
72+
if (this.nameIndex < COMMUNITY_FULL_ELF_NAMES.length) {
73+
return {
74+
name: COMMUNITY_FULL_ELF_NAMES[this.nameIndex],
75+
source: "list",
76+
};
77+
}
78+
const specialOffset = COMMUNITY_FULL_ELF_NAMES.length;
79+
if (this.nameIndex < specialOffset + SPECIAL_FULL_ELF_NAMES.length) {
80+
return {
81+
name: SPECIAL_FULL_ELF_NAMES[this.nameIndex - specialOffset],
82+
source: "list",
83+
};
84+
}
85+
const prefixOffset = specialOffset + SPECIAL_FULL_ELF_NAMES.length;
86+
if (this.nameIndex < prefixOffset + COMMUNITY_PREFIXES.length) {
87+
return {
88+
name: `${COMMUNITY_PREFIXES[this.nameIndex - prefixOffset]} the Elf`,
89+
source: "list",
90+
};
91+
}
92+
93+
return { name: this.getRandomElf(), source: "random" };
94+
}
95+
96+
private getRandomElf(): string {
97+
const suffixNumber = this.random.nextInt(1, 10001);
98+
return `Elf ${suffixNumber}`;
5899
}
59100

60101
private randTile(): TileRef {

src/core/execution/utils/BotNames.ts

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,184 @@ export const BOT_NAME_SUFFIXES = [
253253
"Democracy",
254254
"Autocracy",
255255
];
256+
export const COMMUNITY_FULL_ELF_NAMES = [
257+
"evan the Creator Elf",
258+
"iamlewis the Head Elf",
259+
"Restart the Community Elf",
260+
"Mr Box the Dev Elf",
261+
"InGloriousTom the Dev Elf",
262+
"Sheikh the First Elf",
263+
"N0ur the Flag Elf",
264+
"Diessel the UI Elf",
265+
"Nikola123 the Map Elf",
266+
"Aotumuri the Language Elf",
267+
"Pilkey the Admin Elf",
268+
"Mr tryout33s Elf",
269+
"Biffeur the YT Elf",
270+
"Enzo the YT Elf",
271+
"Molky the YT Elf",
272+
"FuzeIII the YT Elf",
273+
"Node the YT Elf",
274+
"Lumiin the YT Elf",
275+
"youngfentanyl OFM Elf",
276+
"Remorse the Wiki Elf",
277+
"Lonely Millenial Twitch Elf",
278+
"Kaizeron OFM Elf",
279+
"Zilka OFM Elf",
280+
"JIZK Caster Elf",
281+
"MiraCZ the FP Elf",
282+
"aPuddle best Elf",
283+
"lucas the sound Elf",
284+
];
285+
export const SPECIAL_FULL_ELF_NAMES = [
286+
"Santa",
287+
"Rudolf the Red-Nosed Reindeer",
288+
"Frosty the Snowman",
289+
"Hermey the Elf",
290+
"Ivan the Elf",
291+
"Elf on the Shelf",
292+
"Buddy the Elf",
293+
"Legolas",
294+
"Elrond",
295+
"Galadriel",
296+
"Celeborn",
297+
"Glorfindel",
298+
];
299+
export const COMMUNITY_PREFIXES = [
300+
"Baguette Bot",
301+
"Kiwi",
302+
"FakeNeo",
303+
"Nash",
304+
"1brucben",
305+
"Toyatak",
306+
"Readix",
307+
"Danny",
308+
"php",
309+
"Redincon",
310+
"Sachx.",
311+
"Fuity Mctooty",
312+
"Vimacs",
313+
"Wraith",
314+
"Phantom",
315+
"Crescent",
316+
"OF Therapist",
317+
"Aviid",
318+
"brunoo",
319+
"Ezaru",
320+
"prices",
321+
"Santos",
322+
"Wonder",
323+
"Vincent",
324+
"Smith M",
325+
"Acer Alex",
326+
"Controller",
327+
"d3n0x",
328+
"devalnor",
329+
"FloPinguin",
330+
"falcon",
331+
"GlacialDrift",
332+
"Jax",
333+
"Killersoren",
334+
"MiniMeTiny",
335+
"Remissile",
336+
"Sorikairo",
337+
"That Otter",
338+
"Arya",
339+
"Nebula",
340+
"takeser",
341+
"Kai IL PAZZO",
342+
"Vanon",
343+
"Foorack",
344+
"Abod",
345+
"aaa4xu",
346+
"Goblinon",
347+
"dx",
348+
"Pod",
349+
"Demonessica",
350+
"Dovg",
351+
"Joel",
352+
"LegitimatelyCool1",
353+
"OxMzimzy",
354+
"RTHOne",
355+
"Egophobic",
356+
"djmrFunnyMan",
357+
"5oliloguy",
358+
"cfsolver",
359+
"nvm",
360+
"Supbro",
361+
"Mischa",
362+
"WALMART NINJA",
363+
"Magico",
364+
"sidious",
365+
"Bruny",
366+
"Goofer",
367+
"Backn",
368+
"EyeSeeEm",
369+
"TrionX",
370+
"Theodora",
371+
"platz1de",
372+
"Maths Empire",
373+
"Moha",
374+
"SyntaxPM",
375+
"theskeleton4393",
376+
"juliosilvaqwerty5",
377+
"NewHappyRabbit",
378+
"Moki",
379+
"Xaelor",
380+
"NiclasWK",
381+
"cldprv",
382+
"r3ms",
383+
"Tanepro193",
384+
"gx21",
385+
"toldinsound",
386+
"jacks0n",
387+
"floriankilian",
388+
"Fibig",
389+
"Texxter",
390+
"pantelispantelidis",
391+
"ap ms",
392+
"frappa10",
393+
"Lollosean",
394+
"daimyo panda2",
395+
"gafunuko",
396+
"Jinyoon",
397+
"Perdiccas",
398+
"zibi",
399+
"RinkyDinky",
400+
"Rulfam",
401+
"Nobody",
402+
"Vekser",
403+
"extraextra",
404+
"MotivatedMonkey",
405+
"6uzm4n",
406+
"theangel2",
407+
"Keevee",
408+
"Makonede",
409+
"grassified",
410+
"Zjefken",
411+
"Summers Nick",
412+
"Marvin",
413+
"EagleEye",
414+
"Shahiid",
415+
"INGSOC",
416+
"SIG",
417+
"Bobo",
418+
"seekerreturns",
419+
"SlyTy",
420+
"Leo 21",
421+
"FX",
422+
"Calrathan",
423+
"AzloD",
424+
"SunnyBoyWTF",
425+
"BeGj",
426+
"tnhnblgl",
427+
"BrunoJurkovic",
428+
"q8gazy",
429+
"Kipstz",
430+
"aqw42",
431+
"TylerHavanan",
432+
"KerodK",
433+
"ghisloufou",
434+
"dxtron",
435+
"Sii",
436+
];

0 commit comments

Comments
 (0)