mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:00:42 +00:00
@@ -4,16 +4,11 @@ import { PseudoRandom } from "../PseudoRandom";
|
||||
import { GameID } from "../Schemas";
|
||||
import { simpleHash } from "../Util";
|
||||
import { SpawnExecution } from "./SpawnExecution";
|
||||
import {
|
||||
COMMUNITY_FULL_ELF_NAMES,
|
||||
COMMUNITY_PREFIXES,
|
||||
SPECIAL_FULL_ELF_NAMES,
|
||||
} from "./utils/BotNames";
|
||||
import { BOT_NAME_PREFIXES, BOT_NAME_SUFFIXES } from "./utils/BotNames";
|
||||
|
||||
export class BotSpawner {
|
||||
private random: PseudoRandom;
|
||||
private bots: SpawnExecution[] = [];
|
||||
private nameIndex = 0;
|
||||
|
||||
constructor(
|
||||
private gs: Game,
|
||||
@@ -29,13 +24,9 @@ export class BotSpawner {
|
||||
console.log("too many retries while spawning bots, giving up");
|
||||
return this.bots;
|
||||
}
|
||||
const candidate = this.nextCandidateName();
|
||||
const spawn = this.spawnBot(candidate.name);
|
||||
const botName = this.randomBotName();
|
||||
const spawn = this.spawnBot(botName);
|
||||
if (spawn !== null) {
|
||||
// Only use candidate name once bot successfully spawned
|
||||
if (candidate.source === "list") {
|
||||
this.nameIndex++;
|
||||
}
|
||||
this.bots.push(spawn);
|
||||
} else {
|
||||
tries++;
|
||||
@@ -60,42 +51,10 @@ export class BotSpawner {
|
||||
);
|
||||
}
|
||||
|
||||
private nextCandidateName(): {
|
||||
name: string;
|
||||
source: "list" | "random";
|
||||
} {
|
||||
if (this.bots.length < 20) {
|
||||
//first few usually overwritten by Nation spawn
|
||||
return { name: this.getRandomElf(), source: "random" };
|
||||
}
|
||||
|
||||
if (this.nameIndex < COMMUNITY_FULL_ELF_NAMES.length) {
|
||||
return {
|
||||
name: COMMUNITY_FULL_ELF_NAMES[this.nameIndex],
|
||||
source: "list",
|
||||
};
|
||||
}
|
||||
const specialOffset = COMMUNITY_FULL_ELF_NAMES.length;
|
||||
if (this.nameIndex < specialOffset + SPECIAL_FULL_ELF_NAMES.length) {
|
||||
return {
|
||||
name: SPECIAL_FULL_ELF_NAMES[this.nameIndex - specialOffset],
|
||||
source: "list",
|
||||
};
|
||||
}
|
||||
const prefixOffset = specialOffset + SPECIAL_FULL_ELF_NAMES.length;
|
||||
if (this.nameIndex < prefixOffset + COMMUNITY_PREFIXES.length) {
|
||||
return {
|
||||
name: `${COMMUNITY_PREFIXES[this.nameIndex - prefixOffset]} the Elf`,
|
||||
source: "list",
|
||||
};
|
||||
}
|
||||
|
||||
return { name: this.getRandomElf(), source: "random" };
|
||||
}
|
||||
|
||||
private getRandomElf(): string {
|
||||
const suffixNumber = this.random.nextInt(1, 10001);
|
||||
return `Elf ${suffixNumber}`;
|
||||
private randomBotName(): string {
|
||||
const prefixIndex = this.random.nextInt(0, BOT_NAME_PREFIXES.length);
|
||||
const suffixIndex = this.random.nextInt(0, BOT_NAME_SUFFIXES.length);
|
||||
return `${BOT_NAME_PREFIXES[prefixIndex]} ${BOT_NAME_SUFFIXES[suffixIndex]}`;
|
||||
}
|
||||
|
||||
private randTile(): TileRef {
|
||||
|
||||
@@ -253,184 +253,3 @@ export const BOT_NAME_SUFFIXES = [
|
||||
"Democracy",
|
||||
"Autocracy",
|
||||
];
|
||||
export const COMMUNITY_FULL_ELF_NAMES = [
|
||||
"evan the Creator Elf",
|
||||
"iamlewis the Head Elf",
|
||||
"Restart the Community Elf",
|
||||
"Mr Box the Dev Elf",
|
||||
"InGloriousTom the Dev Elf",
|
||||
"Sheikh the First Elf",
|
||||
"N0ur the Flag Elf",
|
||||
"Diessel the UI Elf",
|
||||
"Nikola123 the Map Elf",
|
||||
"Aotumuri the Language Elf",
|
||||
"Pilkey the Admin Elf",
|
||||
"Mr tryout33s Elf",
|
||||
"Biffeur the YT Elf",
|
||||
"Enzo the YT Elf",
|
||||
"Molky the YT Elf",
|
||||
"FuzeIII the YT Elf",
|
||||
"Node the YT Elf",
|
||||
"Lumiin the YT Elf",
|
||||
"youngfentanyl OFM Elf",
|
||||
"Remorse the Wiki Elf",
|
||||
"Lonely Millennial Twitch Elf",
|
||||
"Kaizeron OFM Elf",
|
||||
"Zilka OFM Elf",
|
||||
"JIZK Caster Elf",
|
||||
"MiraCZ the FP Elf",
|
||||
"aPuddle best Elf",
|
||||
"lucas the sound Elf",
|
||||
];
|
||||
export const SPECIAL_FULL_ELF_NAMES = [
|
||||
"Santa",
|
||||
"Rudolf the Red-Nosed Reindeer",
|
||||
"Frosty the Snowman",
|
||||
"Hermey the Elf",
|
||||
"Ivan the Elf",
|
||||
"Elf on the Shelf",
|
||||
"Buddy the Elf",
|
||||
"Legolas",
|
||||
"Elrond",
|
||||
"Galadriel",
|
||||
"Celeborn",
|
||||
"Glorfindel",
|
||||
];
|
||||
export const COMMUNITY_PREFIXES = [
|
||||
"Baguette Bot",
|
||||
"Kiwi",
|
||||
"FakeNeo",
|
||||
"Nash",
|
||||
"1brucben",
|
||||
"Toyatak",
|
||||
"Readix",
|
||||
"Danny",
|
||||
"php",
|
||||
"Redincon",
|
||||
"Sachx.",
|
||||
"Fuity Mctooty",
|
||||
"Vimacs",
|
||||
"Wraith",
|
||||
"Phantom",
|
||||
"Crescent",
|
||||
"OF Therapist",
|
||||
"Aviid",
|
||||
"brunoo",
|
||||
"Ezaru",
|
||||
"prices",
|
||||
"Santos",
|
||||
"Wonder",
|
||||
"Vincent",
|
||||
"Smith M",
|
||||
"Acer Alex",
|
||||
"Controller",
|
||||
"d3n0x",
|
||||
"devalnor",
|
||||
"FloPinguin",
|
||||
"falcon",
|
||||
"GlacialDrift",
|
||||
"Jax",
|
||||
"Killersoren",
|
||||
"MiniMeTiny",
|
||||
"Remissile",
|
||||
"Sorikairo",
|
||||
"That Otter",
|
||||
"Arya",
|
||||
"Nebula",
|
||||
"takeser",
|
||||
"Kai IL PAZZO",
|
||||
"Vanon",
|
||||
"Foorack",
|
||||
"Abod",
|
||||
"aaa4xu",
|
||||
"Goblinon",
|
||||
"dx",
|
||||
"Pod",
|
||||
"Demonessica",
|
||||
"Dovg",
|
||||
"Joel",
|
||||
"LegitimatelyCool1",
|
||||
"OxMzimzy",
|
||||
"RTHOne",
|
||||
"Egophobic",
|
||||
"djmrFunnyMan",
|
||||
"5oliloguy",
|
||||
"cfsolver",
|
||||
"nvm",
|
||||
"Supbro",
|
||||
"Mischa",
|
||||
"WALMART NINJA",
|
||||
"Magico",
|
||||
"sidious",
|
||||
"Bruny",
|
||||
"Goofer",
|
||||
"Backn",
|
||||
"EyeSeeEm",
|
||||
"TrionX",
|
||||
"Theodora",
|
||||
"platz1de",
|
||||
"Maths Empire",
|
||||
"Moha",
|
||||
"SyntaxPM",
|
||||
"theskeleton4393",
|
||||
"juliosilvaqwerty5",
|
||||
"NewHappyRabbit",
|
||||
"Moki",
|
||||
"Xaelor",
|
||||
"NiclasWK",
|
||||
"cldprv",
|
||||
"r3ms",
|
||||
"Tanepro193",
|
||||
"gx21",
|
||||
"toldinsound",
|
||||
"jacks0n",
|
||||
"floriankilian",
|
||||
"Fibig",
|
||||
"Texxter",
|
||||
"pantelispantelidis",
|
||||
"ap ms",
|
||||
"frappa10",
|
||||
"Lollosean",
|
||||
"daimyo panda2",
|
||||
"gafunuko",
|
||||
"Jinyoon",
|
||||
"Perdiccas",
|
||||
"zibi",
|
||||
"RinkyDinky",
|
||||
"Rulfam",
|
||||
"Nobody",
|
||||
"Vekser",
|
||||
"extraextra",
|
||||
"MotivatedMonkey",
|
||||
"6uzm4n",
|
||||
"theangel2",
|
||||
"Keevee",
|
||||
"Makonede",
|
||||
"grassified",
|
||||
"Zjefken",
|
||||
"Summers Nick",
|
||||
"Marvin",
|
||||
"EagleEye",
|
||||
"Shahiid",
|
||||
"INGSOC",
|
||||
"SIG",
|
||||
"Bobo",
|
||||
"seekerreturns",
|
||||
"SlyTy",
|
||||
"Leo 21",
|
||||
"FX",
|
||||
"Calrathan",
|
||||
"AzloD",
|
||||
"SunnyBoyWTF",
|
||||
"BeGj",
|
||||
"tnhnblgl",
|
||||
"BrunoJurkovic",
|
||||
"q8gazy",
|
||||
"Kipstz",
|
||||
"aqw42",
|
||||
"TylerHavanan",
|
||||
"KerodK",
|
||||
"ghisloufou",
|
||||
"dxtron",
|
||||
"Sii",
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user