feat: make general creation daemon-atomic
This commit is contained in:
@@ -16,6 +16,11 @@ export const PERSONALITY_TRAIT_KEYS = [
|
||||
|
||||
export type PersonalityTraitKey = (typeof PERSONALITY_TRAIT_KEYS)[number];
|
||||
|
||||
// Ref GameConst::$availablePersonality에는 은둔이 포함되지 않는다.
|
||||
export const JOIN_PERSONALITY_TRAIT_KEYS = PERSONALITY_TRAIT_KEYS.filter(
|
||||
(key): key is Exclude<PersonalityTraitKey, 'che_은둔'> => key !== 'che_은둔'
|
||||
);
|
||||
|
||||
export type PersonalityTraitModule = TraitModule;
|
||||
|
||||
export type PersonalityTraitImporter = () => Promise<TraitModuleExport>;
|
||||
|
||||
@@ -179,11 +179,14 @@ const readNameParts = (value: unknown, fallback: readonly string[]): string[] =>
|
||||
return result.length > 0 ? result : [...fallback];
|
||||
};
|
||||
|
||||
export const buildAuctionAlias = (
|
||||
generalId: number,
|
||||
export const buildAuctionAliasPool = (
|
||||
hiddenSeed: string | number,
|
||||
configConst: Record<string, unknown> = {}
|
||||
): string => {
|
||||
): string[] => {
|
||||
const persistedPool = readNameParts(configConst.obfuscatedNamePool, []);
|
||||
if (persistedPool.length > 0) {
|
||||
return persistedPool;
|
||||
}
|
||||
const firstNames = readNameParts(configConst.randGenFirstName, LEGACY_RANDOM_GENERAL_FIRST_NAMES);
|
||||
const middleNames = readNameParts(configConst.randGenMiddleName, ['']);
|
||||
const lastNames = readNameParts(configConst.randGenLastName, LEGACY_RANDOM_GENERAL_LAST_NAMES);
|
||||
@@ -195,7 +198,15 @@ export const buildAuctionAlias = (
|
||||
}
|
||||
}
|
||||
}
|
||||
const shuffled = new RandUtil(new LiteHashDRBG(simpleSerialize(hiddenSeed, 'obfuscatedNamePool'))).shuffle(pool);
|
||||
return new RandUtil(new LiteHashDRBG(simpleSerialize(hiddenSeed, 'obfuscatedNamePool'))).shuffle(pool);
|
||||
};
|
||||
|
||||
export const buildAuctionAlias = (
|
||||
generalId: number,
|
||||
hiddenSeed: string | number,
|
||||
configConst: Record<string, unknown> = {}
|
||||
): string => {
|
||||
const shuffled = buildAuctionAliasPool(hiddenSeed, configConst);
|
||||
const normalizedId = Math.max(0, Math.floor(generalId));
|
||||
const duplicateIndex = Math.floor(normalizedId / shuffled.length);
|
||||
const name = shuffled[normalizedId % shuffled.length] ?? `익명${normalizedId}`;
|
||||
|
||||
Reference in New Issue
Block a user