LuminaWebsite/gear.php
Maaxxs 3cc60c7f7e Skill planner: set pages Ausrüstung / Skills / Stigmen, specializations and stigma bonuses with their effects from the aion2hub build planner
- Each set has three pages (tabs with counters): equipment, skills (active and passive) and stigmas; the skill pages live in includes/gear_skills_view.php
- Specializations of active skills like in the aion2hub planner: collapsible list with unlock level and effect, three from level 8, one from 12, one from 16; one slot at 8, two at 12, three at 20; locked options are disabled, lowering the level drops options that no longer fit (checked on the server too, stored as bitmask gear_set_skills.specs)
- Stigmas: the chosen ones as the 4 slots on top, each stigma lists its four bonuses at 5/10/15/20 with effect, reached ones are highlighted
- Admin: "Spezialisierungen & Stigma-Boni übernehmen" reads the build planner page, finds the JavaScript file with the data set (one request per second, remembers the file) and stores the effects of all classes (gear_skills.spec_effects); new page "Namen & Spezialisierungen" (admin/gear_skills.php) for German skill names and texts
- Autosave sends level and specializations per skill card, the tab counter updates live; compare shows specializations, copies keep them
- Schema version 39 (gear_skills.name_de, spec_effects, spec_names; gear_set_skills.specs), patch notes, README

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

636 lines
41 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: Ausruestung (eigene bearbeitbar, fremde nur wenn aufs Profil freigegeben)
* /gear.php?set=ID&tab=skills|stigma Unterseiten Skills und Stigmen des Sets (includes/gear_skills_view.php)
* /gear.php?compare[]=ID&… 2-4 Sets nebeneinander
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/gear.php';
require_once __DIR__ . '/includes/gear_skills_view.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'] : '';
// Unterseite des Sets: Ausruestung (Standard, auch beim Bearbeiten eines Slots), Skills oder Stigmen
$tab = (string) ($_GET['tab'] ?? 'gear');
if (!isset(GEAR_SET_TABS[$tab]) || $activeSlot !== '') {
$tab = 'gear';
}
$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'] . ($tab !== 'gear' ? ' · ' . GEAR_SET_TABS[$tab] : '') . ' - 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(gear_skill_display_name($skill)) ?>
<?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;
$specNumbers = gear_skill_spec_numbers($compareSkills[(int) $c['id']][$skillId]['specs'] ?? 0);
?>
<td>
<?php if ($level > 0): ?>
<span class="<?= gear_skill_is_bonus($skill['kind'], $level) ? 'gear-skill-bonus-text' : '' ?>"><?= $level ?></span>
<?php if ($specNumbers): ?>
<span class="text-muted" title="<?= e(implode(', ', array_map(static fn (int $no): string => gear_skill_spec_label($skill, $no), $specNumbers))) ?>">
· <?= e(implode(', ', array_map(static fn (int $no): string => GEAR_SKILL_SPEC_NUMERALS[$no], $specNumbers))) ?>
</span>
<?php endif; ?>
<?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 ($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>
<?php
// Reiter: Ausruestung, Skills, Stigmen - jede eine eigene Seite
$tabCounts = [
'gear' => count(array_filter($slots, static fn (array $row): bool => !empty($row['item']))) . '/' . count(GEAR_SLOTS),
'skills' => (string) count(gear_skills_of_tab($plannedSkills, 'skills')),
'stigma' => count(gear_skills_of_tab($plannedSkills, 'stigma')) . '/' . GEAR_STIGMA_SLOTS,
];
?>
<nav class="gear-tabs" aria-label="Bereiche des Sets">
<?php foreach (GEAR_SET_TABS as $tabKey => $tabLabel): ?>
<a class="gear-tab<?= $tab === $tabKey ? ' is-active' : '' ?>" href="/gear.php?set=<?= (int) $set['id'] ?><?= $tabKey !== 'gear' ? '&amp;tab=' . $tabKey : '' ?>"<?= $tab === $tabKey ? ' aria-current="page"' : '' ?>>
<?= e($tabLabel) ?> <span class="gear-tab-count"><?= e($tabCounts[$tabKey]) ?></span>
</a>
<?php endforeach; ?>
</nav>
<?php if ($tab !== 'gear'): ?>
<?php gear_render_skill_tab($set, $tab, $isOwn, $canManage); ?>
<?php else: ?>
<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 endif; ?>
<?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'; ?>