This commit is contained in:
@@ -93,60 +93,6 @@ final class Lorelei
|
||||
return substr($seed, 0, 64);
|
||||
}
|
||||
|
||||
public static function seedChoices(string $selectedSeed, int $count = 24): array
|
||||
{
|
||||
$selectedSeed = self::normalizeSeed($selectedSeed);
|
||||
$prefixes = [
|
||||
'abend', 'ahorn', 'anker', 'atlas', 'berg', 'blick', 'brise', 'echo',
|
||||
'eiche', 'fjord', 'fluss', 'fokus', 'hafen', 'herz', 'horizont', 'insel',
|
||||
'kiesel', 'kompass', 'kraft', 'linie', 'licht', 'lotse', 'mond', 'morgen',
|
||||
'nord', 'pfad', 'quelle', 'rauch', 'runde', 'sand', 'sommer', 'stein',
|
||||
'sturm', 'tal', 'ufer', 'wald', 'welle', 'wind', 'winkel', 'zeit',
|
||||
];
|
||||
$suffixes = [
|
||||
'alpha', 'atlas', 'balu', 'bravo', 'caspar', 'dario', 'emil', 'felix',
|
||||
'fiete', 'finn', 'gerrit', 'hanno', 'ilan', 'joris', 'kian', 'leon',
|
||||
'linus', 'maik', 'malo', 'marlon', 'mats', 'mika', 'milan', 'noel',
|
||||
'ole', 'oskar', 'pepe', 'quinn', 'remo', 'sam', 'taro', 'timo',
|
||||
'veit', 'vito', 'yaro', 'yuri', 'zeno', 'zuri',
|
||||
];
|
||||
|
||||
$choices = [[
|
||||
'seed' => $selectedSeed,
|
||||
'label' => 'Aktuelle Auswahl',
|
||||
'image' => self::dicebearUrl($selectedSeed),
|
||||
]];
|
||||
|
||||
$seen = [$selectedSeed => true];
|
||||
$base = abs((int) crc32($selectedSeed));
|
||||
$index = 0;
|
||||
|
||||
while (count($choices) < $count) {
|
||||
$prefix = $prefixes[($base + ($index * 7)) % count($prefixes)];
|
||||
$suffix = $suffixes[($base + ($index * 11)) % count($suffixes)];
|
||||
$candidate = self::normalizeSeed($prefix . '-' . $suffix . '-' . (($base + $index) % 997));
|
||||
$index++;
|
||||
|
||||
if (isset($seen[$candidate])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[$candidate] = true;
|
||||
$choices[] = [
|
||||
'seed' => $candidate,
|
||||
'label' => 'Variante ' . count($choices),
|
||||
'image' => self::dicebearUrl($candidate),
|
||||
];
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
public static function dicebearUrl(string $seed): string
|
||||
{
|
||||
return '/api/avatar?seed=' . rawurlencode(self::normalizeSeed($seed));
|
||||
}
|
||||
|
||||
public static function apiQuery(array $row): array
|
||||
{
|
||||
$avatar = self::normalize($row);
|
||||
@@ -210,7 +156,7 @@ final class Lorelei
|
||||
htmlspecialchars(implode(' ', [
|
||||
'pkt-avatar',
|
||||
'pkt-avatar--' . preg_replace('/[^a-z0-9\-]/', '', strtolower($size)),
|
||||
'pkt-avatar--preset',
|
||||
'pkt-avatar--generated',
|
||||
]), ENT_QUOTES),
|
||||
htmlspecialchars('Avatar von ' . $name, ENT_QUOTES),
|
||||
htmlspecialchars($src, ENT_QUOTES)
|
||||
|
||||
Reference in New Issue
Block a user