LuminaWebsite/gear.php
Maaxxs fab66f64d0 Gear planner: skill planner - skills of the set's class with planned level, stigma limit, point/shard costs, import from aion2hub
- Skills per class come from the aion2hub class pages (Global client core list only, Korea/Taiwan extras left out): 12 normal actives, then Dodge (no levels, dropped), then the stigma skills - matches the Global client's mastery and stigma lists for all 8 classes
- New tables gear_skills and gear_set_skills (schema version 35), skill icons stored under assets/uploads/skills/ (existing files are reused on re-import)
- Admin: "Skills" section on admin/gear_items.php imports/compares all classes (one request per second), marks skills aion2hub no longer lists and can remove them
- Set page: skill grid (active / stigma / passive) with level select and instant save; normal skills 1-10 by skill points, above that only with bonuses (Daevanion up to +4, gear and Arcana up to 20); stigmas up to 20, at most 4 at once (checked on the server too); shows skill point and stigma shard costs
- Planned skills on set cards, the profile page and in the comparison; copies take the skills along, a class change keeps the old levels hidden
- Patch notes entry, README section for the gear planner

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 17:17:59 +02:00

715 lines
47 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
/**
* Gear-Planer: eigene Ausruestungssets zusammenstellen, ihre Skills planen und vergleichen.
* /gear.php Uebersicht der eigenen Sets
* /gear.php?set=ID[&slot=KEY] ein Set (eigene bearbeitbar, fremde nur wenn aufs Profil freigegeben)
* /gear.php?compare[]=ID&… 2-4 Sets nebeneinander
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/gear.php';
require_permission('gear.view');
$me = current_user();
$userId = (int) $me['id'];
$canManage = user_has_permission('gear.manage');
$catalogCount = (int) db()->query('SELECT COUNT(*) FROM gear_items')->fetchColumn();
$mySets = gear_sets_for_user($userId);
$mySlots = gear_slots_for_sets(array_column($mySets, 'id'));
$mySkills = gear_set_skills_for_sets($mySets);
// ---- Welche Ansicht? ----
$set = null;
$compare = [];
if (isset($_GET['compare'])) {
foreach (array_slice(array_unique(array_map('intval', (array) $_GET['compare'])), 0, 4) as $compareId) {
$candidate = gear_set($compareId);
if ($candidate && gear_can_view_set($candidate)) {
$compare[] = $candidate;
}
}
if (count($compare) < 2) {
set_flash('error', 'Zum Vergleichen bitte mindestens zwei Sets auswählen.');
redirect('/gear.php');
}
} elseif (isset($_GET['set'])) {
$set = gear_set((int) $_GET['set']);
if (!$set || !gear_can_view_set($set)) {
show_not_found();
}
}
$isOwn = $set && gear_is_own_set($set);
$slots = $set ? (gear_slots_for_sets([(int) $set['id']])[(int) $set['id']] ?? []) : [];
$activeSlot = $set && isset(GEAR_SLOTS[$_GET['slot'] ?? '']) ? (string) $_GET['slot'] : '';
$activeRow = $activeSlot !== '' ? ($slots[$activeSlot] ?? null) : null;
$activeItem = $activeRow['item'] ?? null;
/** Kurzinfo eines belegten Slots: "+15 · Durchbruch 5 · 3/4 Manasteine" */
$slotTags = static function (?array $row): array {
if (!$row || empty($row['item'])) {
return [];
}
$item = $row['item'];
$tags = [];
if ((int) $item['enchant_max'] > 0) {
$tags[] = '+' . (int) $row['enchant'];
}
if ((int) $row['exceed'] > 0) {
$tags[] = '⬆' . (int) $row['exceed'];
}
if ((int) $item['manastone_slots'] > 0) {
$tags[] = '◆ ' . count($row['manastones']) . '/' . (int) $item['manastone_slots'];
}
return $tags;
};
/** Symbol eines Gegenstands (oder Platzhalter) */
$itemIcon = static function (?array $item, int $size = 40): string {
$url = gear_icon_url($item);
if ($url === null) {
return '<span class="gear-icon gear-icon-empty" style="width:' . $size . 'px;height:' . $size . 'px"></span>';
}
return '<img class="gear-icon ' . e(gear_grade_class($item['grade'] ?? null)) . '" src="' . e($url) . '" alt="" width="' . $size . '" height="' . $size . '" loading="lazy">';
};
$pageTitle = $set ? $set['name'] . ' - Gear-Planer' : 'Gear-Planer';
$containerWide = true;
include __DIR__ . '/includes/header.php';
?>
<div class="panel gear-head">
<div>
<h1>Gear-Planer</h1>
<p class="text-muted">
Stell Ausrüstungssets zusammen, plane die Skills deiner Klasse und vergleiche sie. Grundwerte,
Sockel, die Werte bei voller Aufwertung und die Skill-Listen stammen aus dem Spielclient (Global)
und werden von der Leitung abgeglichen; Werte mit <span class="gear-estimated">≈</span> sind für
Zwischenstufen hochgerechnet.
</p>
</div>
<div class="gear-head-actions">
<?php if ($set || $compare): ?>
<a class="button button-secondary" href="/gear.php">Meine Sets</a>
<?php endif; ?>
<?php if ($canManage): ?>
<a class="button button-secondary" href="/admin/gear_items.php"><?= icon('list') ?> Gegenstände &amp; Skills verwalten</a>
<?php endif; ?>
</div>
</div>
<?php if ($catalogCount === 0): ?>
<div class="panel gear-empty">
<p><strong>Noch keine Gegenstände im Katalog.</strong></p>
<p class="text-muted">
<?= $canManage
? 'Übernimm zuerst Gegenstände von aion2hub - danach lassen sie sich in die Sets einsetzen.'
: 'Die Leitung muss erst die Gegenstände übernehmen. Sets anlegen kannst du trotzdem schon.' ?>
</p>
<?php if ($canManage): ?><a class="button" href="/admin/gear_items.php">Gegenstände übernehmen</a><?php endif; ?>
</div>
<?php endif; ?>
<?php if ($compare): ?>
<?php
// ---- Vergleich ----
$compareSlots = gear_slots_for_sets(array_column($compare, 'id'));
$compareSkills = gear_set_skills_for_sets($compare);
// Alle Skills, die in mindestens einem Set geplant sind - nach Klasse (wie die Sets), dann wie auf der Klassenseite
$compareSkillRows = [];
foreach ($compare as $c) {
foreach ($compareSkills[(int) $c['id']] ?? [] as $skillId => $planned) {
$compareSkillRows[$skillId] ??= $planned['skill'];
}
}
$classOrder = array_flip(array_unique(array_map(static fn (array $c): string => (string) $c['class_name'], $compare)));
uasort($compareSkillRows, static fn (array $a, array $b): int =>
[$classOrder[$a['class_name']] ?? 99, $a['kind'], (int) $a['sort_order']] <=> [$classOrder[$b['class_name']] ?? 99, $b['kind'], (int) $b['sort_order']]);
$compareTotals = [];
$allKeys = [];
foreach ($compare as $c) {
$compareTotals[(int) $c['id']] = gear_set_totals($compareSlots[(int) $c['id']] ?? []);
foreach ($compareTotals[(int) $c['id']] as $key => $row) {
$allKeys[$key] = $row;
}
}
uksort($allKeys, static function (string $a, string $b) use ($allKeys): int {
$ia = array_search($allKeys[$a]['name'], GEAR_STAT_ORDER, true);
$ib = array_search($allKeys[$b]['name'], GEAR_STAT_ORDER, true);
return [$ia === false ? 99 : $ia, $allKeys[$a]['unit'], $a] <=> [$ib === false ? 99 : $ib, $allKeys[$b]['unit'], $b];
});
$first = (int) $compare[0]['id'];
?>
<div class="panel">
<h2>Vergleich</h2>
<p class="text-muted">Unterschiede beziehen sich immer auf das erste Set (links).</p>
<div class="table-scroll">
<table class="gear-compare">
<thead>
<tr>
<th></th>
<?php foreach ($compare as $c): ?>
<th>
<a href="/gear.php?set=<?= (int) $c['id'] ?>"><?= e($c['name']) ?></a>
<?= class_badge_html($c['class_name'], 18) ?>
<?php if ((int) $c['user_id'] !== $userId): ?><div class="text-muted gear-compare-owner"><?= e($c['owner_name']) ?></div><?php endif; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<tr class="gear-compare-group"><th colspan="<?= count($compare) + 1 ?>">Werte</th></tr>
<?php foreach ($allKeys as $key => $meta): ?>
<?php $base = $compareTotals[$first][$key]['total'] ?? 0.0; ?>
<tr>
<th><?= e($meta['name']) ?></th>
<?php foreach ($compare as $index => $c): ?>
<?php $row = $compareTotals[(int) $c['id']][$key] ?? null; $value = $row['total'] ?? 0.0; $diff = $value - $base; ?>
<td>
<?= $row ? ($row['estimated'] ? '<span class="gear-estimated" title="enthält hochgerechnete Zwischenstufen">≈</span>' : '') . e(gear_format_value($value, $meta['unit'])) : '<span class="text-muted">–</span>' ?>
<?php if ($index > 0 && abs($diff) > 0.001): ?>
<span class="gear-diff <?= $diff > 0 ? 'is-up' : 'is-down' ?>"><?= $diff > 0 ? '+' : '−' ?><?= e(gear_format_value(abs($diff), $meta['unit'])) ?></span>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
<tr class="gear-compare-group"><th colspan="<?= count($compare) + 1 ?>">Ausrüstung</th></tr>
<?php foreach (GEAR_SLOTS as $slotKey => [$slotLabel]): ?>
<tr>
<th><?= e($slotLabel) ?></th>
<?php foreach ($compare as $c): ?>
<?php $row = $compareSlots[(int) $c['id']][$slotKey] ?? null; ?>
<td>
<?php if ($row && $row['item']): ?>
<span class="gear-compare-item">
<?= $itemIcon($row['item'], 24) ?>
<span class="<?= e(gear_grade_class($row['item']['grade'])) ?>"><?= e($row['item']['name']) ?></span>
<span class="text-muted"><?= e(implode(' · ', $slotTags($row))) ?></span>
</span>
<?php else: ?>
<span class="text-muted">–</span>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
<?php if ($compareSkillRows): ?>
<tr class="gear-compare-group"><th colspan="<?= count($compare) + 1 ?>">Skills</th></tr>
<?php foreach ($compareSkillRows as $skillId => $skill): ?>
<?php $baseLevel = $compareSkills[$first][$skillId]['level'] ?? 0; ?>
<tr>
<th>
<span class="gear-compare-item">
<?php if ($skillIcon = gear_skill_icon_url($skill)): ?><img class="gear-skill-compare-icon" src="<?= e($skillIcon) ?>" alt="" width="22" height="22" loading="lazy"><?php endif; ?>
<?= e($skill['name']) ?>
<?php if ($skill['kind'] === 'stigma'): ?><span class="gear-skill-stigma-tag">Stigma</span><?php endif; ?>
</span>
</th>
<?php foreach ($compare as $index => $c): ?>
<?php $level = $compareSkills[(int) $c['id']][$skillId]['level'] ?? 0; ?>
<td>
<?php if ($level > 0): ?>
<span class="<?= gear_skill_is_bonus($skill['kind'], $level) ? 'gear-skill-bonus-text' : '' ?>"><?= $level ?></span>
<?php else: ?>
<span class="text-muted">–</span>
<?php endif; ?>
<?php if ($index > 0 && $c['class_name'] === $compare[0]['class_name'] && $level !== $baseLevel): ?>
<span class="gear-diff <?= $level > $baseLevel ? 'is-up' : 'is-down' ?>"><?= $level > $baseLevel ? '+' : '−' ?><?= abs($level - $baseLevel) ?></span>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php elseif ($set): ?>
<?php
$totals = gear_set_totals($slots);
$itemLevel = gear_set_item_level($slots);
$plannedSkills = gear_set_skills_for_sets([$set])[(int) $set['id']] ?? [];
?>
<div class="panel gear-set-head">
<div class="gear-set-title">
<h2><?= e($set['name']) ?> <?= class_badge_html($set['class_name'], 26) ?></h2>
<div class="text-muted">
<?php if (!$isOwn): ?>Set von <?= e($set['owner_name']) ?> · <?php endif; ?>
<?= count(array_filter($slots, static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots belegt
<?php if ($itemLevel !== null): ?> · Ø Gegenstandsstufe <?= e(number_format($itemLevel, 1, ',', '.')) ?><?php endif; ?>
<?php if ($plannedSkills): ?> · <a href="#skills"><?= count($plannedSkills) ?> <?= count($plannedSkills) === 1 ? 'Skill' : 'Skills' ?> geplant</a><?php endif; ?>
<?php if ($isOwn && $set['show_on_profile']): ?> · <span class="badge">auf dem Profil sichtbar</span><?php endif; ?>
</div>
<?php if (!empty($set['note'])): ?><p><?= e($set['note']) ?></p><?php endif; ?>
</div>
<div class="gear-set-actions">
<?php if (!empty($set['build_url']) && gear_build_host((string) $set['build_url']) !== null): ?>
<a class="button button-secondary" href="<?= e($set['build_url']) ?>" target="_blank" rel="noopener noreferrer nofollow"
title="Skills, Stigmen und Daevanion auf <?= e(gear_build_host((string) $set['build_url'])) ?>">Skill- &amp; Daevanion-Plan ↗</a>
<?php endif; ?>
<?php if ($isOwn): ?>
<button type="button" class="button button-secondary" data-modal-open="gear-set-edit"><?= icon('edit') ?> Bearbeiten</button>
<form method="post" action="/gear_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="duplicate">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<button type="submit" class="button button-secondary">Kopieren</button>
</form>
<?php endif; ?>
<?php $compareWith = array_values(array_filter($mySets, static fn (array $s): bool => (int) $s['id'] !== (int) $set['id'])); ?>
<?php if ($compareWith): ?>
<form method="get" action="/gear.php" class="gear-compare-with">
<input type="hidden" name="compare[]" value="<?= (int) $set['id'] ?>">
<select name="compare[]" aria-label="Vergleichen mit" onchange="this.form.submit()">
<option value="">Vergleichen mit …</option>
<?php foreach ($compareWith as $other): ?>
<option value="<?= (int) $other['id'] ?>"><?= e($other['name']) ?></option>
<?php endforeach; ?>
</select>
</form>
<?php endif; ?>
</div>
</div>
<div class="gear-layout">
<div class="panel gear-slots-panel">
<?php // Ausruestung als Raster wie im Spiel: zwei Slots pro Reihe, Name beim Drueberfahren ?>
<div class="gear-doll">
<?php foreach (GEAR_DOLL_ORDER as $slotKey): ?>
<?php
$slotLabel = GEAR_SLOTS[$slotKey][0];
$row = $slots[$slotKey] ?? null;
$item = $row['item'] ?? null;
// Passt nicht (mehr), z.B. nach einem Klassenwechsel: rot markiert, geloescht wird nichts
$mismatch = $item ? gear_item_mismatch($item, $slotKey, $set['class_name']) : null;
$tip = $slotLabel . ': ' . ($item ? $item['name'] . ($slotTags($row) ? ' (' . implode(' · ', $slotTags($row)) . ')' : '') : 'leer')
. ($mismatch !== null ? ' – ' . $mismatch : '');
?>
<a class="gear-doll-slot<?= $item ? ' is-filled ' . e(gear_grade_class($item['grade'])) : '' ?><?= $mismatch !== null ? ' is-mismatch' : '' ?><?= $slotKey === $activeSlot ? ' is-active' : '' ?>"
href="/gear.php?set=<?= (int) $set['id'] ?>&amp;slot=<?= e($slotKey) ?>#slot" title="<?= e($tip) ?>" aria-label="<?= e($tip) ?>">
<?php if ($item && ($iconUrl = gear_icon_url($item))): ?>
<img src="<?= e($iconUrl) ?>" alt="" loading="lazy">
<?php elseif ($item): ?>
<span class="gear-doll-initial"><?= e(mb_substr($item['name'], 0, 1)) ?></span>
<?php else: ?>
<?= gear_slot_silhouette($slotKey) ?>
<?php endif; ?>
<?php if ($item && (int) $row['exceed'] > 0): ?><span class="gear-doll-exceed">⬆<?= (int) $row['exceed'] ?></span><?php endif; ?>
<?php if ($item && (int) $row['enchant'] > 0): ?><span class="gear-doll-enchant">+<?= (int) $row['enchant'] ?></span><?php endif; ?>
<?php if ($item && (int) $item['manastone_slots'] > 0): ?>
<span class="gear-doll-stones" aria-hidden="true">
<?php for ($i = 0; $i < (int) $item['manastone_slots']; $i++): ?><i class="<?= $i < count($row['manastones']) ? 'is-set' : '' ?>"></i><?php endfor; ?>
</span>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>
<p class="gear-doll-hint text-muted"><?= $isOwn ? 'Slot anklicken zum Bearbeiten' : 'Slot anklicken für Details' ?></p>
</div>
<div class="gear-side">
<?php if ($activeSlot !== ''): ?>
<div class="panel gear-slot-editor" id="slot">
<h3><?= e(GEAR_SLOTS[$activeSlot][0]) ?></h3>
<?php if ($activeItem): ?>
<?php $activeMismatch = gear_item_mismatch($activeItem, $activeSlot, $set['class_name']); ?>
<div class="gear-item-card">
<?= $itemIcon($activeItem, 48) ?>
<div>
<strong class="<?= e(gear_grade_class($activeItem['grade'])) ?>"><?= e($activeItem['name']) ?></strong>
<?php if ($activeMismatch !== null): ?><span class="badge badge-disabled"><?= e($activeMismatch) ?></span><?php endif; ?>
<div class="text-muted">
<?= e($activeItem['grade']) ?> · Stufe <?= (int) $activeItem['item_level'] ?>
<?= $activeItem['item_type'] !== $activeItem['slot'] ? ' · ' . e(gear_type_label($activeItem['item_type'])) : '' ?>
· <a href="<?= e(GEAR_SOURCE_ITEM_URL . (int) $activeItem['id']) ?>" target="_blank" rel="noopener">aion2hub</a>
</div>
<div class="gear-item-stats"><?= e(gear_stats_text($activeItem['stats'])) ?></div>
</div>
</div>
<?php endif; ?>
<?php if ($isOwn): ?>
<?php $pickerItems = gear_picker_items($activeSlot, $set['class_name'], $activeItem ? (int) $activeItem['id'] : 0); ?>
<form method="post" action="/gear_action.php" class="gear-slot-form" data-autosave>
<?= csrf_field() ?>
<input type="hidden" name="action" value="save_slot">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<input type="hidden" name="slot" value="<?= e($activeSlot) ?>">
<div>
<label for="gear-item-search">Gegenstand</label>
<div class="item-picker" data-picker-items="gear-picker" data-picker-mode="id" data-picker-empty="Nichts gefunden - fehlt ein Gegenstand, sag der Leitung Bescheid.">
<label class="search-field">
<span class="item-picker-icon"><?= icon('search') ?></span>
<input type="text" class="item-picker-input" id="gear-item-search" required placeholder="<?= $pickerItems ? 'Gegenstand suchen …' : 'Noch keine Gegenstände für diesen Slot' ?>">
</label>
<input type="hidden" name="item_id" value="<?= $activeItem ? (int) $activeItem['id'] : '' ?>">
</div>
<script type="application/json" id="gear-picker"><?= json_encode($pickerItems, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP) ?></script>
<?php if ($activeSlot === 'main_hand'): ?>
<p class="gear-hint text-muted">
<?= isset(GEAR_CLASS_WEAPONS[$set['class_name'] ?? ''])
? 'Nur Waffen für ' . e($set['class_name']) . ' – Klasse ändern unter „Bearbeiten“.'
: 'Tipp: Klasse im Set wählen, dann siehst du nur passende Waffen.' ?>
</p>
<?php endif; ?>
</div>
<?php if ($activeItem): ?>
<div class="gear-form-row">
<?php if ((int) $activeItem['enchant_max'] > 0): ?>
<label>Aufwertung
<select name="enchant">
<?php for ($level = 0; $level <= (int) $activeItem['enchant_max']; $level++): ?>
<option value="<?= $level ?>"<?= (int) $activeRow['enchant'] === $level ? ' selected' : '' ?>>+<?= $level ?></option>
<?php endfor; ?>
</select>
</label>
<?php endif; ?>
<?php if ((int) $activeItem['exceed_max'] > 0): ?>
<label>Durchbruch
<select name="exceed">
<?php for ($level = 0; $level <= (int) $activeItem['exceed_max']; $level++): ?>
<option value="<?= $level ?>"<?= (int) $activeRow['exceed'] === $level ? ' selected' : '' ?>><?= $level ?></option>
<?php endfor; ?>
</select>
</label>
<?php endif; ?>
</div>
<?php if ($activeItem['enchant_stats']): ?>
<p class="gear-hint text-muted">
Bei +<?= (int) $activeItem['enchant_max'] ?>: <?= e(gear_stats_text($activeItem['enchant_stats'])) ?>
<?php if ($activeItem['exceed_stats']): ?><br>Durchbruch <?= (int) $activeItem['exceed_max'] ?>: <?= e(gear_stats_text($activeItem['exceed_stats'])) ?><?php endif; ?>
</p>
<?php endif; ?>
<?php if ((int) $activeItem['soul_imprint_count'] > 0): ?>
<fieldset class="gear-fieldset">
<legend>Seelenprägung <span class="text-muted">(bis zu <?= (int) $activeItem['soul_imprint_count'] ?>, wie im Spiel gewürfelt)</span></legend>
<?php for ($i = 0; $i < (int) $activeItem['soul_imprint_count']; $i++): ?>
<?php $entry = $activeRow['soul_imprint'][$i] ?? null; ?>
<div class="gear-roll-row">
<select name="soul_stat[]" aria-label="Seelenprägung <?= $i + 1 ?>" data-range-select>
<option value="">– keine –</option>
<?php foreach ($activeItem['soul_imprint'] as [$stat, $min, $max, $unit]): ?>
<option value="<?= e($stat) ?>" data-min="<?= e((string) $min) ?>" data-max="<?= e((string) $max) ?>" data-unit="<?= e($unit) ?>"<?= $entry && $entry[0] === $stat ? ' selected' : '' ?>>
<?= e($stat) ?> (<?= e(gear_format_value((float) $min, $unit)) ?>–<?= e(gear_format_value((float) $max, $unit)) ?>)
</option>
<?php endforeach; ?>
</select>
<input type="text" inputmode="decimal" name="soul_value[]" value="<?= $entry ? e(str_replace('.', ',', (string) $entry[1])) : '' ?>" placeholder="Wert" aria-label="Wert Seelenprägung <?= $i + 1 ?>">
</div>
<?php endfor; ?>
</fieldset>
<?php endif; ?>
<?php if ((int) $activeItem['manastone_slots'] > 0): ?>
<?php $manastoneStats = gear_manastone_stats(); ?>
<fieldset class="gear-fieldset">
<legend>Manasteine <span class="text-muted">(<?= (int) $activeItem['manastone_slots'] ?> Sockel)</span></legend>
<?php for ($i = 0; $i < (int) $activeItem['manastone_slots']; $i++): ?>
<?php $entry = $activeRow['manastones'][$i] ?? null; ?>
<div class="gear-roll-row">
<select name="mana_stat[]" aria-label="Manastein <?= $i + 1 ?>">
<option value="">– leer –</option>
<?php foreach ($manastoneStats as $stat): ?>
<option value="<?= e($stat) ?>"<?= $entry && $entry[0] === $stat ? ' selected' : '' ?>><?= e($stat) ?></option>
<?php endforeach; ?>
</select>
<input type="text" inputmode="numeric" name="mana_value[]" value="<?= $entry ? (int) $entry[1] : '' ?>" placeholder="Wert" aria-label="Wert Manastein <?= $i + 1 ?>">
</div>
<?php endfor; ?>
</fieldset>
<?php endif; ?>
<?php if ((int) $activeItem['godstone_slots'] > 0): ?>
<label>Götterstein <span class="text-muted">(nur zur Info, zählt nicht in die Werte)</span>
<input type="text" name="godstone" maxlength="100" value="<?= e((string) ($activeRow['godstone'] ?? '')) ?>" placeholder="z.B. Götterstein: …">
</label>
<?php endif; ?>
<p class="gear-hint text-muted">Wechselst du den Gegenstand, werden Seelenprägung und Manasteine zurückgesetzt.</p>
<?php endif; ?>
<div class="actions gear-slot-actions">
<?php // Mit JavaScript speichert das Formular automatisch (assets/js/gear.js) - der Knopf verschwindet dann ?>
<button type="submit" class="button" data-autosave-fallback>Speichern</button>
<span class="gear-save-status" aria-live="polite"></span>
<a class="button button-secondary" href="/gear.php?set=<?= (int) $set['id'] ?>">Schließen</a>
</div>
</form>
<?php if ($activeItem): ?>
<form method="post" action="/gear_action.php" class="gear-clear-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="clear_slot">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<input type="hidden" name="slot" value="<?= e($activeSlot) ?>">
<button type="submit" class="button button-secondary button-small">Slot leeren</button>
</form>
<?php endif; ?>
<?php elseif ($activeItem): ?>
<dl class="gear-detail-list">
<?php if ((int) $activeItem['enchant_max'] > 0): ?><div><dt>Aufwertung</dt><dd>+<?= (int) $activeRow['enchant'] ?> von +<?= (int) $activeItem['enchant_max'] ?></dd></div><?php endif; ?>
<?php if ((int) $activeItem['exceed_max'] > 0): ?><div><dt>Durchbruch</dt><dd><?= (int) $activeRow['exceed'] ?> von <?= (int) $activeItem['exceed_max'] ?></dd></div><?php endif; ?>
<?php if ($activeRow['soul_imprint']): ?>
<div><dt>Seelenprägung</dt><dd><?= e(implode(', ', array_map(static fn (array $s): string => $s[0] . ' ' . str_replace('.', ',', (string) $s[1]), $activeRow['soul_imprint']))) ?></dd></div>
<?php endif; ?>
<?php if ($activeRow['manastones']): ?>
<div><dt>Manasteine</dt><dd><?= e(implode(', ', array_map(static fn (array $s): string => $s[0] . ' ' . (int) $s[1], $activeRow['manastones']))) ?></dd></div>
<?php endif; ?>
<?php if (!empty($activeRow['godstone'])): ?><div><dt>Götterstein</dt><dd><?= e((string) $activeRow['godstone']) ?></dd></div><?php endif; ?>
</dl>
<?php else: ?>
<p class="text-muted">Dieser Slot ist leer.</p>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="panel gear-totals">
<h3>Werte gesamt</h3>
<?php if (!$totals): ?>
<p class="text-muted">Noch keine Gegenstände eingesetzt.</p>
<?php else: ?>
<?php $usedSources = array_keys(array_filter(GEAR_SOURCES, static fn (string $label, string $source): bool => (bool) array_filter($totals, static fn (array $t): bool => isset($t['by'][$source])), ARRAY_FILTER_USE_BOTH)); ?>
<div class="table-scroll">
<table class="gear-totals-table">
<thead>
<tr>
<th>Wert</th>
<th class="gear-total-col">Gesamt</th>
<?php foreach ($usedSources as $source): ?><th class="gear-source-col"><?= e(GEAR_SOURCES[$source]) ?></th><?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($totals as $row): ?>
<tr>
<th><?= e($row['name']) ?></th>
<td class="gear-total-col">
<?php if ($row['estimated']): ?><span class="gear-estimated" title="enthält hochgerechnete Zwischenstufen">≈</span><?php endif; ?>
<?= e(gear_format_value($row['total'], $row['unit'])) ?>
</td>
<?php foreach ($usedSources as $source): ?>
<td class="gear-source-col"><?= isset($row['by'][$source]) ? e(gear_format_value($row['by'][$source], $row['unit'])) : '<span class="text-muted">–</span>' ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<p class="gear-hint text-muted">Einfache Summe aller Gegenstände - Klassen- und Charakterwerte, Set-Boni und Götterstein sind nicht enthalten.</p>
<?php endif; ?>
</div>
</div>
</div>
<?php
// ---- Skills der Klasse mit geplanter Stufe ----
$skillLevels = gear_set_skill_levels((int) $set['id']);
// Skills, die aion2hub nicht mehr listet, nur zeigen, wenn sie in diesem Set eine Stufe haben
$classSkills = array_filter(
gear_skills_for_class($set['class_name'], false),
static fn (array $skill): bool => (int) $skill['is_listed'] === 1 || isset($skillLevels[(int) $skill['id']])
);
?>
<div class="panel gear-skills" id="skills">
<div class="gear-skills-head">
<h3>Skills<?= !empty($set['class_name']) ? ' · ' . e($set['class_name']) : '' ?></h3>
<?php if ($classSkills): ?>
<span class="text-muted" data-skill-summary><?= e(gear_skill_summary($plannedSkills)) ?></span>
<span class="gear-skill-costs" data-skill-costs title="Was die geplanten Stufen kosten (Skillpunkte nur bis Stufe <?= GEAR_SKILL_LEVEL_SELF ?>)"><?= e(gear_skill_costs_text($plannedSkills)) ?></span>
<?php if ($isOwn): ?><span class="gear-save-status" data-skill-status aria-live="polite"></span><?php endif; ?>
<?php endif; ?>
</div>
<?php if (empty($set['class_name'])): ?>
<p class="text-muted"><?= $isOwn ? 'Wähle unter „Bearbeiten“ eine Klasse für das Set – dann planst du hier ihre Skills.' : 'Für dieses Set ist keine Klasse gewählt.' ?></p>
<?php elseif (!$classSkills): ?>
<p class="text-muted">
Für <?= e($set['class_name']) ?> sind noch keine Skills da<?= $canManage ? '' : ' – die Leitung muss sie erst übernehmen' ?>.
<?php if ($canManage): ?><a href="/admin/gear_items.php#skills">Jetzt von aion2hub übernehmen</a><?php endif; ?>
</p>
<?php else: ?>
<p class="gear-hint text-muted gear-skills-legend">
Aktive und passive Skills steigerst du mit Skillpunkten bis Stufe <?= GEAR_SKILL_LEVEL_SELF ?>, darüber nur mit Boni:
<span class="gear-skill-bonus-text">die Daevanion-Bretter geben bis +<?= GEAR_SKILL_DAEVANION_BONUS ?>, Ausrüstung und Arcana den Rest bis <?= GEAR_SKILL_LEVEL_MAX ?></span>.
Stigma-Skills steigen mit Stigma-Splittern bis <?= GEAR_STIGMA_LEVEL_MAX ?>, ausrüsten kannst du höchstens <?= GEAR_STIGMA_SLOTS ?> gleichzeitig.
</p>
<details class="gear-skills-details">
<summary>Kosten und Stand der Daten</summary>
<p class="gear-hint text-muted">
Skillpunkte: Stufe 1 gibt es beim Lernen, Stufe 2–4 kosten je 1 Punkt, 5–7 je 2, 8–10 je 4 – also 21 Punkte bis
Stufe 10. Mit Stufe 45 hat man etwa 230–250 Skillpunkte, alle Skills auf 10 bräuchten gut 460.
Stigma-Splitter: Stufe 1–5 je 1, 6–10 je 2, 11–15 je 4, 16–20 je 8 – 75 bis Stufe 20.
Stand: Global-Client des Launch-Tests und offizieller Guide aus Korea (September 2026) – nach dem Launch gleichen
wir die Zahlen ab. Skill-Liste aus dem Global-Client, Namen wie bei aion2hub (deutsche Namen folgen, sobald sie feststehen).
</p>
</details>
<?php if ($isOwn): ?>
<form method="post" action="/gear_action.php" class="gear-skills-form" data-skills-autosave
data-self-max="<?= GEAR_SKILL_LEVEL_SELF ?>" data-stigma-slots="<?= GEAR_STIGMA_SLOTS ?>">
<?= csrf_field() ?>
<input type="hidden" name="action" value="save_skills">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<?php endif; ?>
<?php
// Stigmen: hoechstens GEAR_STIGMA_SLOTS gleichzeitig - sind alle belegt, sind die uebrigen gesperrt
$stigmaPlanned = count(array_filter($classSkills, static fn (array $skill): bool =>
$skill['kind'] === 'stigma' && isset($skillLevels[(int) $skill['id']])));
?>
<?php foreach (GEAR_SKILL_KINDS as $kind => $kindLabel): ?>
<?php $kindSkills = array_filter($classSkills, static fn (array $skill): bool => $skill['kind'] === $kind); ?>
<?php if (!$kindSkills) { continue; } ?>
<h4 class="gear-skills-kind">
<?= e($kindLabel) ?>
<?php if ($kind === 'stigma'): ?>
<span class="gear-skills-kind-count<?= $stigmaPlanned >= GEAR_STIGMA_SLOTS ? ' is-full' : '' ?>" data-stigma-count><?= $stigmaPlanned ?> von <?= GEAR_STIGMA_SLOTS ?> ausgewählt</span>
<?php endif; ?>
</h4>
<div class="gear-skill-grid">
<?php foreach ($kindSkills as $skill): ?>
<?php
$level = $skillLevels[(int) $skill['id']] ?? 0;
$skillIcon = gear_skill_icon_url($skill);
$unlisted = (int) $skill['is_listed'] !== 1;
?>
<div class="gear-skill<?= $level > 0 ? ' is-planned' : '' ?><?= gear_skill_is_bonus($kind, $level) ? ' is-bonus' : '' ?><?= $unlisted ? ' is-unlisted' : '' ?>"
data-skill data-kind="<?= e($kind) ?>">
<span class="gear-skill-icon">
<?php if ($skillIcon): ?>
<img src="<?= e($skillIcon) ?>" alt="" width="36" height="36" loading="lazy">
<?php else: ?>
<span class="gear-skill-initial"><?= e(mb_substr($skill['name'], 0, 1)) ?></span>
<?php endif; ?>
<span class="gear-skill-level" data-skill-badge><?= $level > 0 ? $level : '' ?></span>
</span>
<span class="gear-skill-info">
<span class="gear-skill-name" title="<?= e($skill['name']) ?>"><?= e($skill['name']) ?></span>
<span class="gear-skill-cat <?= e(gear_skill_category_class($skill['category'])) ?>">
<?= $unlisted ? 'nicht mehr in der Liste' : e(gear_skill_category_label($skill['category'])) ?>
</span>
</span>
<?php if ($isOwn): ?>
<select name="level[<?= (int) $skill['id'] ?>]" aria-label="Stufe von <?= e($skill['name']) ?>" data-skill-level
<?= $kind === 'stigma' && $level === 0 && $stigmaPlanned >= GEAR_STIGMA_SLOTS ? ' disabled title="Schon ' . GEAR_STIGMA_SLOTS . ' Stigmen ausgewählt"' : '' ?>>
<option value="0"<?= $level === 0 ? ' selected' : '' ?>>–</option>
<?php foreach (gear_skill_level_groups($kind) as $groupLabel => $groupLevels): ?>
<?php if ($groupLabel !== ''): ?><optgroup label="<?= e($groupLabel) ?>"><?php endif; ?>
<?php foreach ($groupLevels as $l): ?>
<option value="<?= $l ?>"<?= $level === $l ? ' selected' : '' ?>><?= $l ?></option>
<?php endforeach; ?>
<?php if ($groupLabel !== ''): ?></optgroup><?php endif; ?>
<?php endforeach; ?>
</select>
<?php else: ?>
<span class="gear-skill-level-text"><?= $level > 0 ? 'Stufe ' . $level : '–' ?></span>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
<?php if ($isOwn): ?>
<div class="actions gear-skills-actions">
<?php // Mit JavaScript speichert jede Aenderung sofort (assets/js/gear.js) - der Knopf verschwindet dann ?>
<button type="submit" class="button" data-autosave-fallback>Skills speichern</button>
</div>
</form>
<?php endif; ?>
<?php endif; ?>
</div>
<?php if ($isOwn): ?>
<div class="modal-overlay" id="gear-set-edit" hidden>
<div class="modal">
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
<h2>Set bearbeiten</h2>
<form method="post" action="/gear_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<label>Name <input type="text" name="name" maxlength="80" required value="<?= e($set['name']) ?>"></label>
<label>Klasse
<select name="class_name">
<option value="">– keine –</option>
<?php foreach (AION_CLASSES as $class): ?>
<option value="<?= e($class) ?>"<?= $set['class_name'] === $class ? ' selected' : '' ?>><?= e($class) ?></option>
<?php endforeach; ?>
</select>
</label>
<label>Notiz <input type="text" name="note" maxlength="255" value="<?= e((string) $set['note']) ?>" placeholder="z.B. PvP, Raid, Ziel-Ausrüstung …"></label>
<label>Link zum Skill- &amp; Daevanion-Plan <span class="text-muted">(optional)</span>
<input type="url" name="build_url" maxlength="<?= GEAR_BUILD_URL_MAX ?>" value="<?= e((string) ($set['build_url'] ?? '')) ?>" placeholder="https://aion2hub.com/…">
</label>
<p class="field-hint">Die Skillstufen planst du direkt hier im Set. Daevanion-Bretter (und was die Website sonst noch nicht kennt) planst du auf einer Planer-Seite (<?= e(implode(', ', GEAR_BUILD_HOSTS)) ?>) und fügst hier den Link ein - er erscheint beim Set und auf deiner Profilseite.</p>
<label class="checkbox-label"><input type="checkbox" name="show_on_profile" value="1"<?= $set['show_on_profile'] ? ' checked' : '' ?>> Auf meiner Profilseite zeigen</label>
<div class="actions">
<button type="submit" class="button">Speichern</button>
</div>
</form>
<form method="post" action="/gear_action.php" data-confirm="Set „<?= e($set['name']) ?>“ wirklich löschen?" data-confirm-title="Set löschen" data-confirm-danger data-confirm-ok="Löschen" class="gear-delete-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<button type="submit" class="button button-danger button-small"><?= icon('trash') ?> Set löschen</button>
</form>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<?php // ---- Uebersicht der eigenen Sets ---- ?>
<div class="panel">
<div class="gear-overview-head">
<h2>Meine Sets</h2>
<form method="post" action="/gear_action.php" class="gear-create-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="create">
<input type="text" name="name" maxlength="80" required placeholder="Name, z.B. Raid-Set" aria-label="Name des neuen Sets">
<select name="class_name" aria-label="Klasse">
<option value=""<?= empty($me['class_name']) ? ' selected' : '' ?>>– keine Klasse –</option>
<?php foreach (AION_CLASSES as $class): ?>
<option value="<?= e($class) ?>"<?= ($me['class_name'] ?? '') === $class ? ' selected' : '' ?>><?= e($class) ?></option>
<?php endforeach; ?>
</select>
<button type="submit" class="button">Neues Set</button>
</form>
</div>
<?php if (!$mySets): ?>
<p class="text-muted">Du hast noch kein Set. Leg oben eins an - z.B. deine aktuelle Ausrüstung und ein Ziel-Set zum Vergleichen.</p>
<?php else: ?>
<form method="get" action="/gear.php" id="gear-compare-form">
<div class="gear-set-cards">
<?php foreach ($mySets as $s): ?>
<?php $sSlots = $mySlots[(int) $s['id']] ?? []; $sLevel = gear_set_item_level($sSlots); $sSkills = $mySkills[(int) $s['id']] ?? []; ?>
<article class="gear-set-card">
<label class="gear-set-card-check" title="Zum Vergleich auswählen">
<input type="checkbox" name="compare[]" value="<?= (int) $s['id'] ?>">
</label>
<a class="gear-set-card-link" href="/gear.php?set=<?= (int) $s['id'] ?>">
<span class="gear-set-card-title"><?= e($s['name']) ?> <?= class_badge_html($s['class_name'], 20) ?></span>
<span class="text-muted">
<?= count(array_filter($sSlots, static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots
<?php if ($sLevel !== null): ?> · Ø Stufe <?= e(number_format($sLevel, 1, ',', '.')) ?><?php endif; ?>
<?php if ($sSkills): ?> · <?= count($sSkills) ?> Skills<?php endif; ?>
<?php if ($s['show_on_profile']): ?> · auf dem Profil<?php endif; ?>
</span>
<?= gear_doll_mini_html($sSlots) ?>
<?= gear_skills_mini_html($sSkills) ?>
<?php if (!empty($s['note'])): ?><span class="gear-set-card-note"><?= e($s['note']) ?></span><?php endif; ?>
</a>
</article>
<?php endforeach; ?>
</div>
<?php if (count($mySets) > 1): ?>
<div class="actions gear-compare-bar">
<button type="submit" class="button button-secondary" id="gear-compare-button" disabled>Ausgewählte vergleichen</button>
<span class="text-muted">2–4 Sets anhaken</span>
</div>
<?php endif; ?>
</form>
<?php endif; ?>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
<script src="<?= e(asset_url('/assets/js/gear.js')) ?>"></script>
<?php include __DIR__ . '/includes/footer.php'; ?>