'Siel', 1302 => 'Nezekan', 1303 => 'Vaizel', 1304 => 'Kaisinel', 1305 => 'Yustiel', 1306 => 'Ariel', 1307 => 'Fregion', 1308 => 'Meslamtaeda', 1309 => 'Hithanya', 1310 => 'Nania', 1311 => 'Tahavatha', 1312 => 'Luteros', 1313 => 'Phernos', 1314 => 'Daminu', 1315 => 'Kasaka', 1316 => 'Bakarma', 1317 => 'Tsenka', 1318 => 'Kochi', 1319 => 'Ishtar', 1320 => 'Tiamat', 1321 => 'Gauss', 1322 => 'Lamuatan', ]; const ARMORY_DEFAULT_SERVER = 1304; // Klasse laut Suche (pcId: je vier IDs pro Klasse, ab 5) und laut Charakterinfo (deutscher Name) -> AION_CLASSES const ARMORY_PC_CLASSES = ['Gladiator', 'Templer', 'Jäger', 'Assassine', 'Beschwörer', 'Magier', 'Kleriker', 'Kantor']; const ARMORY_CLASS_NAMES = ['Waldläufer' => 'Jäger', 'Ranger' => 'Jäger', 'Templar' => 'Templer', 'Assassin' => 'Assassine', 'Spiritmaster' => 'Beschwörer', 'Elementalist' => 'Beschwörer', 'Sorcerer' => 'Magier', 'Cleric' => 'Kleriker', 'Chanter' => 'Kantor']; // Seltenheit bei NCSoft -> Farbe wie im Gear-Planer (NCSoft "Legend" heisst auf Deutsch "Episch" und ist blau) const ARMORY_GRADES = ['Common' => 'common', 'Rare' => 'rare', 'Legend' => 'epic', 'Unique' => 'unique', 'Epic' => 'heroic', 'Mythic' => 'heroic', 'Special' => 'special']; // Slots der Ausruestung (slotPosName) -> Slots des Gear-Planers (GEAR_SLOTS, includes/gear.php) const ARMORY_SLOTS = [ 'MainHand' => 'main_hand', 'SubHand' => 'off_hand', 'Helmet' => 'head', 'Shoulder' => 'shoulder', 'Torso' => 'torso', 'Gloves' => 'gloves', 'Pants' => 'pants', 'Boots' => 'boots', 'Cape' => 'cape', 'Necklace' => 'necklace', 'Earring1' => 'earring_1', 'Earring2' => 'earring_2', 'Ring1' => 'ring_1', 'Ring2' => 'ring_2', 'Bracelet1' => 'bracelet_1', 'Bracelet2' => 'bracelet_2', 'Belt' => 'belt', 'Amulet' => 'amulet', ]; // Weitere Slots (Runen), die es im Gear-Planer nicht gibt const ARMORY_EXTRA_SLOTS = ['Rune1' => 'Rune 1', 'Rune2' => 'Rune 2']; // Grundwerte und Werte der Gottheiten (statList.type), in dieser Reihenfolge const ARMORY_BASE_STATS = ['STR', 'DEX', 'INT', 'CON', 'AGI', 'WIS']; const ARMORY_GOD_STATS = ['Justice', 'Freedom', 'Illusion', 'Life', 'Time', 'Destruction', 'Death', 'Wisdom', 'Destiny', 'Space']; /** * Fragt eine Schnittstelle von NCSoft ab (nur aion2.plaync.com und die Charaktersuche, kein Weiterleiten). * * @return array * @throws RuntimeException mit verstaendlicher Meldung (Code 404 = Charakter/Gegenstand nicht gefunden) */ function armory_request(string $url): array { $host = strtolower((string) parse_url($url, PHP_URL_HOST)); if (parse_url($url, PHP_URL_SCHEME) !== 'https' || !in_array($host, [ARMORY_API_HOST, 'api-search.plaync.com'], true)) { throw new RuntimeException('Unerlaubte Adresse.'); } if (!function_exists('curl_init')) { throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.'); } $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => false, CURLOPT_TIMEOUT => 10, CURLOPT_CONNECTTIMEOUT => 4, CURLOPT_USERAGENT => ARMORY_AGENT, CURLOPT_HTTPHEADER => ['Accept: application/json'], ]); $body = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); if ($body === false) { throw new RuntimeException('Die Aion-2-Seite von NCSoft ist gerade nicht erreichbar (' . $error . ').'); } if ($status === 404) { throw new RuntimeException('Diesen Charakter gibt es im Spiel nicht (mehr).', 404); } if ($status !== 200) { throw new RuntimeException('Die Aion-2-Seite von NCSoft antwortet mit Status ' . $status . '.'); } $data = json_decode((string) $body, true); if (!is_array($data)) { throw new RuntimeException('Die Aion-2-Seite von NCSoft hat unerwartet geantwortet.'); } return $data; } /** Abfrage-Teil fuer einen Charakter (Sprache, Charakter, Server, Region). */ function armory_query(string $charId, int $serverId, array $extra = []): string { return http_build_query(array_merge(['lang' => ARMORY_LANG, 'characterId' => $charId, 'serverId' => $serverId], $extra, ['region' => ARMORY_REGION])); } function armory_server_name(?int $serverId): string { return ARMORY_SERVERS[$serverId ?? 0] ?? ('Server ' . (int) $serverId); } function armory_class_from_pc(int $pcId): ?string { return $pcId >= 5 ? (ARMORY_PC_CLASSES[intdiv($pcId - 5, 4)] ?? null) : null; } function armory_class_name(string $name): ?string { $name = ARMORY_CLASS_NAMES[$name] ?? $name; return in_array($name, AION_CLASSES, true) ? $name : null; } function armory_grade_class(?string $grade): string { return 'grade-' . (ARMORY_GRADES[$grade ?? ''] ?? 'common'); } /** * Sucht Elyos-Charaktere auf einem Server (Namensteil, wie die Suche auf aion2.plaync.com). * * @return array */ function armory_search(string $name, int $serverId): array { $data = armory_request(ARMORY_SEARCH_URL . '?' . http_build_query([ 'keyword' => $name, 'page' => 1, 'size' => 20, 'localeInfo' => ARMORY_LANG, 'region' => ARMORY_REGION, 'serverId' => $serverId, ])); $results = []; foreach ((array) ($data['list'] ?? []) as $row) { if (!is_array($row) || (int) ($row['race'] ?? 1) !== 1 || (int) ($row['serverId'] ?? 0) !== $serverId) { continue; } // Die Suche hebt den Treffer mit hervor und liefert die ID URL-kodiert $results[] = [ 'id' => rawurldecode((string) ($row['characterId'] ?? '')), 'name' => html_entity_decode(strip_tags((string) ($row['name'] ?? '')), ENT_QUOTES, 'UTF-8'), 'level' => (int) ($row['level'] ?? 0), 'class' => armory_class_from_pc((int) ($row['pcId'] ?? 0)), 'server_id' => $serverId, 'server' => armory_server_name($serverId), ]; } // Genauer Name zuerst, dann hoechste Stufe $lower = mb_strtolower($name); usort($results, static fn (array $a, array $b): int => [mb_strtolower($a['name']) !== $lower, -$a['level'], $a['name']] <=> [mb_strtolower($b['name']) !== $lower, -$b['level'], $b['name']]); return array_values(array_filter($results, static fn (array $r): bool => $r['id'] !== '' && $r['name'] !== '')); } /** Gueltige Charakter-ID von NCSoft (Base64-URL mit "="). */ function armory_valid_char_id(string $charId): bool { return (bool) preg_match('/^[A-Za-z0-9_\-]{20,120}={0,2}$/', $charId); } /** * Holt Charakterinfo und Ausruestung und bereitet sie fuer die Anzeige auf (nur was wir zeigen). * * @return array */ function armory_fetch(string $charId, int $serverId): array { $info = armory_request('https://' . ARMORY_API_HOST . '/api/character/info?' . armory_query($charId, $serverId)); $equip = armory_request('https://' . ARMORY_API_HOST . '/api/character/equipment?' . armory_query($charId, $serverId)); $profile = (array) ($info['profile'] ?? []); if (empty($profile['characterName'])) { throw new RuntimeException('Diesen Charakter gibt es im Spiel nicht (mehr).', 404); } $stats = []; $itemLevel = null; foreach ((array) ($info['stat']['statList'] ?? []) as $stat) { $type = (string) ($stat['type'] ?? ''); if ($type === 'ItemLevel') { $itemLevel = (int) ($stat['value'] ?? 0); } elseif (in_array($type, ARMORY_BASE_STATS, true) || in_array($type, ARMORY_GOD_STATS, true)) { $stats[$type] = [ 'name' => (string) ($stat['name'] ?? $type), 'value' => (int) ($stat['value'] ?? 0), 'effects' => array_values(array_map('strval', (array) ($stat['statSecondList'] ?? []))), ]; } } $boards = []; foreach ((array) ($info['daevanion']['boardList'] ?? []) as $board) { $boards[] = [ 'name' => (string) ($board['name'] ?? ''), 'icon' => (string) ($board['icon'] ?? ''), 'open' => (int) ($board['openNodeCount'] ?? 0), 'total' => (int) ($board['totalNodeCount'] ?? 0), ]; } $equipment = []; $extra = []; foreach ((array) ($equip['equipment']['equipmentList'] ?? []) as $item) { $slotName = (string) ($item['slotPosName'] ?? ''); $entry = [ 'id' => (int) ($item['id'] ?? 0), 'name' => (string) ($item['name'] ?? ''), 'grade' => (string) ($item['grade'] ?? ''), 'icon' => (string) ($item['icon'] ?? ''), 'enchant' => (int) ($item['enchantLevel'] ?? 0), 'exceed' => (int) ($item['exceedLevel'] ?? 0), 'slot_pos' => (int) ($item['slotPos'] ?? 0), ]; if (isset(ARMORY_SLOTS[$slotName])) { $equipment[ARMORY_SLOTS[$slotName]] = $entry; } elseif (isset(ARMORY_EXTRA_SLOTS[$slotName])) { $extra[$slotName] = $entry + ['label' => ARMORY_EXTRA_SLOTS[$slotName]]; } } $pet = (array) ($equip['petwing']['pet'] ?? []); $wing = (array) ($equip['petwing']['wing'] ?? []); return [ 'name' => (string) $profile['characterName'], 'level' => (int) ($profile['characterLevel'] ?? 0), 'class' => armory_class_name((string) ($profile['className'] ?? '')), 'class_label' => (string) ($profile['className'] ?? ''), 'combat_power' => (int) ($profile['combatPower'] ?? 0), 'item_level' => $itemLevel, 'title' => !empty($profile['titleName']) ? ['name' => (string) $profile['titleName'], 'grade' => (string) ($profile['titleGrade'] ?? '')] : null, 'portrait' => (string) ($profile['profileImage'] ?? ''), 'server_id' => $serverId, 'stats' => $stats, 'boards' => $boards, 'equipment' => $equipment, 'extra' => $extra, 'pet' => !empty($pet['name']) ? ['name' => (string) $pet['name'], 'icon' => (string) ($pet['icon'] ?? ''), 'level' => (int) ($pet['level'] ?? 0)] : null, 'wing' => !empty($wing['name']) ? ['name' => (string) $wing['name'], 'icon' => (string) ($wing['icon'] ?? ''), 'grade' => (string) ($wing['grade'] ?? ''), 'enchant' => (int) ($wing['enchantLevel'] ?? 0)] : null, ]; } /** * Erneuert die Live-Daten eines verknuepften Charakters: speichert sie, holt das Portrait und * gleicht Name, Klasse und Stufe des Profil-Charakters an. Gibt es den Charakter nicht mehr, bleibt * die Verknuepfung bestehen, nur mit Fehlermeldung (aion_error). * * @param array $character Zeile aus member_characters * @return array die aktualisierte Zeile * @throws RuntimeException wenn NCSoft nicht erreichbar ist (die alten Daten bleiben dann stehen) */ function armory_refresh(array $character): array { $charId = (string) $character['aion_char_id']; $serverId = (int) $character['aion_server_id']; $pdo = db(); try { $data = armory_fetch($charId, $serverId); } catch (RuntimeException $e) { if ($e->getCode() === 404) { $pdo->prepare('UPDATE member_characters SET aion_fetched_at = ?, aion_error = ? WHERE id = ?') ->execute([date('Y-m-d H:i:s'), mb_substr($e->getMessage(), 0, 255), (int) $character['id']]); $character['aion_error'] = $e->getMessage(); $character['aion_fetched_at'] = date('Y-m-d H:i:s'); return $character; } throw $e; } $portrait = armory_store_portrait((int) $character['id'], $data['portrait']); $data['portrait'] = $portrait; $json = json_encode($data, JSON_UNESCAPED_UNICODE); $level = $data['level'] >= 1 && $data['level'] <= PROFILE_MAX_LEVEL ? $data['level'] : $character['level']; $class = $data['class'] ?? $character['class_name']; $pdo->prepare( 'UPDATE member_characters SET name = ?, class_name = ?, level = ?, aion_data = ?, aion_fetched_at = ?, aion_error = NULL WHERE id = ?' )->execute([mb_substr($data['name'], 0, 60), $class, $level, $json, date('Y-m-d H:i:s'), (int) $character['id']]); return array_merge($character, [ 'name' => mb_substr($data['name'], 0, 60), 'class_name' => $class, 'level' => $level, 'aion_data' => $json, 'aion_fetched_at' => date('Y-m-d H:i:s'), 'aion_error' => null, ]); } /** Gespeicherte Live-Daten eines Charakters (null = nicht verknuepft oder noch nie abgerufen). */ function armory_data(array $character): ?array { if (empty($character['aion_char_id']) || empty($character['aion_data'])) { return null; } $data = json_decode((string) $character['aion_data'], true); return is_array($data) ? $data : null; } /** Sind die Live-Daten alt genug, um sie zu erneuern? */ function armory_is_stale(array $character, int $age = ARMORY_TTL): bool { return !empty($character['aion_char_id']) && (empty($character['aion_fetched_at']) || strtotime((string) $character['aion_fetched_at']) < time() - $age); } /** * Laedt eine Datei von NCSoft (Icons, Portraits). Weiterleitungen nur zu Servern von NCSoft * (plaync.com, playnccdn.com), hoechstens zwei. */ function armory_download(string $url, int $maxBytes = 2 * 1024 * 1024): string { for ($hop = 0; $hop < 3; $hop++) { $host = strtolower((string) parse_url($url, PHP_URL_HOST)); if (parse_url($url, PHP_URL_SCHEME) !== 'https' || !preg_match('/(^|\.)(plaync\.com|playnccdn\.com)$/', $host)) { throw new RuntimeException('Unerlaubte Adresse.'); } $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => false, CURLOPT_TIMEOUT => 10, CURLOPT_CONNECTTIMEOUT => 4, CURLOPT_USERAGENT => ARMORY_AGENT, CURLOPT_HTTPHEADER => ['Accept: image/*'], ]); $body = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $location = (string) curl_getinfo($ch, CURLINFO_REDIRECT_URL); if ($body === false) { throw new RuntimeException('Bild nicht erreichbar.'); } if (in_array($status, [301, 302, 303, 307, 308], true) && $location !== '') { $url = $location; continue; } if ($status !== 200 || strlen((string) $body) > $maxBytes) { throw new RuntimeException('Bild nicht verfuegbar (Status ' . $status . ').'); } return (string) $body; } throw new RuntimeException('Zu viele Weiterleitungen.'); } /** Prueft heruntergeladene Bilddaten und liefert die Endung (png, jpg, webp, gif) oder null. */ function armory_image_ext(string $bytes): ?string { $info = @getimagesizefromstring($bytes); return $info ? ([IMAGETYPE_PNG => 'png', IMAGETYPE_JPEG => 'jpg', IMAGETYPE_WEBP => 'webp', IMAGETYPE_GIF => 'gif'][$info[2]] ?? null) : null; } /** * Speichert das Portrait aus dem Spiel als assets/uploads/armory/char. (ersetzt das alte). * * @return string Dateiname oder '' (kein Portrait) */ function armory_store_portrait(int $characterId, string $url): string { if ($url === '') { return ''; } try { $bytes = armory_download($url); $ext = armory_image_ext($bytes); if ($ext === null) { return ''; } $name = 'char' . $characterId . '.' . $ext; foreach (glob(ARMORY_ICON_DIR . 'char' . $characterId . '.*') ?: [] as $old) { if (basename($old) !== $name) { @unlink($old); } } if (@file_put_contents(ARMORY_ICON_DIR . $name, $bytes) === false) { return ''; } return $name; } catch (RuntimeException $e) { return ''; } } /** * Portrait-Dateien aus dem Spiel zu Profil-Charakteren - beim Loeschen von Charakteren bzw. Konten * mit wegraeumen (die Datenbankzeilen fallen weg, die Dateien nicht). * * @param array $characterIds * @return array Pfade */ function armory_portrait_files(array $characterIds): array { $files = []; foreach ($characterIds as $id) { foreach (glob(ARMORY_ICON_DIR . 'char' . (int) $id . '.*') ?: [] as $file) { $files[] = $file; } } return $files; } function armory_portrait_url(array $data): ?string { $name = (string) ($data['portrait'] ?? ''); return preg_match('/^char\d+\.(png|jpg|webp|gif)$/', $name) && is_file(ARMORY_ICON_DIR . $name) ? ARMORY_ICON_URL . $name . '?v=' . filemtime(ARMORY_ICON_DIR . $name) : null; } /** Dateiname eines Icons von NCSoft (nur aus ARMORY_ICON_BASE) oder null. */ function armory_icon_file(string $url): ?string { if (!str_starts_with($url, ARMORY_ICON_BASE)) { return null; } $file = substr($url, strlen(ARMORY_ICON_BASE)); return preg_match('/^[A-Za-z0-9_\-]{1,100}\.png$/', $file) ? $file : null; } /** Adresse eines Icons bei uns: schon geladen direkt, sonst ueber armory_icon.php (laedt es einmalig). */ function armory_icon_url(string $url): ?string { $file = armory_icon_file($url); if ($file === null) { return null; } return is_file(ARMORY_ICON_DIR . $file) ? ARMORY_ICON_URL . $file : '/armory_icon.php?f=' . rawurlencode($file); } // ---- Infos zu einzelnen Gegenstaenden (Info-Blase) ---- /** * Werte eines angelegten Gegenstands (mit Manasteinen des Charakters), zwischengespeichert in armory_cache. * * @return array */ function armory_item(string $charId, int $serverId, int $itemId, int $enchant, int $slotPos): array { $key = 'item:' . sha1($charId . '|' . $serverId . '|' . $itemId . '|' . $enchant . '|' . $slotPos); $stmt = db()->prepare('SELECT data FROM armory_cache WHERE cache_key = ? AND fetched_at > ?'); $stmt->execute([$key, date('Y-m-d H:i:s', time() - ARMORY_ITEM_TTL)]); $cached = $stmt->fetchColumn(); if ($cached !== false && is_array($item = json_decode((string) $cached, true))) { return $item; } $item = armory_request('https://' . ARMORY_API_HOST . '/api/character/equipment/item?' . http_build_query([ 'id' => $itemId, 'enchantLevel' => $enchant, 'characterId' => $charId, 'serverId' => $serverId, 'slotPos' => $slotPos, 'lang' => ARMORY_LANG, 'region' => ARMORY_REGION, ])); db()->prepare('INSERT INTO armory_cache (cache_key, data, fetched_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data), fetched_at = VALUES(fetched_at)') ->execute([$key, json_encode($item, JSON_UNESCAPED_UNICODE), date('Y-m-d H:i:s')]); // Alte Eintraege gelegentlich wegraeumen if (random_int(1, 50) === 1) { db()->prepare('DELETE FROM armory_cache WHERE fetched_at < ?')->execute([date('Y-m-d H:i:s', time() - 7 * 86400)]); } return $item; } /** Inhalt der Info-Blase zu einem Gegenstand (gleiche Klassen wie die Lagerhaus-Blase, assets/js/item-tooltip.js). */ function armory_item_tip_html(array $item): string { $iconUrl = armory_icon_url((string) ($item['icon'] ?? '')); $grade = armory_grade_class((string) ($item['grade'] ?? '')); $enchant = (int) ($item['enchantLevel'] ?? 0); $meta = array_filter([(string) ($item['gradeName'] ?? ''), (string) ($item['categoryName'] ?? '')]); $levels = array_filter([ !empty($item['level']) ? 'Gegenstandsstufe ' . (int) $item['level'] : '', !empty($item['equipLevel']) ? 'ab Stufe ' . (int) $item['equipLevel'] : '', ]); $html = '
' . ($iconUrl ? '' : '') . '
' . e((string) ($item['name'] ?? '')) . ($enchant > 0 ? ' +' . $enchant : '') . '' . ($meta ? '' . e(implode(' · ', $meta)) . '' : '') . ($levels ? '' . e(implode(' · ', $levels)) . '' : '') . '
'; $list = static function (string $title, array $rows): string { if (!$rows) { return ''; } $out = '
' . e($title) . '
    '; foreach ($rows as [$label, $value]) { $out .= '
  • ' . e($label) . '' . e($value) . '
  • '; } return $out . '
'; }; $main = []; foreach ((array) ($item['mainStats'] ?? []) as $stat) { $extra = (string) ($stat['extra'] ?? '0'); $main[] = [(string) ($stat['name'] ?? ''), (string) ($stat['value'] ?? '') . ($extra !== '' && $extra !== '0' ? ' (+' . $extra . ')' : '')]; } $sub = []; foreach ((array) ($item['subStats'] ?? []) as $stat) { $sub[] = [(string) ($stat['name'] ?? ''), (string) ($stat['value'] ?? '')]; } $stones = []; foreach ((array) ($item['magicStoneStat'] ?? []) as $stat) { $stones[] = [(string) ($stat['name'] ?? ''), (string) ($stat['value'] ?? '')]; } $html .= $list('Grundwerte', $main) . $list('Zusatzwerte', $sub) . $list('Manasteine', $stones); // Goetterstein: Name und Effekt als Text (zu lang fuer die Werte-Spalte) foreach ((array) ($item['godStoneStat'] ?? []) as $stat) { if (is_array($stat) && !empty($stat['name'])) { $html .= '
Götterstein

' . e(preg_replace('/^Götterstein:\s*/u', '', (string) $stat['name'])) . '
' . e((string) ($stat['desc'] ?? $stat['value'] ?? '')) . '

'; } } $info = []; if (!empty($item['maxEnchantLevel'])) { $info[] = ['Aufwertung', $enchant . ' / ' . (int) $item['maxEnchantLevel']]; } if (!empty($item['sources'])) { $info[] = ['Herkunft', implode(', ', array_map('strval', (array) $item['sources']))]; } if ($info) { $html .= '
'; foreach ($info as [$label, $value]) { $html .= '
' . e($label) . '
' . e($value) . '
'; } $html .= '
'; } return $html . '
Daten: aion2.plaync.com
'; } // ---- Anzeige auf der Profilseite ---- /** Ein Slot im Ausruestungsraster (Icon, Seltenheit, Aufwertung, Info-Blase). */ function armory_slot_html(?array $item, string $label, string $silhouetteKey, int $characterId): string { if (!$item) { return '' . gear_slot_silhouette($silhouetteKey) . ''; } $iconUrl = armory_icon_url($item['icon']); $tipUrl = '/armory_api.php?' . http_build_query(['action' => 'item', 'character' => $characterId, 'slot' => $item['slot_pos']]); $html = ''; $html .= $iconUrl ? '' : '' . e(mb_substr($item['name'], 0, 1)) . ''; if ($item['exceed'] > 0) { $html .= '★' . (int) $item['exceed'] . ''; } if ($item['enchant'] > 0) { $html .= '+' . (int) $item['enchant'] . ''; } return $html . ''; } /** Kurzangabe "vor 12 Minuten" fuer den Stand der Daten. */ function armory_age_label(?string $fetchedAt): string { if (!$fetchedAt) { return 'noch nie'; } $minutes = max(0, intdiv(time() - (int) strtotime($fetchedAt), 60)); return match (true) { $minutes < 1 => 'gerade eben', $minutes < 60 => 'vor ' . $minutes . ' Min.', $minutes < 1440 => 'vor ' . intdiv($minutes, 60) . ' Std.', default => 'am ' . date('d.m.Y', (int) strtotime($fetchedAt)), }; } /** Kampfkraft in Tausend mit einer Nachkommastelle (98986 -> "98,9k"), darunter ganz. */ function armory_power_label(int $power): string { return $power < 1000 ? (string) $power : number_format(floor($power / 100) / 10, 1, ',', '.') . 'k'; } /** * Kurzinfo an der Charakterkarte (Stufe, Gearscore, Kampfkraft) - oeffnet das Popup mit allen * Live-Daten (armory_modal_html). Leer, wenn der Charakter nicht verknuepft ist. */ function armory_summary_html(array $character): string { if (empty($character['aion_char_id'])) { return ''; } $id = (int) $character['id']; $data = armory_data($character); $html = ''; } $stats = [['Stufe', (string) (int) $data['level'], '']]; if ($data['item_level'] !== null) { $stats[] = ['Gearscore', number_format((int) $data['item_level'], 0, ',', '.'), '']; } $stats[] = ['Kampfkraft', armory_power_label((int) $data['combat_power']), number_format((int) $data['combat_power'], 0, ',', '.')]; foreach ($stats as [$label, $value, $exact]) { $html .= '' . e($label) . '' . e($value) . '
'; } return $html . 'Details ›'; } /** Popup mit den Live-Daten eines Charakters (geoeffnet ueber die Kurzinfo, assets/js/armory.js). */ function armory_modal_html(array $character, bool $canRefresh): string { $id = (int) $character['id']; return ''; } /** * Live-Bereich eines verknuepften Charakters: Kopf mit Kampfkraft, Ausruestung, Werte, Daevanion. * Wird auf member.php ausgegeben und nach einem Abgleich von armory_api.php ersetzt. * * @param array $character Zeile aus member_characters */ function armory_panel_html(array $character, bool $canRefresh): string { $id = (int) $character['id']; $data = armory_data($character); $stale = armory_is_stale($character); $html = '
'; $head = '
Live aus dem Spiel · Stand ' . e(armory_age_label($character['aion_fetched_at'] ?? null)) . ''; if ($canRefresh) { $head .= ' '; } $head .= '
'; if ($data === null) { $html .= $head . '

' . (!empty($character['aion_error']) ? e((string) $character['aion_error']) : 'Die Daten aus dem Spiel werden gerade geladen …') . '

'; return $html . '
'; } $portrait = armory_portrait_url($data); $html .= '
'; if ($portrait) { $html .= ''; } $html .= '

' . e($data['name']) . ' ' . class_badge_html($data['class'], 22) . '

' . '
' . e(trim(($data['class'] ?? $data['class_label']) . ' · Stufe ' . (int) $data['level'] . ' · ' . armory_server_name((int) $data['server_id']))) . '
'; if (!empty($data['title'])) { $html .= '
„' . e($data['title']['name']) . '“
'; } $html .= '
' . '
Kampfkraft' . e(armory_power_label((int) $data['combat_power'])) . '
' . ($data['item_level'] !== null ? '
Gearscore' . e(number_format((int) $data['item_level'], 0, ',', '.')) . '
' : '') . '
'; $html .= $head; if (!empty($character['aion_error'])) { $html .= '

' . e((string) $character['aion_error']) . ' Angezeigt wird der letzte Stand.

'; } // Ausruestung wie im Gear-Planer (zwei pro Reihe), daneben Runen, Flügel und Begleiter $html .= '
'; foreach (GEAR_DOLL_ORDER as $slotKey) { $html .= armory_slot_html($data['equipment'][$slotKey] ?? null, GEAR_SLOTS[$slotKey][0], $slotKey, $id); } $html .= '
'; $extras = []; foreach (ARMORY_EXTRA_SLOTS as $slotName => $label) { if (!empty($data['extra'][$slotName])) { $extras[] = [$label, $data['extra'][$slotName]]; } } if ($extras || $data['wing'] || $data['pet']) { $html .= '
    '; foreach ($extras as [$label, $item]) { $html .= '
  • ' . armory_slot_html($item, $label, 'amulet', $id) . '' . e($label) . '' . e($item['name']) . ($item['enchant'] > 0 ? ' +' . (int) $item['enchant'] : '') . '
  • '; } foreach (['wing' => 'Flügel', 'pet' => 'Begleiter'] as $key => $label) { $entry = $data[$key]; if (!$entry) { continue; } $iconUrl = armory_icon_url($entry['icon']); $grade = armory_grade_class($entry['grade'] ?? null); $html .= '
  • ' . ($iconUrl ? '' : '') . '' . '' . e($label) . '' . e($entry['name']) . (!empty($entry['enchant']) ? ' +' . (int) $entry['enchant'] : '') . (!empty($entry['level']) ? ' · Stufe ' . (int) $entry['level'] : '') . '
  • '; } $html .= '
'; } $html .= '
'; // Werte: Grundwerte und Gottheiten, Effekte im Tooltip $html .= '
'; foreach (['Grundwerte' => ARMORY_BASE_STATS, 'Gottheiten' => ARMORY_GOD_STATS] as $title => $types) { $rows = array_filter(array_map(static fn (string $type): ?array => $data['stats'][$type] ?? null, $types)); if (!$rows) { continue; } $html .= '

' . e($title) . '

    '; foreach ($rows as $stat) { $html .= '' . '' . e($stat['name']) . '' . (int) $stat['value'] . ''; } $html .= '
'; } if ($data['boards']) { $html .= '

Daevanion

    '; foreach ($data['boards'] as $board) { $percent = $board['total'] > 0 ? (int) round($board['open'] * 100 / $board['total']) : 0; $iconUrl = armory_icon_url($board['icon']); $html .= '
  • ' . ($iconUrl ? '' : '') . '' . e($board['name']) . '' . '' . '' . $percent . ' %
  • '; } $html .= '
'; } $html .= '
'; return $html . ''; }