LuminaWebsite/includes/gear_skills.php
Maaxxs 0977ef4f37 Skill planner: levels with - and + like aion2hub, self-leveled up to 10, bonuses from Daevanion and Arcana
Active and passive skills are planned only up to level 10 (stigmas 20); the levels above come from the
Daevanion and Arcana pages and show as "+4 → 14" (effective level, also used for specializations and the
compare view). Skill points and stigma points are limited to aion2hub's budget at character level 45
(3,723 / 304), at most 4 stigmas can be leveled - checked in the page and on the server. Stored levels
above 10 are set to 10 by the schema update (v41).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 00:34:13 +02:00

581 lines
25 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
/**
* Gear-Planer, Skills: Skill-Liste je Klasse (von aion2hub, Global-Client) und die geplante
* Skillstufe je Set.
*
* Die Listen uebernehmen Admins unter /admin/gear_items.php von den Klassenseiten bei aion2hub
* (includes/gear_source.php). Jedes Set plant die Skills seiner Klasse; wechselt die Klasse,
* bleiben die alten Stufen gespeichert (ausgeblendet) und sind beim Zurueckwechseln wieder da.
*
* Drei Arten (kind): normale aktive Skills und passive Skills (Meisterschaft, mit Skillpunkten
* gesteigert) und Stigma-Skills (mit Stigma-Splittern gesteigert, nur wenige gleichzeitig). Aktive
* Skills haben dazu fuenf Spezialisierungen, Stigmen vier Boni - deren Effekte kommen aus dem Build-Planer
* von aion2hub (englisch, gear_skills.spec_effects). Deutsche Skillnamen und deutsche Texte der
* Spezialisierungen/Boni traegt die Leitung unter /admin/gear_skills.php ein.
*/
const GEAR_SKILL_ICON_DIR = __DIR__ . '/../assets/uploads/skills/';
const GEAR_SKILL_ICON_URL = '/assets/uploads/skills/';
// Stufen (Stand: Global-Client des Launch Scale Tests und offizieller KR-Guide, geprueft 23.09.2026):
// Normale aktive und passive Skills (Meisterschaft) steigert man selbst mit Skillpunkten bis 10 - nur
// das wird hier geplant. Darueber kommen Boni: die Daevanion-Bretter geben je Skill +4, Arcana und
// Ausruestung den Rest bis 20 (Seiten Daevanion und Arcana, includes/gear_planner.php). Stigma-Skills
// steigen mit Stigma-Punkten bis 20, steigern lassen sich hoechstens 4 (Korea inzwischen 6 Plaetze und
// Stufe 25 - fuer spaetere Seasons hier anpassen).
const GEAR_SKILL_LEVEL_SELF = 10;
const GEAR_SKILL_DAEVANION_BONUS = 4;
const GEAR_SKILL_LEVEL_MAX = 20;
const GEAR_STIGMA_LEVEL_MAX = 20;
const GEAR_STIGMA_SLOTS = 4;
// Kosten je Stufe (Index 0 = Stufe 1) wie im Build-Planer von aion2hub: Stufe 1 gibt es beim Lernen,
// 2-4 kosten je 1 Skillpunkt, 5-7 je 2, 8-10 je 4 (21 bis Stufe 10); Stigmen 1-5 je 1, 6-10 je 2,
// 11-15 je 4, 16-20 je 8 Stigma-Punkte (75 bis Stufe 20)
const GEAR_SKILL_LEVEL_COSTS = [0, 1, 1, 1, 2, 2, 2, 4, 4, 4];
const GEAR_STIGMA_LEVEL_COSTS = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8];
// So viele Skillpunkte und Stigma-Punkte lassen sich insgesamt vergeben - das Budget bei Charakterstufe 45
// (Hoechststufe auf Global) laut Build-Planer von aion2hub
const GEAR_SKILL_POINTS = 3723;
const GEAR_STIGMA_POINTS = 304;
const GEAR_SKILL_KINDS = ['active' => 'Aktive Skills', 'stigma' => 'Stigma-Skills', 'passive' => 'Passive Skills'];
// Spezialisierungen der normalen aktiven Skills (Stand Korea): fuenf zur Wahl - I-III ab Stufe 8,
// IV ab 12, V ab 16 -, einsetzen lassen sich eine ab Stufe 8, zwei ab 12 und drei ab 20. Passive
// Skills haben keine, Stigma-Skills bekommen ihre Boni bei 5/10/15/20 automatisch.
const GEAR_SKILL_SPECS = [1 => 8, 2 => 8, 3 => 8, 4 => 12, 5 => 16];
const GEAR_SKILL_SPEC_SLOTS = [20 => 3, 12 => 2, 8 => 1];
const GEAR_SKILL_SPEC_NUMERALS = [1 => 'I', 2 => 'II', 3 => 'III', 4 => 'IV', 5 => 'V'];
const GEAR_STIGMA_PERKS = [5, 10, 15, 20];
// Art des Skills auf Deutsch (aion2hub liefert sie englisch), unbekannte bleiben, wie sie sind
const GEAR_SKILL_CATEGORIES = [
'Attack' => 'Angriff', 'Buff' => 'Stärkung', 'Heal' => 'Heilung', 'Debuff' => 'Schwächung',
'Defense' => 'Verteidigung', 'Movement' => 'Bewegung', 'Crowd Control' => 'Kontrolle',
];
/** Anzeigename: der deutsche, wenn die Leitung einen eingetragen hat, sonst der von aion2hub. */
function gear_skill_display_name(array $skill): string
{
$german = trim((string) ($skill['name_de'] ?? ''));
return $german !== '' ? $german : (string) $skill['name'];
}
/** Hat diese Art Spezialisierungen zur Wahl? (nur normale aktive Skills) */
function gear_skill_has_specs(string $kind): bool
{
return $kind === 'active';
}
/** Wie viele Spezialisierungen sich bei dieser Stufe einsetzen lassen. */
function gear_skill_spec_slots(int $level): int
{
foreach (GEAR_SKILL_SPEC_SLOTS as $from => $slots) {
if ($level >= $from) {
return $slots;
}
}
return 0;
}
/** Gewaehlte Spezialisierungen als Nummern ([1, 3]) aus der Bitmaske (Bit 0 = I). */
function gear_skill_spec_numbers(int $mask): array
{
return array_values(array_filter(
array_keys(GEAR_SKILL_SPECS),
static fn (int $no): bool => ($mask & (1 << ($no - 1))) !== 0
));
}
function gear_skill_spec_mask(array $numbers): int
{
$mask = 0;
foreach ($numbers as $no) {
if (isset(GEAR_SKILL_SPECS[(int) $no])) {
$mask |= 1 << ((int) $no - 1);
}
}
return $mask;
}
/** Nur, was bei dieser Stufe geht: freigeschaltete, hoechstens so viele wie Plaetze (die niedrigsten Nummern bleiben). */
function gear_skill_specs_clean(int $mask, int $level): int
{
$kept = [];
foreach (gear_skill_spec_numbers($mask) as $no) {
if ($level >= GEAR_SKILL_SPECS[$no] && count($kept) < gear_skill_spec_slots($level)) {
$kept[] = $no;
}
}
return gear_skill_spec_mask($kept);
}
/** Deutsche Texte der Spezialisierungen/Boni eines Skills [1 => 'Text', …] - leer, solange die Leitung keine eingetragen hat. */
function gear_skill_spec_names(array $skill): array
{
$stored = json_decode((string) ($skill['spec_names'] ?? ''), true);
$names = [];
foreach (array_keys(gear_skill_part_levels($skill['kind'])) as $no) {
$names[$no] = is_array($stored) ? trim((string) ($stored[$no - 1] ?? '')) : '';
}
return $names;
}
/** Ab welcher Stufe die Spezialisierungen (aktiv: I-V) bzw. Boni (Stigma: 1-4) kommen: [Nr => Stufe]. */
function gear_skill_part_levels(string $kind): array
{
if ($kind === 'stigma') {
return array_combine(range(1, count(GEAR_STIGMA_PERKS)), GEAR_STIGMA_PERKS);
}
return $kind === 'active' ? GEAR_SKILL_SPECS : [];
}
/**
* Spezialisierungen (aktive Skills) bzw. Boni (Stigmen) eines Skills zum Anzeigen:
* [Nr => ['t' => ab Stufe, 'text' => deutsch, sonst englischer Effekt von aion2hub, sonst Platzhalter,
* 'en' => englischer Effekt, 'kr' => Effekt nur aus Korea-Daten]]
*/
function gear_skill_parts(array $skill): array
{
$effects = json_decode((string) ($skill['spec_effects'] ?? ''), true);
$german = gear_skill_spec_names($skill);
$parts = [];
foreach (gear_skill_part_levels($skill['kind']) as $no => $level) {
$effect = is_array($effects) && is_array($effects[$no - 1] ?? null) ? $effects[$no - 1] : [];
$english = trim((string) ($effect['e'] ?? ''));
$parts[$no] = [
't' => $level,
'text' => $german[$no] !== '' ? $german[$no] : ($english !== '' ? $english
: ($skill['kind'] === 'stigma' ? 'Bonus ab Stufe ' . $level : 'Spezialisierung ' . GEAR_SKILL_SPEC_NUMERALS[$no])),
'en' => $english,
'kr' => !empty($effect['kr']),
];
}
return $parts;
}
/** "II · Effekt" (Spezialisierung eines aktiven Skills) */
function gear_skill_spec_label(array $skill, int $no): string
{
return GEAR_SKILL_SPEC_NUMERALS[$no] . ' · ' . (gear_skill_parts($skill)[$no]['text'] ?? '');
}
function gear_skill_icon_url(?array $skill): ?string
{
return !empty($skill['icon']) ? GEAR_SKILL_ICON_URL . rawurlencode((string) $skill['icon']) : null;
}
function gear_skill_category_label(string $category): string
{
return GEAR_SKILL_CATEGORIES[$category] ?? $category;
}
/** CSS-Klasse fuer die Farbe der Art ("skill-cat-attack"). */
function gear_skill_category_class(string $category): string
{
return 'skill-cat-' . (preg_replace('/[^a-z]+/', '-', strtolower($category)) ?: 'none');
}
/** Hoechste Stufe, die man selbst steigert (aktiv/passiv 10, Stigma 20) - darueber nur Boni. */
function gear_skill_level_max(string $kind): int
{
return $kind === 'stigma' ? GEAR_STIGMA_LEVEL_MAX : GEAR_SKILL_LEVEL_SELF;
}
/** Erreichte Stufe: selbst gesteigert plus Boni aus Daevanion, Arcana und Ausruestung, hoechstens bis zur Grenze. */
function gear_skill_effective_level(string $kind, int $level, int $bonus): int
{
return min($level + max(0, $bonus), $kind === 'stigma' ? GEAR_STIGMA_LEVEL_MAX : GEAR_SKILL_LEVEL_MAX);
}
/** Liegt die (erreichte) Stufe ueber dem, was Skillpunkte hergeben? Gilt nicht fuer Stigma-Skills. */
function gear_skill_is_bonus(string $kind, int $level): bool
{
return $kind !== 'stigma' && $level > GEAR_SKILL_LEVEL_SELF;
}
/** Kosten je Stufe einer Art (Index 0 = Stufe 1). */
function gear_skill_level_costs(string $kind): array
{
return $kind === 'stigma' ? GEAR_STIGMA_LEVEL_COSTS : GEAR_SKILL_LEVEL_COSTS;
}
/** Skillpunkte bis zu einer Stufe (Stufe 1 gibt es beim Lernen): 2-4 je 1, 5-7 je 2, 8-10 je 4. */
function gear_skill_point_cost(int $level): int
{
return (int) array_sum(array_slice(GEAR_SKILL_LEVEL_COSTS, 0, max(0, $level)));
}
/** Stigma-Punkte bis zu einer Stufe (Stufe 1 = Lernen): 1-5 je 1, 6-10 je 2, 11-15 je 4, 16-20 je 8. */
function gear_stigma_shard_cost(int $level): int
{
return (int) array_sum(array_slice(GEAR_STIGMA_LEVEL_COSTS, 0, max(0, $level)));
}
/**
* Was die geplanten Stufen kosten: Skillpunkte (aktive und passive Skills) und Stigma-Punkte.
*
* @return array{points: int, shards: int}
*/
function gear_skill_costs(array $planned): array
{
$costs = ['points' => 0, 'shards' => 0];
foreach ($planned as ['skill' => $skill, 'level' => $level]) {
if ($skill['kind'] === 'stigma') {
$costs['shards'] += gear_stigma_shard_cost($level);
} else {
$costs['points'] += gear_skill_point_cost($level);
}
}
return $costs;
}
/** "142 / 3.723 Skillpunkte" bzw. "90 / 304 Stigma-Punkte" */
function gear_skill_budget_text(int $spent, bool $stigma): string
{
return number_format($spent, 0, ',', '.') . ' / ' . number_format($stigma ? GEAR_STIGMA_POINTS : GEAR_SKILL_POINTS, 0, ',', '.')
. ($stigma ? ' Stigma-Punkte' : ' Skillpunkte');
}
function gear_skill(int $id): ?array
{
$stmt = db()->prepare('SELECT * FROM gear_skills WHERE id = ?');
$stmt->execute([$id]);
return $stmt->fetch() ?: null;
}
/**
* Skills einer Klasse in der Reihenfolge der Klassenseite (aktive, Stigma, passive).
* $listedOnly = false nimmt auch die, die beim letzten Abgleich nicht mehr in der Liste standen.
*
* @return array<int, array> [Skill-ID => Zeile]
*/
function gear_skills_for_class(?string $className, bool $listedOnly = true): array
{
if ($className === null || $className === '') {
return [];
}
$stmt = db()->prepare(
'SELECT * FROM gear_skills WHERE class_name = ?' . ($listedOnly ? ' AND is_listed = 1' : '') . ' ORDER BY kind, sort_order, id'
);
$stmt->execute([$className]);
$skills = [];
foreach ($stmt->fetchAll() as $row) {
$skills[(int) $row['id']] = $row;
}
return $skills;
}
/** Gespeicherte Stufen eines Sets: [Skill-ID => Stufe] (auch die einer frueheren Klasse). */
function gear_set_skill_levels(int $setId): array
{
return array_map(static fn (array $row): int => $row['level'], gear_set_skill_rows($setId));
}
/** Gespeicherte Stufen und Spezialisierungen eines Sets: [Skill-ID => ['level' => n, 'specs' => Bitmaske]]. */
function gear_set_skill_rows(int $setId): array
{
$stmt = db()->prepare('SELECT skill_id, level, specs FROM gear_set_skills WHERE set_id = ? AND level > 0');
$stmt->execute([$setId]);
$rows = [];
foreach ($stmt->fetchAll() as $row) {
$rows[(int) $row['skill_id']] = ['level' => (int) $row['level'], 'specs' => (int) $row['specs']];
}
return $rows;
}
/**
* Geplante Skills mehrerer Sets - nur die der Klasse des Sets und mit Stufe, in der Reihenfolge
* der Klassenseite.
*
* @param array<int, array> $sets Zeilen aus gear_sets (id, class_name)
* @return array<int, array<int, array{skill: array, level: int, specs: int}>> [Set-ID => [Skill-ID => …]]
*/
function gear_set_skills_for_sets(array $sets): array
{
$classes = [];
foreach ($sets as $set) {
$classes[(int) $set['id']] = (string) ($set['class_name'] ?? '');
}
$result = array_fill_keys(array_keys($classes), []);
if (!$classes) {
return $result;
}
$stmt = db()->prepare(
'SELECT gss.set_id, gss.level, gss.specs, sk.* FROM gear_set_skills gss JOIN gear_skills sk ON sk.id = gss.skill_id
WHERE gss.set_id IN (' . implode(',', array_fill(0, count($classes), '?')) . ') AND gss.level > 0
ORDER BY sk.kind, sk.sort_order, sk.id'
);
$stmt->execute(array_keys($classes));
foreach ($stmt->fetchAll() as $row) {
$setId = (int) $row['set_id'];
if ($row['class_name'] !== $classes[$setId]) {
continue; // von einer frueheren Klasse des Sets
}
$level = (int) $row['level'];
$specs = (int) $row['specs'];
unset($row['set_id'], $row['level'], $row['specs']);
$result[$setId][(int) $row['id']] = ['skill' => $row, 'level' => $level, 'specs' => $specs];
}
return $result;
}
/** "14 Skills geplant · 4/4 Stigmen" */
function gear_skill_summary(array $planned): string
{
if (!$planned) {
return 'Noch keine Skills geplant';
}
$stigma = count(array_filter($planned, static fn (array $p): bool => $p['skill']['kind'] === 'stigma'));
return count($planned) . (count($planned) === 1 ? ' Skill' : ' Skills') . ' geplant'
. ($stigma ? ' · ' . $stigma . '/' . GEAR_STIGMA_SLOTS . ' Stigmen' : '');
}
/**
* Zusammenfassung einer Unterseite ("skills" = aktive und passive, "stigma" = Stigmen):
* [Text, Kosten], z.B. ["12 Skills geplant · 3 über Stufe 10", "142 / 3.723 Skillpunkte"].
*
* @param array<int, array{skill: array, level: int}> $planned nur die Skills dieser Unterseite
* @param array<int, int> $bonuses Boni aus Daevanion/Arcana je Skill (fuer "über Stufe 10")
* @return array{0: string, 1: string}
*/
function gear_skill_tab_summary(array $planned, string $tab, array $bonuses = []): array
{
$costs = gear_skill_costs($planned);
if ($tab === 'stigma') {
return [count($planned) . ' von ' . GEAR_STIGMA_SLOTS . ' Stigmen', gear_skill_budget_text($costs['shards'], true)];
}
if (!$planned) {
return ['Noch keine Skills geplant', gear_skill_budget_text(0, false)];
}
$boosted = count(array_filter($planned, static fn (array $p): bool => gear_skill_is_bonus(
$p['skill']['kind'],
gear_skill_effective_level($p['skill']['kind'], $p['level'], (int) ($bonuses[(int) $p['skill']['id']] ?? 0))
)));
return [
count($planned) . (count($planned) === 1 ? ' Skill' : ' Skills') . ' geplant' . ($boosted ? ' · ' . $boosted . ' mit Boni über Stufe ' . GEAR_SKILL_LEVEL_SELF : ''),
gear_skill_budget_text($costs['points'], false),
];
}
/** Die geplanten Skills einer Unterseite ("skills" oder "stigma"). */
function gear_skills_of_tab(array $planned, string $tab): array
{
return array_filter($planned, static fn (array $p): bool => ($p['skill']['kind'] === 'stigma') === ($tab === 'stigma'));
}
/**
* Kleine Icon-Reihe der geplanten Skills fuer Set-Karten: die hoechsten Stufen zuerst, mit Stufe.
*
* @param array<int, array{skill: array, level: int}> $planned
*/
function gear_skills_mini_html(array $planned, int $limit = 8): string
{
if (!$planned) {
return '';
}
$sorted = array_values($planned);
usort($sorted, static fn (array $a, array $b): int => $b['level'] <=> $a['level']);
$html = '<span class="gear-skill-mini">';
foreach (array_slice($sorted, 0, $limit) as ['skill' => $skill, 'level' => $level]) {
$url = gear_skill_icon_url($skill);
$html .= '<span class="gear-skill-mini-icon' . (gear_skill_is_bonus($skill['kind'], $level) ? ' is-bonus' : '')
. ($skill['kind'] === 'stigma' ? ' is-stigma' : '') . '" title="'
. e(gear_skill_display_name($skill) . ($skill['kind'] === 'stigma' ? ' (Stigma)' : '') . ' – Stufe ' . $level) . '">'
. ($url ? '<img src="' . e($url) . '" alt="" loading="lazy">' : '<span>' . e(mb_substr(gear_skill_display_name($skill), 0, 1)) . '</span>')
. '<span class="gear-skill-mini-level">' . $level . '</span></span>';
}
if (count($sorted) > $limit) {
$html .= '<span class="gear-skill-mini-more">+' . (count($sorted) - $limit) . '</span>';
}
return $html . '</span>';
}
// ---- Uebernehmen von aion2hub ----
/** Skill-Icon von aion2hub laden (einmalig). Gibt den Dateinamen zurueck oder null. */
function gear_skill_icon_download(int $id): ?string
{
return gear_image_download(GEAR_SOURCE_SKILL_ICON_URL . $id, GEAR_SKILL_ICON_DIR, (string) $id);
}
/** Schon vorhandene Icon-Datei eines Skills (z.B. nach dem Entfernen und erneuten Uebernehmen). */
function gear_skill_icon_on_disk(int $id): ?string
{
foreach (['webp', 'png', 'jpg', 'gif'] as $extension) {
if (is_file(GEAR_SKILL_ICON_DIR . $id . '.' . $extension)) {
return $id . '.' . $extension;
}
}
return null;
}
/**
* Ausgelesene Skill-Liste einer Klasse speichern (gear_source_parse_class_skills). Skills, die
* nicht mehr in der Liste stehen, bleiben fuer bestehende Plaene erhalten und werden nur markiert.
*
* @return array{total: int, new: string[], changed: string[], same: int, unlisted: string[], missing_icons: int[], source_version: string}
*/
function gear_skills_store(string $className, array $parsed, int $userId): array
{
$pdo = db();
$ids = array_column($parsed['skills'], 'id');
$stmt = $pdo->prepare(
'SELECT * FROM gear_skills WHERE class_name = ?'
. ($ids ? ' OR id IN (' . implode(',', array_fill(0, count($ids), '?')) . ')' : '')
);
$stmt->execute([$className, ...$ids]);
$old = [];
foreach ($stmt->fetchAll() as $row) {
$old[(int) $row['id']] = $row;
}
$result = [
'total' => count($parsed['skills']), 'new' => [], 'changed' => [], 'same' => 0, 'unlisted' => [],
'missing_icons' => [], 'source_version' => $parsed['source_version'],
];
$upsert = $pdo->prepare(
'INSERT INTO gear_skills (id, class_name, name, kind, category, sort_order, source_version, is_listed, checked_at, checked_by)
VALUES (?, ?, ?, ?, ?, ?, ?, 1, NOW(), ?)
ON DUPLICATE KEY UPDATE class_name = VALUES(class_name), name = VALUES(name), kind = VALUES(kind), category = VALUES(category),
sort_order = VALUES(sort_order), source_version = VALUES(source_version), is_listed = 1,
checked_at = NOW(), checked_by = VALUES(checked_by)'
);
$pdo->beginTransaction();
try {
foreach ($parsed['skills'] as $index => $skill) {
$before = $old[$skill['id']] ?? null;
$upsert->execute([
$skill['id'], $className, $skill['name'], $skill['kind'], $skill['category'], $index + 1,
mb_substr($parsed['source_version'], 0, 120), $userId,
]);
if ($before === null) {
$result['new'][] = $skill['name'];
} else {
$changes = [];
if ($before['name'] !== $skill['name']) {
$changes[] = 'Name ' . $before['name'] . ' → ' . $skill['name'];
}
if ($before['kind'] !== $skill['kind']) {
$changes[] = ['active' => 'jetzt aktiv', 'stigma' => 'jetzt Stigma', 'passive' => 'jetzt passiv'][$skill['kind']] ?? $skill['kind'];
}
if ($before['category'] !== $skill['category']) {
$changes[] = 'Art ' . ($before['category'] ?: '–') . ' → ' . ($skill['category'] ?: '–');
}
if ($before['class_name'] !== $className) {
$changes[] = 'Klasse ' . $before['class_name'] . ' → ' . $className;
}
if (!(int) $before['is_listed']) {
$changes[] = 'wieder in der Liste';
}
if ($changes) {
$result['changed'][] = $skill['name'] . ' (' . implode(', ', $changes) . ')';
} else {
$result['same']++;
}
}
if ($before === null || empty($before['icon']) || !is_file(GEAR_SKILL_ICON_DIR . $before['icon'])) {
// Liegt die Datei noch da, reicht es, sie wieder einzutragen - sonst spaeter laden
$onDisk = gear_skill_icon_on_disk($skill['id']);
if ($onDisk !== null) {
$pdo->prepare('UPDATE gear_skills SET icon = ? WHERE id = ?')->execute([$onDisk, $skill['id']]);
} else {
$result['missing_icons'][] = $skill['id'];
}
}
}
$listed = array_flip($ids);
$unlist = $pdo->prepare('UPDATE gear_skills SET is_listed = 0 WHERE id = ?');
foreach ($old as $id => $row) {
if (!isset($listed[$id]) && $row['class_name'] === $className && (int) $row['is_listed']) {
$unlist->execute([$id]);
$result['unlisted'][] = $row['name'];
}
}
$pdo->commit();
} catch (Throwable $e) {
$pdo->rollBack();
throw $e;
}
return $result;
}
/**
* Effekte der Spezialisierungen und Stigma-Boni aus dem Build-Planer von aion2hub speichern
* (gear_source_parse_planner_specs) - fuer alle Skills im Katalog. Deutsche Texte der Leitung bleiben.
*
* @return array{updated: int, same: int, missing: string[], kr: int, built_at: string, warning: string}
*/
function gear_skills_store_specs(array $planner): array
{
$rows = db()->query("SELECT id, name, class_name, kind, spec_effects FROM gear_skills WHERE kind IN ('active', 'stigma') ORDER BY class_name, kind, sort_order")->fetchAll();
$update = db()->prepare('UPDATE gear_skills SET spec_effects = ? WHERE id = ?');
$result = ['updated' => 0, 'same' => 0, 'missing' => [], 'kr' => 0, 'built_at' => $planner['built_at'], 'warning' => ''];
foreach ($rows as $row) {
$entry = $planner['skills'][(int) $row['id']] ?? null;
$expected = $row['kind'] === 'stigma' ? 'Stigma' : 'Mastery';
if ($entry === null || $entry['kind'] !== $expected || count($entry['parts']) !== count(gear_skill_part_levels($row['kind']))) {
$result['missing'][] = $row['name'] . ' (' . $row['class_name'] . ')';
continue;
}
$result['kr'] += count(array_filter($entry['parts'], static fn (array $part): bool => $part['kr'] === 1));
$json = json_encode($entry['parts'], JSON_UNESCAPED_UNICODE);
if ($json === $row['spec_effects']) {
$result['same']++;
continue;
}
$update->execute([$json, $row['id']]);
$result['updated']++;
}
// Rechnet aion2hub mit anderen Stufen als der Planer (GEAR_SKILL_SPEC_SLOTS / GEAR_SKILL_SPECS)?
$slotLevels = array_reverse(array_keys(GEAR_SKILL_SPEC_SLOTS));
if ($planner['slot_unlock'] && $planner['slot_unlock'] !== $slotLevels) {
$result['warning'] = 'aion2hub öffnet die Plätze für Spezialisierungen bei Stufe ' . implode('/', $planner['slot_unlock'])
. ', der Planer rechnet mit ' . implode('/', $slotLevels) . '.';
}
foreach ($planner['skills'] as $entry) {
$levels = array_column($entry['parts'], 't');
$expected = array_values(gear_skill_part_levels($entry['kind'] === 'Stigma' ? 'stigma' : 'active'));
if ($levels !== $expected) {
$result['warning'] = trim($result['warning'] . ' Manche Spezialisierungen/Boni kommen dort bei anderen Stufen ('
. implode('/', $levels) . ' statt ' . implode('/', $expected) . ').');
break;
}
}
return $result;
}
/**
* Stand des Skill-Katalogs je Klasse fuer die Verwaltung.
*
* @return array<string, array{active: int, stigma: int, passive: int, effects: int, unlisted: int, no_icon: int, checked_at: ?string, source_version: string}>
*/
function gear_skill_catalog_status(): array
{
$status = [];
foreach (AION_CLASSES as $class) {
$status[$class] = ['active' => 0, 'stigma' => 0, 'passive' => 0, 'effects' => 0, 'unlisted' => 0, 'no_icon' => 0, 'checked_at' => null, 'source_version' => ''];
}
$rows = db()->query(
"SELECT class_name, SUM(is_listed = 1 AND kind = 'active') AS active, SUM(is_listed = 1 AND kind = 'stigma') AS stigma,
SUM(is_listed = 1 AND kind = 'passive') AS passive, SUM(is_listed = 0) AS unlisted, SUM(icon IS NULL) AS no_icon,
SUM(is_listed = 1 AND kind IN ('active', 'stigma') AND spec_effects IS NOT NULL) AS effects,
MAX(checked_at) AS checked_at, MAX(source_version) AS source_version
FROM gear_skills GROUP BY class_name"
)->fetchAll();
foreach ($rows as $row) {
if (isset($status[$row['class_name']])) {
$status[$row['class_name']] = [
'active' => (int) $row['active'], 'stigma' => (int) $row['stigma'], 'passive' => (int) $row['passive'],
'effects' => (int) $row['effects'], 'unlisted' => (int) $row['unlisted'], 'no_icon' => (int) $row['no_icon'], 'checked_at' => $row['checked_at'],
'source_version' => (string) $row['source_version'],
];
}
}
return $status;
}