mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 22:00:07 +00:00
+ add random bot names
This commit is contained in:
+6
-2
@@ -8,6 +8,10 @@ import { number } from 'zod';
|
||||
import { GameConfig, GameID, GameRecord, PlayerRecord, Turn } from './Schemas';
|
||||
import { customAlphabet, nanoid } from 'nanoid';
|
||||
|
||||
|
||||
export const MIN_USERNAME_LENGTH = 3;
|
||||
export const MAX_USERNAME_LENGTH = 12;
|
||||
|
||||
export function manhattanDist(c1: Cell, c2: Cell): number {
|
||||
return Math.abs(c1.x - c2.x) + Math.abs(c1.y - c2.y);
|
||||
}
|
||||
@@ -185,7 +189,7 @@ export function getMode(list: string[]): string {
|
||||
}
|
||||
|
||||
export function sanitize(name: string): string {
|
||||
return Array.from(name).slice(0, 10).join('').replace(/[^\p{L}\p{N}\s\p{Emoji}\p{Emoji_Component}]/gu, '');
|
||||
return Array.from(name).join('').replace(/[^\p{L}\p{N}\s\p{Emoji}\p{Emoji_Component}]/gu, '');
|
||||
}
|
||||
|
||||
export function processName(name: string): string {
|
||||
@@ -277,4 +281,4 @@ export function assertNever(x: never): never {
|
||||
export function generateID(): GameID {
|
||||
const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 8)
|
||||
return nanoid()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user