diff --git a/api/debug-events.php b/api/debug-events.php index dc3554b..98eb3da 100644 --- a/api/debug-events.php +++ b/api/debug-events.php @@ -87,13 +87,20 @@ if ($playerName !== '') { } } -// Fetch events +// Fetch events + masterData abilities (incl. type) $includeResources = in_array($dataType, ['DamageTaken', 'DamageDone']) ? 'includeResources: true,' : ''; $result = dbg_gql(<< $ab['name'], 'type' => $ab['type'] ?? null]; +} + // Filter by raw event type, player (source OR target), then apply limit +// Enrich each event with ability meta (name + type) from masterData $filtered = []; foreach ($events as $ev) { if ($eventType !== '' && ($ev['type'] ?? '') !== $eventType) continue; @@ -121,21 +135,24 @@ foreach ($events as $ev) { $tgtId = (int)($ev['targetID'] ?? -1); if (!in_array($srcId, $playerIds) && !in_array($tgtId, $playerIds)) continue; } + // Inject ability meta so ability.type is visible directly on the event + $gid = (int)($ev['abilityGameID'] ?? 0); + if ($gid && isset($abilityMeta[$gid])) { + $ev['_ability'] = $abilityMeta[$gid]; + } $filtered[] = $ev; if (count($filtered) >= $limit) break; } echo json_encode([ - 'data_type' => $dataType, - 'event_type' => $eventType ?: null, - 'ability_id' => $abilityId ?: null, - 'player_name' => $playerName ?: null, - 'player_ids' => $playerIds ?: null, - 'time_range' => [ - 'from_ms' => (int)$queryStart, - 'to_ms' => (int)$queryEnd, - ], + 'data_type' => $dataType, + 'event_type' => $eventType ?: null, + 'ability_id' => $abilityId ?: null, + 'player_name' => $playerName ?: null, + 'player_ids' => $playerIds ?: null, + 'time_range' => ['from_ms' => (int)$queryStart, 'to_ms' => (int)$queryEnd], 'total_before_limit' => count($events), - 'count' => count($filtered), - 'events' => $filtered, + 'count' => count($filtered), + 'ability_meta' => $abilityMeta, // vollständige Lookup-Tabelle: gameID → {name, type} + 'events' => $filtered, ], JSON_PRETTY_PRINT); diff --git a/js/ffxiv-data.js b/js/ffxiv-data.js index a3e600f..3f43a77 100644 --- a/js/ffxiv-data.js +++ b/js/ffxiv-data.js @@ -1,4 +1,15 @@ (function () { + // FFLogs ability type bitmask values for FFXIV + // Verified via XIVAPI AttackType cross-reference: + // 128 = Physical (all subtypes: Slashing/Piercing/Blunt/Shot) + // 1024 = Magical + // Used for Feint/Addle DR calculation (Feint: 10% phys / 5% mag, Addle: 10% mag / 5% phys) + const ABILITY_TYPE_PHYSICAL = 128; + const ABILITY_TYPE_MAGICAL = 1024; + + function abilityTypeIsPhysical(type) { return (parseInt(type) & ABILITY_TYPE_PHYSICAL) !== 0; } + function abilityTypeIsMagical(type) { return (parseInt(type) & ABILITY_TYPE_MAGICAL) !== 0; } + const JOB_FROM_TYPE = { 'Paladin': 'PLD', 'Warrior': 'WAR', 'DarkKnight': 'DRK', 'Gunbreaker': 'GNB', 'WhiteMage': 'WHM', 'Scholar': 'SCH', 'Astrologian': 'AST', 'Sage': 'SGE', @@ -308,5 +319,9 @@ TANK_JOBS: new Set(['PLD', 'WAR', 'DRK', 'GNB']), MELEE_JOBS: new Set(['MNK', 'DRG', 'NIN', 'SAM', 'RPR', 'VPR']), CASTER_JOBS: new Set(['BLM', 'SMN', 'RDM', 'PCT']), + ABILITY_TYPE_PHYSICAL, + ABILITY_TYPE_MAGICAL, + abilityTypeIsPhysical, + abilityTypeIsMagical, }; })();