diff --git a/crates/openlogs-analysis/src/actors.rs b/crates/openlogs-analysis/src/actors.rs index c8bf7fa..e3287a9 100644 --- a/crates/openlogs-analysis/src/actors.rs +++ b/crates/openlogs-analysis/src/actors.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use openlogs_gamedata::Role; use openlogs_parser::unit_flags::{ AFFILIATION_GROUP, CONTROL_NPC, REACTION_FRIENDLY, REACTION_HOSTILE, TYPE_GUARDIAN, TYPE_PET, }; @@ -45,6 +46,26 @@ pub struct Actor { pub item_level: Option, /// Largest max HP the advanced block reported; players only. pub max_hp: Option, + /// The talent tree a player of a game without specs put most points into; see + /// [`crate::assign_talent_specs`]. + pub talent_spec: Option, +} + +/// A talent tree as a player's spec, with their role in this pull. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct TalentSpec { + pub tree_id: u32, + pub name: String, + pub icon: String, + pub role: Role, +} + +/// The spec a player is shown with: their spec, else their talent spec. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ShownSpec<'a> { + pub name: &'a str, + pub icon: &'a str, + pub role: Role, } impl Actor { @@ -67,6 +88,21 @@ impl Actor { spec_class(self.spec_id) } + pub fn shown_spec(&self) -> Option> { + match self.spec_id.and_then(openlogs_gamedata::spec) { + Some(spec) => Some(ShownSpec { + name: &spec.name, + icon: &spec.icon, + role: spec.role, + }), + None => self.talent_spec.as_ref().map(|spec| ShownSpec { + name: &spec.name, + icon: &spec.icon, + role: spec.role, + }), + } + } + /// Belongs to the logging player's group (mine, party or raid) and is not hostile. pub fn is_friendly(&self) -> bool { self.flags & AFFILIATION_GROUP != 0 && !self.is_hostile() @@ -118,6 +154,7 @@ impl Actors { class_id: None, item_level: None, max_hp: None, + talent_spec: None, }], by_guid: HashMap::new(), } @@ -137,6 +174,7 @@ impl Actors { actor.class_id = None; actor.item_level = None; actor.max_hp = None; + actor.talent_spec = None; } carried } @@ -188,6 +226,7 @@ impl Actors { class_id: None, item_level: None, max_hp: None, + talent_spec: None, }); self.by_guid.insert(guid.to_string(), id); id @@ -244,6 +283,10 @@ impl Actors { self.list[unit as usize].class_id = class_id; } + pub(crate) fn set_talent_spec(&mut self, unit: ActorId, spec: Option) { + self.list[unit as usize].talent_spec = spec; + } + /// Records a player's item level and max HP from an advanced block, keeping the largest. pub fn note_advanced(&mut self, unit: ActorId, level: u32, max_hp: u64) { let actor = &mut self.list[unit as usize]; diff --git a/crates/openlogs-analysis/src/classes.rs b/crates/openlogs-analysis/src/classes.rs index 8840789..1c02d2e 100644 --- a/crates/openlogs-analysis/src/classes.rs +++ b/crates/openlogs-analysis/src/classes.rs @@ -11,7 +11,7 @@ pub fn infer_classes(fight: &mut Fight, spell_classes: &SpellClasses) { let mut casts: HashMap> = fight .actors .players() - .filter(|player| player.spec_class().is_none()) + .filter(|player| player.class().is_none()) .map(|player| (player.id, HashMap::new())) .collect(); for event in &fight.events { diff --git a/crates/openlogs-analysis/src/fight.rs b/crates/openlogs-analysis/src/fight.rs index d408e95..2b4243d 100644 --- a/crates/openlogs-analysis/src/fight.rs +++ b/crates/openlogs-analysis/src/fight.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use openlogs_index::{GameFlavor, MapBounds, Outcome}; pub use openlogs_parser::{AuraAction, AuraType, DamageVia}; @@ -56,6 +56,8 @@ pub struct Fight { /// The index's roster: players with `COMBATANT_INFO` in a boss pull or run, the players /// who fought in a combat pull. pub roster: BTreeSet, + /// `(node, rank)` of each player's talents, from `COMBATANT_INFO` in the pull or the index. + pub talents: HashMap>, /// The log's game, which decides how player names are shown; `None` until the caller /// that knows the log sets it. pub flavor: Option, diff --git a/crates/openlogs-analysis/src/lib.rs b/crates/openlogs-analysis/src/lib.rs index 5a088ef..9f7c0cd 100644 --- a/crates/openlogs-analysis/src/lib.rs +++ b/crates/openlogs-analysis/src/lib.rs @@ -29,6 +29,7 @@ mod reports; mod resources; mod run_result; mod scope; +mod talent_specs; mod targets; mod timeline; mod turned; @@ -36,7 +37,7 @@ mod usage; mod views; pub use ability::{AbilityDetail, AbilityHit, TargetHits, ability_detail}; -pub use actors::{Actor, ActorId, ActorKind, Actors, NOBODY, spec_class}; +pub use actors::{Actor, ActorId, ActorKind, Actors, NOBODY, ShownSpec, TalentSpec, spec_class}; pub use aura_report::{AuraHolder, AuraLane, AuraRow, AurasReport, SourceSpec, auras_report}; pub use auras::{AuraInterval, aura_intervals, coverage, union_ms}; pub use breakdown::{ @@ -98,6 +99,7 @@ pub use resources::{ }; pub use run_result::{BossProgress, RunResult, run_result}; pub use scope::{AbilityRef, Scope, Side, UnitRef, side_of, unit_of}; +pub use talent_specs::assign_talent_specs; pub use targets::{ EnemyGroup, TargetDetail, UnitLife, WAVE_GAP_MS, Wave, enemy_groups, target_detail, }; diff --git a/crates/openlogs-analysis/src/load.rs b/crates/openlogs-analysis/src/load.rs index e920a2e..6b79920 100644 --- a/crates/openlogs-analysis/src/load.rs +++ b/crates/openlogs-analysis/src/load.rs @@ -83,6 +83,12 @@ fn apply_roster(fight: &mut Fight, roster: &[RosterEntry]) { if entry.spec_id != 0 && fight.actors.get(id).spec_id.is_none() { fight.actors.set_spec(id, entry.spec_id); } + if !entry.talents.is_empty() { + fight + .talents + .entry(id) + .or_insert_with(|| entry.talents.clone()); + } } } @@ -259,6 +265,7 @@ impl FightBuilder { logger_turned: Vec::new(), heal_grants: Vec::new(), delayed_hits: Vec::new(), + talents: HashMap::new(), roster: BTreeSet::new(), flavor: None, }, @@ -288,6 +295,7 @@ impl FightBuilder { LogEvent::CombatantInfo(info) => { let id = self.fight.actors.intern_guid(info.guid); self.fight.actors.set_spec(id, info.spec_id); + self.fight.talents.insert(id, info.talents().collect()); } LogEvent::Combat(event) => { let converted = self.convert(t, event); diff --git a/crates/openlogs-analysis/src/replay/units.rs b/crates/openlogs-analysis/src/replay/units.rs index 64eae23..8124d8f 100644 --- a/crates/openlogs-analysis/src/replay/units.rs +++ b/crates/openlogs-analysis/src/replay/units.rs @@ -19,6 +19,7 @@ pub struct ReplayUnit { pub name: String, pub kind: UnitKind, pub spec_id: Option, + pub spec_icon: Option, pub class_id: Option, pub owner: Option, /// Adds of one name are numbered from 1 in the order they were first positioned. @@ -61,6 +62,7 @@ impl Roster { name: actor.name.clone().unwrap_or_default(), kind, spec_id: actor.spec_id, + spec_icon: actor.shown_spec().map(|spec| spec.icon.to_string()), class_id: actor.class(), owner: actor.owner, add_number: None, diff --git a/crates/openlogs-analysis/src/talent_specs.rs b/crates/openlogs-analysis/src/talent_specs.rs new file mode 100644 index 0000000..29dfcad --- /dev/null +++ b/crates/openlogs-analysis/src/talent_specs.rs @@ -0,0 +1,68 @@ +use openlogs_gamedata::{BEAR_FORMS, Role, TalentTrees, TreeRole, tree_role}; + +use crate::actors::{ActorId, TalentSpec}; +use crate::auras::{AuraInterval, aura_intervals, union_ms}; +use crate::fight::Fight; + +/// A Feral Combat druid tanks a pull they spent at least this share of in Bear Form. +const BEAR_FORM_TANK_SHARE: f64 = 0.2; + +/// Gives each player with talents the tree they put most points into, with their role in this +/// pull, and each player whose spec ID is one of the game's class specs that class. +pub fn assign_talent_specs(fight: &mut Fight, trees: &TalentTrees) { + let players: Vec<(ActorId, Option)> = fight + .actors + .players() + .map(|player| (player.id, player.spec_id)) + .collect(); + let mut bear_forms: Option> = None; + for (player, spec_id) in players { + let tree = fight + .talents + .get(&player) + .and_then(|talents| trees.spec_of(talents.iter().copied())); + let class = spec_id + .and_then(|spec_id| trees.class_of_spec(spec_id)) + .or(tree.map(|tree| tree.class_id)); + if class.is_some() { + fight.actors.set_class(player, class); + } + let spec = tree.map(|tree| TalentSpec { + tree_id: tree.id, + name: tree.name.clone(), + icon: tree.icon.clone(), + role: match tree_role(tree.id) { + TreeRole::Fixed(role) => role, + TreeRole::BearForm => { + let intervals = bear_forms.get_or_insert_with(|| bear_form_intervals(fight)); + if bear_form_share(fight, intervals, player) >= BEAR_FORM_TANK_SHARE { + Role::Tank + } else { + Role::Damage + } + } + }, + }); + fight.actors.set_talent_spec(player, spec); + } +} + +fn bear_form_intervals(fight: &Fight) -> Vec { + aura_intervals(fight) + .into_iter() + .filter(|interval| BEAR_FORMS.contains(&interval.spell)) + .collect() +} + +fn bear_form_share(fight: &Fight, bear_forms: &[AuraInterval], player: ActorId) -> f64 { + let duration = i32::try_from(fight.duration_ms).unwrap_or(i32::MAX); + if duration <= 0 { + return 0.0; + } + let spans: Vec<(i32, i32)> = bear_forms + .iter() + .filter(|interval| interval.target == player) + .map(|interval| (interval.start_ms, interval.end_ms)) + .collect(); + union_ms(&spans, 0, duration) as f64 / f64::from(duration) +} diff --git a/crates/openlogs-analysis/tests/replay.rs b/crates/openlogs-analysis/tests/replay.rs index bf22c82..abaed57 100644 --- a/crates/openlogs-analysis/tests/replay.rs +++ b/crates/openlogs-analysis/tests/replay.rs @@ -115,6 +115,7 @@ fn units_are_classified_and_adds_numbered_per_name() { name: name.into(), kind, spec_id: None, + spec_icon: None, class_id: None, owner: None, add_number: None, @@ -124,6 +125,7 @@ fn units_are_classified_and_adds_numbered_per_name() { vec![ ReplayUnit { spec_id: Some(62), + spec_icon: Some(openlogs_gamedata::spec(62).unwrap().icon.clone()), class_id: Some(8), ..unit(mage, "Ilvaren", UnitKind::Player) }, diff --git a/crates/openlogs-analysis/tests/support/mod.rs b/crates/openlogs-analysis/tests/support/mod.rs index d283071..e36ddee 100644 --- a/crates/openlogs-analysis/tests/support/mod.rs +++ b/crates/openlogs-analysis/tests/support/mod.rs @@ -1,7 +1,7 @@ // Each test binary uses a different subset of these helpers. #![allow(dead_code)] -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use openlogs_analysis::{ ActorId, Actors, Damage, DamageVia, Event, EventKind, Fight, FightKind, Heal, NO_SPELL, NOBODY, @@ -47,6 +47,7 @@ impl FightBuilder { logger_turned: Vec::new(), heal_grants: Vec::new(), delayed_hits: Vec::new(), + talents: HashMap::new(), roster: BTreeSet::new(), flavor: None, }, diff --git a/crates/openlogs-analysis/tests/talent_specs.rs b/crates/openlogs-analysis/tests/talent_specs.rs new file mode 100644 index 0000000..528fa86 --- /dev/null +++ b/crates/openlogs-analysis/tests/talent_specs.rs @@ -0,0 +1,119 @@ +mod support; + +use openlogs_analysis::{ + AuraAction, AuraType, EventKind, Fight, NO_SPELL, ShownSpec, assign_talent_specs, +}; +use openlogs_gamedata::{Role, TalentTrees}; +use support::FightBuilder; + +const COMBAT_NODE: u32 = 1; +const ASSASSINATION_NODE: u32 = 2; +const FERAL_NODE: u32 = 3; +const BEAR_FORM: u32 = 5487; +const DIRE_BEAR_FORM: u32 = 9634; + +fn trees() -> TalentTrees { + TalentTrees::from_json( + r#"{"trees":[ + {"id":181,"classId":4,"name":"Combat","icon":"ability_backstab"}, + {"id":182,"classId":4,"name":"Assassination","icon":"ability_rogue_eviscerate"}, + {"id":281,"classId":11,"name":"Feral Combat","icon":"ability_racial_bearform"}], + "nodes":[[1,181],[2,182],[3,281]], + "specClasses":[[1488,4],[1484,11]]}"#, + ) + .unwrap() +} + +fn aura(action: AuraAction) -> EventKind { + EventKind::Aura { + action, + aura_type: AuraType::Buff, + stacks: None, + broken_by: NO_SPELL, + } +} + +fn shown(fight: &Fight, player: u32) -> Option<(String, String, Role)> { + fight + .actors + .get(player) + .shown_spec() + .map(|ShownSpec { name, icon, role }| (name.to_string(), icon.to_string(), role)) +} + +#[test] +fn a_player_takes_the_tree_with_most_points() { + let mut b = FightBuilder::new(60_000); + let rogue = b.player("Player-1", "Ravel-Ashwood-Normal-EU", 1488); + b.fight + .talents + .insert(rogue, vec![(COMBAT_NODE, 35), (ASSASSINATION_NODE, 16)]); + let mut fight = b.build(); + + assign_talent_specs(&mut fight, &trees()); + + assert_eq!( + shown(&fight, rogue), + Some(("Combat".into(), "ability_backstab".into(), Role::Damage)) + ); + assert_eq!(fight.actors.get(rogue).class(), Some(4)); +} + +#[test] +fn a_tie_gives_no_talent_spec_but_the_class() { + let mut b = FightBuilder::new(60_000); + let rogue = b.player("Player-1", "Ravel-Ashwood-Normal-EU", 1488); + b.fight + .talents + .insert(rogue, vec![(COMBAT_NODE, 25), (ASSASSINATION_NODE, 25)]); + let mut fight = b.build(); + + assign_talent_specs(&mut fight, &trees()); + + assert_eq!(shown(&fight, rogue), None); + assert_eq!(fight.actors.get(rogue).class(), Some(4)); +} + +#[test] +fn a_feral_druid_tanks_a_pull_spent_in_bear_form() { + let role_with = |form: u32, applied_ms: i32, removed_ms: i32| { + let mut b = FightBuilder::new(100_000); + let druid = b.player("Player-1", "Brakk-Thornfield-Normal-EU", 1484); + b.fight.talents.insert(druid, vec![(FERAL_NODE, 31)]); + let form = b.spell(form, "Bear Form"); + if applied_ms >= 0 { + b.push(applied_ms, druid, druid, form, aura(AuraAction::Applied)); + } + b.push(removed_ms, druid, druid, form, aura(AuraAction::Removed)); + let mut fight = b.build(); + assign_talent_specs(&mut fight, &trees()); + shown(&fight, druid).map(|(_, _, role)| role) + }; + + assert_eq!(role_with(BEAR_FORM, 10_000, 35_000), Some(Role::Tank)); + assert_eq!( + role_with(DIRE_BEAR_FORM, 10_000, 20_000), + Some(Role::Damage) + ); + assert_eq!( + role_with(BEAR_FORM, -1, 22_000), + Some(Role::Tank), + "in Bear Form when the pull began" + ); +} + +#[test] +fn shown_spec_prefers_the_retail_spec() { + let mut b = FightBuilder::new(60_000); + let warrior = b.player("Player-1", "Faelan-Emberfall-EU", 73); + b.fight.talents.insert(warrior, vec![(COMBAT_NODE, 35)]); + let mut fight = b.build(); + + assign_talent_specs(&mut fight, &trees()); + + let retail = openlogs_gamedata::spec(73).unwrap(); + assert_eq!( + shown(&fight, warrior), + Some((retail.name.clone(), retail.icon.clone(), retail.role)) + ); +} diff --git a/crates/openlogs-cli/src/game_data.rs b/crates/openlogs-cli/src/game_data.rs index d97bc33..f9a6ef7 100644 --- a/crates/openlogs-cli/src/game_data.rs +++ b/crates/openlogs-cli/src/game_data.rs @@ -43,6 +43,10 @@ pub fn export(out_dir: &Path) -> Result<(), Box> { forever_dir.join("spell-classes.json"), forever.classes.to_json(), )?; + fs::write( + forever_dir.join("talent-trees.json"), + forever.talent_trees.to_json(), + )?; // Written last: the app reads the tables only once the manifest names them. let manifest = serde_json::json!({ "fetchedUnixMs": fetched_unix_ms, @@ -57,6 +61,7 @@ pub fn export(out_dir: &Path) -> Result<(), Box> { "spellIcons": forever.spells.icons.len(), "channelSpells": forever.spells.channels.len(), "spellClasses": forever.classes.class_spell_count(), + "talentTrees": forever.talent_trees.len(), }, }); fs::write(out_dir.join("manifest.json"), manifest.to_string())?; @@ -72,11 +77,12 @@ pub fn export(out_dir: &Path) -> Result<(), Box> { out_dir.display() ); println!( - "Forever {}: {} spells, {} channel spells and {} class spells written to {}", + "Forever {}: {} spells, {} channel spells, {} class spells and {} talent trees written to {}", forever.build, forever.spells.icons.len(), forever.spells.channels.len(), forever.classes.class_spell_count(), + forever.talent_trees.len(), forever_dir.display() ); Ok(()) diff --git a/crates/openlogs-gamedata/src/download.rs b/crates/openlogs-gamedata/src/download.rs index 3451194..947578d 100644 --- a/crates/openlogs-gamedata/src/download.rs +++ b/crates/openlogs-gamedata/src/download.rs @@ -7,6 +7,7 @@ use crate::fetch::{Fetch, FetchError}; use crate::map_art::{MapArtError, MapArtTable}; use crate::spell_classes::{SpellClasses, SpellClassesError}; use crate::spell_icons::{SpellIconError, SpellIconTable}; +use crate::talent_trees::{TalentTreeCsvs, TalentTrees, TalentTreesError}; pub const WAGO_SPELL_MISC_URL: &str = "https://wago.tools/db2/SpellMisc/csv"; pub const WAGO_SPELL_CLASS_OPTIONS_URL: &str = "https://wago.tools/db2/SpellClassOptions/csv"; @@ -41,6 +42,8 @@ pub enum DownloadError { BossPortraits(#[from] BossPortraitError), #[error("downloaded map art data is invalid: {0}")] MapArt(#[from] MapArtError), + #[error("downloaded talent tree data is invalid: {0}")] + TalentTrees(#[from] TalentTreesError), #[error("downloaded build list is invalid: {0}")] Builds(#[from] serde_json::Error), #[error("wago.tools lists no build of {0}")] @@ -58,11 +61,13 @@ pub struct ForeverTables { pub build: String, pub spells: SpellTables, pub classes: SpellClasses, + pub talent_trees: TalentTrees, } /// Builds the spell icon and channel tables from the wago.tools exports. pub fn download_spell_tables(fetch: &F) -> Result { - spell_tables(fetch, None) + let manifest = fetch.get(WAGO_MANIFEST_URL)?; + spell_tables(fetch, None, &manifest) } /// Builds the class and crowd-control spell table from the wago.tools exports. @@ -73,13 +78,39 @@ pub fn download_spell_classes(fetch: &F) -> Result(fetch: &F) -> Result { let build = latest_build(fetch, FOREVER_PRODUCT)?; + let manifest = fetch.get(&table_url(WAGO_MANIFEST_URL, Some(&build)))?; Ok(ForeverTables { - spells: spell_tables(fetch, Some(&build))?, + spells: spell_tables(fetch, Some(&build), &manifest)?, classes: spell_classes(fetch, Some(&build))?, + talent_trees: talent_trees(fetch, &build, &manifest)?, build, }) } +fn talent_trees( + fetch: &F, + build: &str, + manifest: &[u8], +) -> Result { + let table = |name: &str| { + fetch.get(&table_url( + &format!("https://wago.tools/db2/{name}/csv"), + Some(build), + )) + }; + Ok(TalentTrees::from_csv(&TalentTreeCsvs { + trait_node: &table("TraitNode")?, + node_x_entry: &table("TraitNodeXTraitNodeEntry")?, + node_entry: &table("TraitNodeEntry")?, + definition: &table("TraitDefinition")?, + talent: &table("Talent")?, + talent_tab: &table("TalentTab")?, + skill_line_x_trait_tree: &table("SkillLineXTraitTree")?, + chr_specialization: &table("ChrSpecialization")?, + manifest, + })?) +} + fn latest_build(fetch: &F, product: &'static str) -> Result { let builds: serde_json::Value = serde_json::from_slice(&fetch.get(WAGO_LATEST_BUILDS_URL)?)?; builds[product]["version"] @@ -96,11 +127,14 @@ fn table_url(base: &str, build: Option<&str>) -> String { } } -fn spell_tables(fetch: &F, build: Option<&str>) -> Result { +fn spell_tables( + fetch: &F, + build: Option<&str>, + manifest: &[u8], +) -> Result { let spell_misc = fetch.get(&table_url(WAGO_SPELL_MISC_URL, build))?; - let manifest = fetch.get(&table_url(WAGO_MANIFEST_URL, build))?; Ok(SpellTables { - icons: SpellIconTable::from_csv(&spell_misc, &manifest)?, + icons: SpellIconTable::from_csv(&spell_misc, manifest)?, channels: ChannelSpells::from_csv(&spell_misc)?, }) } diff --git a/crates/openlogs-gamedata/src/lib.rs b/crates/openlogs-gamedata/src/lib.rs index 2e20fab..0a1334c 100644 --- a/crates/openlogs-gamedata/src/lib.rs +++ b/crates/openlogs-gamedata/src/lib.rs @@ -14,6 +14,7 @@ mod map_art; mod specs; mod spell_classes; mod spell_icons; +mod talent_trees; pub use boss_portraits::{BossPortraitError, BossPortraitTable}; pub use channel_spells::{ChannelSpellError, ChannelSpells}; @@ -46,3 +47,6 @@ pub use map_art::{BossPin, MapArt, MapArtError, MapArtTable}; pub use specs::{ClassInfo, Role, SpecInfo, class, classes, spec, specs}; pub use spell_classes::{SpellClasses, SpellClassesError}; pub use spell_icons::{SpellIconError, SpellIconTable}; +pub use talent_trees::{ + BEAR_FORMS, TalentTree, TalentTreeCsvs, TalentTrees, TalentTreesError, TreeRole, tree_role, +}; diff --git a/crates/openlogs-gamedata/src/spell_icons.rs b/crates/openlogs-gamedata/src/spell_icons.rs index 7af11aa..8e07166 100644 --- a/crates/openlogs-gamedata/src/spell_icons.rs +++ b/crates/openlogs-gamedata/src/spell_icons.rs @@ -98,7 +98,7 @@ impl SpellIconTable { } /// File data ID → icon name for every file under `Interface\ICONS\` with a usable name. -fn read_icon_files(manifest: &[u8]) -> Result, SpellIconError> { +pub(crate) fn read_icon_files(manifest: &[u8]) -> Result, SpellIconError> { let mut reader = csv::Reader::from_reader(manifest); let headers = reader.headers()?.clone(); let id_col = column(&headers, "ID")?; diff --git a/crates/openlogs-gamedata/src/talent_trees.rs b/crates/openlogs-gamedata/src/talent_trees.rs new file mode 100644 index 0000000..d148d2e --- /dev/null +++ b/crates/openlogs-gamedata/src/talent_trees.rs @@ -0,0 +1,382 @@ +use std::collections::{BTreeMap, HashMap, HashSet}; + +use serde::{Deserialize, Serialize}; +use thiserror::Error; + +use crate::specs::Role; +use crate::spell_icons::{SpellIconError, read_icon_files}; + +/// Bear Form and Dire Bear Form. +pub const BEAR_FORMS: [u32; 2] = [5487, 9634]; + +/// `TraitNode.PosX` where the middle and the right column of a class tree begin. +const COLUMN_STARTS: [i64; 2] = [4000, 8000]; + +#[derive(Debug, Error)] +pub enum TalentTreesError { + #[error("CSV error: {0}")] + Csv(#[from] csv::Error), + #[error("CSV is missing the column {0}")] + MissingColumn(&'static str), + #[error("{0}")] + Icons(#[from] SpellIconError), + #[error("JSON error: {0}")] + Json(#[from] serde_json::Error), + #[error("the talent tree table is empty")] + Empty, + #[error("the columns of trait tree {0} do not name three trees of one class")] + UnresolvedTree(u32), +} + +/// A Forever talent tree, named by the classic `TalentTab` it continues. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct TalentTree { + pub id: u32, + pub class_id: u32, + pub name: String, + pub icon: String, +} + +/// How a tree's players are counted: one role, or by the share of a pull spent in Bear Form. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TreeRole { + Fixed(Role), + BearForm, +} + +pub fn tree_role(tree_id: u32) -> TreeRole { + match tree_id { + 163 | 383 => TreeRole::Fixed(Role::Tank), + 201 | 202 | 382 | 262 | 282 => TreeRole::Fixed(Role::Healer), + 281 => TreeRole::BearForm, + _ => TreeRole::Fixed(Role::Damage), + } +} + +/// The wago.tools exports the talent trees are derived from. +pub struct TalentTreeCsvs<'a> { + pub trait_node: &'a [u8], + pub node_x_entry: &'a [u8], + pub node_entry: &'a [u8], + pub definition: &'a [u8], + pub talent: &'a [u8], + pub talent_tab: &'a [u8], + pub skill_line_x_trait_tree: &'a [u8], + pub chr_specialization: &'a [u8], + pub manifest: &'a [u8], +} + +/// Forever's talent trees: which tree each trait node belongs to, and the class of each of its +/// class specs. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct TalentTrees { + trees: BTreeMap, + node_trees: HashMap, + spec_classes: HashMap, +} + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct WebTable { + trees: Vec, + nodes: Vec<(u32, u32)>, + spec_classes: Vec<(u32, u32)>, +} + +impl TalentTrees { + /// A class tree lays its talents out in three columns. A node belongs to the classic tree that + /// most of its column's talents come from, also when Forever moved it there from another tree. + pub fn from_csv(csvs: &TalentTreeCsvs<'_>) -> Result { + let class_trees: HashSet = numbers(csvs.skill_line_x_trait_tree, ["TraitTreeID"])? + .into_iter() + .map(|[tree]| tree) + .collect(); + let entry_of_node: HashMap = + numbers(csvs.node_x_entry, ["TraitNodeID", "TraitNodeEntryID"])? + .into_iter() + .map(|[node, entry]| (node, entry)) + .collect(); + let definition_of_entry: HashMap = + numbers(csvs.node_entry, ["ID", "TraitDefinitionID"])? + .into_iter() + .map(|[entry, definition]| (entry, definition)) + .collect(); + let spell_of_definition: HashMap = numbers(csvs.definition, ["ID", "SpellID"])? + .into_iter() + .map(|[definition, spell]| (definition, spell)) + .collect(); + let tab_of_spell = classic_talent_tabs(csvs.talent)?; + let classic_tab = |node: u32| { + let definition = definition_of_entry.get(entry_of_node.get(&node)?)?; + tab_of_spell + .get(spell_of_definition.get(definition)?) + .copied() + }; + + let nodes: Vec<(u32, (u32, usize))> = + signed(csvs.trait_node, ["ID", "TraitTreeID", "PosX"])? + .into_iter() + .filter_map(|[node, tree, x]| { + let (node, tree) = (u32::try_from(node).ok()?, u32::try_from(tree).ok()?); + class_trees + .contains(&tree) + .then_some((node, (tree, column(x)))) + }) + .collect(); + let mut votes: HashMap<(u32, usize), BTreeMap> = HashMap::new(); + for &(node, place) in &nodes { + if let Some(tab) = classic_tab(node) { + *votes.entry(place).or_default().entry(tab).or_default() += 1; + } + } + let column_tabs: HashMap<(u32, usize), u32> = votes + .into_iter() + .filter_map(|(place, tabs)| { + let top = tabs + .iter() + .max_by_key(|&(&tab, &count)| (count, std::cmp::Reverse(tab)))?; + Some((place, *top.0)) + }) + .collect(); + let node_trees = nodes + .into_iter() + .filter_map(|(node, place)| Some((node, *column_tabs.get(&place)?))) + .collect(); + + let icons = read_icon_files(csvs.manifest)?; + let trees: BTreeMap = talent_tabs(csvs.talent_tab)? + .into_iter() + .filter_map(|(id, class_mask, name, icon)| { + let class_id = class_of_mask(class_mask)?; + let icon = icons + .get(&icon) + .cloned() + .unwrap_or_else(|| icon.to_string()); + Some(( + id, + TalentTree { + id, + class_id, + name, + icon, + }, + )) + }) + .collect(); + for &class_tree in &class_trees { + let tabs: Vec> = (0..=COLUMN_STARTS.len()) + .map(|column| { + column_tabs + .get(&(class_tree, column)) + .and_then(|tab| trees.get(tab)) + }) + .collect(); + let resolved = tabs.iter().all(Option::is_some) + && tabs + .iter() + .flatten() + .map(|tree| tree.id) + .collect::>() + .len() + == tabs.len() + && tabs + .iter() + .flatten() + .map(|tree| tree.class_id) + .collect::>() + .len() + == 1; + if !resolved { + return Err(TalentTreesError::UnresolvedTree(class_tree)); + } + } + let spec_classes = numbers(csvs.chr_specialization, ["ID", "ClassID"])? + .into_iter() + .filter(|&[_, class]| class != 0) + .map(|[spec, class]| (spec, class)) + .collect(); + Ok(Self { + trees, + node_trees, + spec_classes, + }) + } + + pub fn tree(&self, id: u32) -> Option<&TalentTree> { + self.trees.get(&id) + } + + pub fn class_of_spec(&self, spec_id: u32) -> Option { + self.spec_classes.get(&spec_id).copied() + } + + /// The tree with the most points of `talents` (node, rank); `None` on a tie or without points. + pub fn spec_of(&self, talents: impl IntoIterator) -> Option<&TalentTree> { + let mut points: BTreeMap = BTreeMap::new(); + for (node, rank) in talents { + if let Some(&tree) = self.node_trees.get(&node) { + *points.entry(tree).or_default() += rank; + } + } + let most = points.values().copied().max().filter(|&most| most > 0)?; + let mut leaders = points.iter().filter(|&(_, &p)| p == most); + let (&tree, _) = leaders.next()?; + if leaders.next().is_some() { + return None; + } + self.tree(tree) + } + + pub fn len(&self) -> usize { + self.trees.len() + } + + pub fn is_empty(&self) -> bool { + self.trees.is_empty() + } + + pub fn to_json(&self) -> String { + let mut nodes: Vec<(u32, u32)> = self.node_trees.iter().map(|(&n, &t)| (n, t)).collect(); + nodes.sort_unstable(); + let mut spec_classes: Vec<(u32, u32)> = + self.spec_classes.iter().map(|(&s, &c)| (s, c)).collect(); + spec_classes.sort_unstable(); + let table = WebTable { + trees: self.trees.values().cloned().collect(), + nodes, + spec_classes, + }; + serde_json::to_string(&table).expect("the talent tree table serializes") + } + + pub fn from_json(text: &str) -> Result { + let table: WebTable = serde_json::from_str(text)?; + if table.trees.is_empty() { + return Err(TalentTreesError::Empty); + } + Ok(Self { + trees: table + .trees + .into_iter() + .map(|tree| (tree.id, tree)) + .collect(), + node_trees: table.nodes.into_iter().collect(), + spec_classes: table.spec_classes.into_iter().collect(), + }) + } +} + +fn column(x: i64) -> usize { + COLUMN_STARTS.iter().filter(|&&start| x >= start).count() +} + +/// `ClassMask` has one bit per class, the class ID's bit counted from 1. +fn class_of_mask(mask: u32) -> Option { + mask.is_power_of_two().then(|| mask.trailing_zeros() + 1) +} + +/// Spell of any rank of a classic talent → its `TalentTab`. +fn classic_talent_tabs(talent: &[u8]) -> Result, TalentTreesError> { + let mut reader = csv::Reader::from_reader(talent); + let headers = reader.headers()?.clone(); + let tab_col = column_of(&headers, "TabID")?; + let rank_cols: Vec = headers + .iter() + .enumerate() + .filter(|(_, header)| header.starts_with("SpellRank_")) + .map(|(col, _)| col) + .collect(); + let mut tabs = HashMap::new(); + for record in reader.records() { + let record = record?; + let parse = |col: usize| record.get(col).and_then(|v| v.parse::().ok()); + let Some(tab) = parse(tab_col) else { continue }; + for spell in rank_cols + .iter() + .filter_map(|&col| parse(col)) + .filter(|&s| s != 0) + { + tabs.insert(spell, tab); + } + } + Ok(tabs) +} + +/// `(ID, ClassMask, Name_lang, SpellIconID)` of each `TalentTab`. +fn talent_tabs(talent_tab: &[u8]) -> Result, TalentTreesError> { + let mut reader = csv::Reader::from_reader(talent_tab); + let headers = reader.headers()?.clone(); + let cols = [ + column_of(&headers, "ID")?, + column_of(&headers, "ClassMask")?, + column_of(&headers, "Name_lang")?, + column_of(&headers, "SpellIconID")?, + ]; + let mut tabs = Vec::new(); + for record in reader.records() { + let record = record?; + let parse = |col: usize| record.get(col).and_then(|v| v.parse::().ok()); + if let (Some(id), Some(mask), Some(name), Some(icon)) = ( + parse(cols[0]), + parse(cols[1]), + record.get(cols[2]), + parse(cols[3]), + ) { + tabs.push((id, mask, name.to_string(), icon)); + } + } + Ok(tabs) +} + +fn numbers( + csv_bytes: &[u8], + names: [&'static str; N], +) -> Result, TalentTreesError> { + Ok(signed(csv_bytes, names)? + .into_iter() + .filter_map(|row| { + let mut values = [0; N]; + for (value, &v) in values.iter_mut().zip(&row) { + *value = u32::try_from(v).ok()?; + } + Some(values) + }) + .collect()) +} + +/// The named columns of every row where all of them are numbers. +fn signed( + csv_bytes: &[u8], + names: [&'static str; N], +) -> Result, TalentTreesError> { + let mut reader = csv::Reader::from_reader(csv_bytes); + let headers = reader.headers()?.clone(); + let mut cols = [0; N]; + for (col, name) in cols.iter_mut().zip(names) { + *col = column_of(&headers, name)?; + } + let mut rows = Vec::new(); + for record in reader.records() { + let record = record?; + let mut values = [0; N]; + let complete = values.iter_mut().zip(cols).all(|(value, col)| { + record + .get(col) + .and_then(|v| v.parse::().ok()) + .map(|v| *value = v) + .is_some() + }); + if complete { + rows.push(values); + } + } + Ok(rows) +} + +fn column_of(headers: &csv::StringRecord, name: &'static str) -> Result { + headers + .iter() + .position(|header| header == name) + .ok_or(TalentTreesError::MissingColumn(name)) +} diff --git a/crates/openlogs-gamedata/tests/download.rs b/crates/openlogs-gamedata/tests/download.rs index 726d0c7..30fd446 100644 --- a/crates/openlogs-gamedata/tests/download.rs +++ b/crates/openlogs-gamedata/tests/download.rs @@ -7,9 +7,18 @@ use openlogs_gamedata::{ const SPELL_MISC: &str = "ID,Attributes_1,DifficultyID,SpellIconFileDataID,SpellID\n1,0,0,132276,5487\n"; const MANIFEST: &str = - "ID,FilePath,FileName\n132276,Interface\\Icons\\,Ability_Racial_BearForm.blp\n"; + "ID,FilePath,FileName\n132276,Interface\\ICONS\\,Ability_Racial_BearForm.blp\n"; const SPELL_CLASS_OPTIONS: &str = "ID,SpellID,SpellClassSet\n1,5487,7\n"; const SPELL_EFFECT: &str = "ID,EffectAura,SpellID\n1,0,5487\n"; +/// The druid tree with one talent in each column: Balance, Feral Combat, Restoration. +const TRAIT_NODE: &str = "ID,TraitTreeID,PosX\n0,1089,1000\n1,1089,5000\n2,1089,9000\n"; +const NODE_X_ENTRY: &str = "TraitNodeID,TraitNodeEntryID\n0,10\n1,11\n2,12\n"; +const NODE_ENTRY: &str = "ID,TraitDefinitionID\n10,20\n11,21\n12,22\n"; +const DEFINITION: &str = "ID,SpellID\n20,16814\n21,16934\n22,17050\n"; +const TALENT: &str = "TabID,SpellRank_0\n283,16814\n281,16934\n282,17050\n"; +const TALENT_TAB: &str = "ID,Name_lang,ClassMask,SpellIconID\n283,Balance,1024,132276\n281,Feral Combat,1024,132276\n282,Restoration,1024,132276\n"; +const SKILL_LINE_X_TRAIT_TREE: &str = "SkillLineID,TraitTreeID\n574,1089\n"; +const CHR_SPECIALIZATION: &str = "ID,ClassID\n1484,11\n"; /// Answers wago.tools requests from fixed tables and records every URL asked for. struct FakeWago { @@ -38,6 +47,14 @@ impl Fetch for FakeWago { Some("ManifestInterfaceData") => MANIFEST, Some("SpellClassOptions") => SPELL_CLASS_OPTIONS, Some("SpellEffect") => SPELL_EFFECT, + Some("TraitNode") => TRAIT_NODE, + Some("TraitNodeXTraitNodeEntry") => NODE_X_ENTRY, + Some("TraitNodeEntry") => NODE_ENTRY, + Some("TraitDefinition") => DEFINITION, + Some("Talent") => TALENT, + Some("TalentTab") => TALENT_TAB, + Some("SkillLineXTraitTree") => SKILL_LINE_X_TRAIT_TREE, + Some("ChrSpecialization") => CHR_SPECIALIZATION, _ => return Err(FetchError::Status(404)), }; Ok(body.as_bytes().to_vec()) @@ -57,12 +74,18 @@ fn forever_tables_come_from_the_latest_forever_build() { Some("ability_racial_bearform") ); assert!(tables.classes.is_class_spell(5487)); + let feral = tables.talent_trees.spec_of([(1, 5)]).unwrap(); + assert_eq!( + (feral.name.as_str(), feral.icon.as_str()), + ("Feral Combat", "ability_racial_bearform") + ); + assert_eq!(tables.talent_trees.class_of_spec(1484), Some(11)); let asked = wago.asked.lock().unwrap(); let tables_asked: Vec<&String> = asked .iter() .filter(|url| url.as_str() != WAGO_LATEST_BUILDS_URL) .collect(); - assert_eq!(tables_asked.len(), 4, "asked {asked:?}"); + assert_eq!(tables_asked.len(), 12, "asked {asked:?}"); for url in tables_asked { assert!(url.ends_with("/csv?build=1.60.1.70959"), "asked {url}"); } diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/ChrSpecialization.csv b/crates/openlogs-gamedata/tests/fixtures/forever/ChrSpecialization.csv new file mode 100644 index 0000000..c3b6885 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/ChrSpecialization.csv @@ -0,0 +1,11 @@ +Name_lang,FemaleName_lang,Description_lang,ID,ClassID,OrderIndex,PetTalentType,Role,Flags,SpellIconFileID,PrimaryStatPriority,AnimReplacements,MasterySpellID_0,MasterySpellID_1 +Mage,Mage,,1482,8,0,0,2,4,626001,0,0,0,0 +Druid,Druid,,1484,11,0,0,2,4,625999,0,0,0,0 +Hunter,Hunter,,1485,3,0,0,2,4,626000,0,0,0,0 +Paladin,Paladin,,1486,2,0,0,2,4,626003,0,0,0,0 +Priest,Priest,,1487,5,0,0,2,4,626004,0,0,0,0 +Rogue,Rogue,,1488,4,0,0,2,4,626005,0,0,0,0 +Shaman,Shaman,,1489,7,0,0,2,4,626006,0,0,0,0 +Warlock,Warlock,,1490,9,0,0,2,4,626007,0,0,0,0 +Warrior,Warrior,,1491,1,0,0,2,4,626008,0,0,0,0 +Default,Default,I'm a pet!,1493,0,0,0,2,0,6642732,3,0,0,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/ManifestInterfaceData.csv b/crates/openlogs-gamedata/tests/fixtures/forever/ManifestInterfaceData.csv new file mode 100644 index 0000000..45bac70 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/ManifestInterfaceData.csv @@ -0,0 +1,27 @@ +ID,FilePath,FileName +132090,Interface\ICONS\,Ability_BackStab.blp +132164,Interface\ICONS\,Ability_Hunter_BeastTaming.blp +132215,Interface\ICONS\,Ability_Hunter_SwiftStrike.blp +132222,Interface\ICONS\,Ability_Marksmanship.blp +132276,Interface\ICONS\,Ability_Racial_BearForm.blp +132292,Interface\ICONS\,Ability_Rogue_Eviscerate.blp +132320,Interface\ICONS\,Ability_Stealth.blp +132347,Interface\ICONS\,Ability_Warrior_InnerRage.blp +134952,Interface\ICONS\,INV_Shield_06.blp +135810,Interface\ICONS\,Spell_Fire_FireBolt02.blp +135846,Interface\ICONS\,Spell_Frost_FrostBolt02.blp +135873,Interface\ICONS\,Spell_Holy_AuraOfLight.blp +135893,Interface\ICONS\,SPELL_HOLY_DEVOTIONAURA.BLP +135920,Interface\ICONS\,Spell_Holy_HolyBolt.blp +135932,Interface\ICONS\,Spell_Holy_MagicalSentry.blp +135987,Interface\ICONS\,Spell_Holy_WordFortitude.blp +136041,Interface\ICONS\,SPELL_NATURE_HEALINGTOUCH.BLP +136048,Interface\ICONS\,Spell_Nature_Lightning.blp +136051,Interface\ICONS\,Spell_Nature_LightningShield.blp +136052,Interface\ICONS\,Spell_Nature_MagicImmunity.blp +136096,Interface\ICONS\,Spell_Nature_StarFall.blp +136145,Interface\ICONS\,Spell_Shadow_DeathCoil.blp +136172,Interface\ICONS\,Spell_Shadow_Metamorphosis.blp +136186,Interface\ICONS\,Spell_Shadow_RainOfFire.blp +136207,Interface\ICONS\,Spell_Shadow_ShadowWordPain.blp +237542,Interface\ICONS\,Spell_Holy_GuardianSpirit.blp diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/SkillLineXTraitTree.csv b/crates/openlogs-gamedata/tests/fixtures/forever/SkillLineXTraitTree.csv new file mode 100644 index 0000000..1ac7592 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/SkillLineXTraitTree.csv @@ -0,0 +1,3 @@ +ID,SkillLineID,TraitTreeID,Variant +158,574,1089,0 +162,38,1111,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/Talent.csv b/crates/openlogs-gamedata/tests/fixtures/forever/Talent.csv new file mode 100644 index 0000000..8024ef3 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/Talent.csv @@ -0,0 +1,99 @@ +ID,Description_lang,TierID,Flags,ColumnIndex,TabID,ClassID,SpecID,SpellID,OverridesSpellID,RequiredSpellID,CategoryMask_0,CategoryMask_1,SpellRank_0,SpellRank_1,SpellRank_2,SpellRank_3,SpellRank_4,SpellRank_5,SpellRank_6,SpellRank_7,SpellRank_8,PrereqTalent_0,PrereqTalent_1,PrereqTalent_2,PrereqRank_0,PrereqRank_1,PrereqRank_2 +181,,1,0,2,181,0,0,0,0,0,0,0,13705,13832,13843,13844,13845,0,0,0,0,0,0,0,0,0,0 +182,,3,0,1,181,0,0,0,0,0,0,0,13706,13804,13805,13806,13807,0,0,0,0,0,0,0,0,0,0 +183,,4,0,3,181,0,0,0,0,0,0,0,13707,13966,13967,13968,13969,0,0,0,0,0,0,0,0,0,0 +184,,4,0,0,181,0,0,0,0,0,0,0,13709,13800,13801,13802,13803,0,0,0,0,0,0,0,0,0,0 +186,,0,0,2,181,0,0,0,0,0,0,0,13712,13788,13789,13790,13791,0,0,0,0,0,0,0,0,0,0 +187,,1,0,1,181,0,0,0,0,0,0,0,13713,13853,13854,13855,13856,0,0,0,0,0,0,0,0,0,0 +201,,0,0,1,181,0,0,0,0,0,0,0,13732,13863,0,0,0,0,0,0,0,0,0,0,0,0,0 +202,,1,0,0,181,0,0,0,0,0,0,0,13733,13865,13866,0,0,0,0,0,0,0,0,0,0,0,0 +203,,0,0,0,181,0,0,0,0,0,0,0,13741,13793,13792,0,0,0,0,0,0,0,0,0,0,0,0 +204,,2,0,0,181,0,0,0,0,0,0,0,13742,13872,0,0,0,0,0,0,0,0,0,0,0,0,0 +205,,6,1,1,181,0,0,0,0,0,0,0,13750,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +206,,3,0,0,181,0,0,0,0,0,0,0,13754,13867,0,0,0,0,0,0,0,0,0,0,0,0,0 +221,,3,0,2,181,0,0,0,0,0,0,0,13715,13848,13849,13851,13852,0,0,0,0,181,0,0,4,0,0 +222,,2,0,3,181,0,0,0,0,0,0,0,13743,13875,0,0,0,0,0,0,0,0,0,0,0,0,0 +223,,4,1,1,181,0,0,0,0,0,0,0,13877,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +241,,0,0,1,183,0,0,0,0,0,0,0,13958,13970,13971,13972,13973,0,0,0,0,0,0,0,0,0,0 +242,,4,0,2,181,0,0,0,0,0,0,0,13960,13961,13962,13963,13964,0,0,0,0,0,0,0,0,0,0 +244,,1,0,2,183,0,0,0,0,0,0,0,13975,14062,14063,14064,14065,0,0,0,0,0,0,0,0,0,0 +245,,2,0,0,183,0,0,0,0,0,0,0,13976,13979,13980,0,0,0,0,0,0,0,0,0,0,0,0 +246,,3,0,0,183,0,0,0,0,0,0,0,13983,14070,14071,0,0,0,0,0,0,0,0,0,0,0,0 +247,,1,0,1,183,0,0,0,0,0,0,0,13981,14066,0,0,0,0,0,0,0,0,0,0,0,0,0 +261,,0,0,2,183,0,0,0,0,0,0,0,14057,14072,14073,14074,14075,0,0,0,0,0,0,0,0,0,0 +262,,3,0,1,183,0,0,0,0,0,0,0,14076,14094,14095,0,0,0,0,0,0,0,0,0,0,0,0 +263,,2,0,2,183,0,0,0,0,0,0,0,14079,14080,14081,0,0,0,0,0,0,0,0,0,0,0,0 +265,,4,0,2,183,0,0,0,0,0,0,0,14082,14083,0,0,0,0,0,0,0,0,0,0,0,0,0 +268,,3,0,2,182,0,0,0,0,0,0,0,14113,14114,14115,14116,14117,0,0,0,0,0,0,0,0,0,0 +269,,2,0,2,182,0,0,0,0,0,0,0,14128,14132,14135,14136,14137,0,0,0,0,270,0,0,4,0,0 +270,,0,0,2,182,0,0,0,0,0,0,0,14138,14139,14140,14141,14142,0,0,0,0,0,0,0,0,0,0 +272,,0,0,1,182,0,0,0,0,0,0,0,14144,14148,0,0,0,0,0,0,0,0,0,0,0,0,0 +273,,1,0,0,182,0,0,0,0,0,0,0,14156,14160,14161,0,0,0,0,0,0,0,0,0,0,0,0 +274,,1,0,1,182,0,0,0,0,0,0,0,14158,14159,0,0,0,0,0,0,0,0,0,0,0,0,0 +276,,0,0,0,182,0,0,0,0,0,0,0,14162,14163,14164,0,0,0,0,0,0,0,0,0,0,0,0 +277,,1,0,3,182,0,0,0,0,0,0,0,14165,14166,14167,0,0,0,0,0,0,0,0,0,0,0,0 +278,,2,0,1,182,0,0,0,0,0,0,0,14168,14169,0,0,0,0,0,0,0,0,0,0,0,0,0 +279,,4,0,2,182,0,0,0,0,0,0,0,14174,14175,14176,0,0,0,0,0,0,0,0,0,0,0,0 +280,,4,1,1,182,0,0,0,0,0,0,0,14177,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +281,,2,1,0,182,0,0,0,0,0,0,0,14179,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +283,,5,0,1,182,0,0,0,0,0,0,0,14186,14190,14193,14194,14195,0,0,0,0,280,0,0,0,0,0 +284,,4,1,1,183,0,0,0,0,0,0,0,14185,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +301,,2,1,1,181,0,0,0,0,0,0,0,14251,0,0,0,0,0,0,0,0,187,0,0,4,0,0 +303,,2,1,1,183,0,0,0,0,0,0,0,14278,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +381,,6,1,1,183,0,0,0,0,0,0,0,14183,0,0,0,0,0,0,0,0,284,0,0,0,0,0 +382,,6,0,1,182,0,0,0,0,0,0,0,14983,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +681,,4,1,3,183,0,0,0,0,0,0,0,16511,0,0,0,0,0,0,0,0,1123,0,0,2,0,0 +682,,3,0,1,182,0,0,0,0,0,0,0,16513,16514,16515,16719,16720,0,0,0,0,0,0,0,0,0,0 +761,,0,1,1,283,0,0,0,0,339,0,0,16689,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +762,,0,0,0,283,0,0,0,0,0,0,0,16814,16815,16816,16817,16818,0,0,0,0,0,0,0,0,0,0 +763,,1,0,1,283,0,0,0,0,0,0,0,16821,16822,16823,16824,16825,0,0,0,0,0,0,0,0,0,0 +764,,2,0,3,283,0,0,0,0,0,0,0,16819,16820,0,0,0,0,0,0,0,0,0,0,0,0,0 +781,,1,0,3,283,0,0,0,0,0,0,0,16833,16834,16835,0,0,0,0,0,0,0,0,0,0,0,0 +782,,2,0,0,283,0,0,0,0,0,0,0,16836,16839,16840,0,0,0,0,0,0,0,0,0,0,0,0 +783,,4,0,2,283,0,0,0,0,0,0,0,16845,16846,16847,0,0,0,0,0,0,0,0,0,0,0,0 +784,,3,0,2,283,0,0,0,0,0,0,0,16850,16923,16924,16925,16926,0,0,0,0,0,0,0,0,0,0 +787,,1,0,0,283,0,0,0,0,0,0,0,16918,16919,16920,0,0,0,0,0,0,0,0,0,0,0,0 +788,,2,1,2,283,0,0,0,0,0,0,0,16864,0,0,0,0,0,0,0,0,791,0,0,4,0,0 +789,,4,0,1,283,0,0,0,0,0,0,0,16880,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +790,,5,0,1,283,0,0,0,0,0,0,0,16896,16897,16899,16900,16901,0,0,0,0,789,0,0,0,0,0 +791,,1,0,2,283,0,0,0,0,0,0,0,16902,16903,16904,16905,16906,0,0,0,0,0,0,0,0,0,0 +792,,3,0,1,283,0,0,0,0,0,0,0,16909,16910,16911,16912,16913,0,0,0,0,763,0,0,4,0,0 +793,,6,1,1,283,0,0,0,0,0,0,0,24858,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +794,,1,0,2,281,0,0,0,0,0,0,0,16929,16930,16931,16932,16933,0,0,0,0,0,0,0,0,0,0 +795,,0,0,2,281,0,0,0,0,0,0,0,16858,16859,16860,16861,16862,0,0,0,0,0,0,0,0,0,0 +796,,0,0,1,281,0,0,0,0,0,0,0,16934,16935,16936,16937,16938,0,0,0,0,0,0,0,0,0,0 +797,,1,0,1,281,0,0,0,0,0,0,0,16940,16941,0,0,0,0,0,0,0,0,0,0,0,0,0 +798,,2,0,2,281,0,0,0,0,0,0,0,16942,16943,16944,0,0,0,0,0,0,0,0,0,0,0,0 +799,,1,0,0,281,0,0,0,0,0,0,0,16947,16948,16949,16950,16951,0,0,0,0,0,0,0,0,0,0 +800,,3,0,2,281,0,0,0,0,0,0,0,16952,16954,0,0,0,0,0,0,0,798,0,0,2,0,0 +801,,3,0,3,281,0,0,0,0,0,0,0,16958,16961,0,0,0,0,0,0,0,798,0,0,2,0,0 +802,,3,0,0,281,0,0,0,0,0,0,0,16966,16968,0,0,0,0,0,0,0,0,0,0,0,0,0 +803,,3,0,1,281,0,0,0,0,0,0,0,16972,16974,16975,0,0,0,0,0,0,0,0,0,0,0,0 +804,,2,1,1,281,0,0,0,0,0,0,0,16979,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +805,,4,0,0,281,0,0,0,0,0,0,0,16998,16999,0,0,0,0,0,0,0,0,0,0,0,0,0 +807,,2,0,0,281,0,0,0,0,0,0,0,17002,24866,0,0,0,0,0,0,0,0,0,0,0,0,0 +808,,5,0,1,281,0,0,0,0,0,0,0,17003,17004,17005,17006,24894,0,0,0,0,803,0,0,2,0,0 +809,,6,1,1,281,0,0,0,0,0,0,0,17007,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +821,,0,0,1,282,0,0,0,0,0,0,0,17050,17051,17053,17054,17055,0,0,0,0,0,0,0,0,0,0 +822,,0,0,2,282,0,0,0,0,0,0,0,17056,17058,17059,17060,17061,0,0,0,0,0,0,0,0,0,0 +823,,1,0,1,282,0,0,0,0,0,0,0,17063,17065,17066,17067,17068,0,0,0,0,0,0,0,0,0,0 +824,,1,0,0,282,0,0,0,0,0,0,0,17069,17070,17071,17072,17073,0,0,0,0,0,0,0,0,0,0 +825,,5,0,2,282,0,0,0,0,0,0,0,17074,17075,17076,17077,17078,0,0,0,0,0,0,0,0,0,0 +826,,1,0,2,282,0,0,0,0,0,0,0,17079,17082,0,0,0,0,0,0,0,0,0,0,4,0,0 +827,,2,1,2,282,0,0,0,0,0,0,0,5570,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +828,,4,0,2,282,0,0,0,0,0,0,0,17104,24943,24944,24945,24946,0,0,0,0,827,0,0,0,0,0 +829,,2,0,1,282,0,0,0,0,0,0,0,17106,17107,17108,0,0,0,0,0,0,0,0,0,0,0,0 +830,,3,0,3,282,0,0,0,0,0,0,0,17111,17112,17113,0,0,0,0,0,0,0,0,0,0,0,0 +831,,4,1,0,282,0,0,0,0,0,0,0,17116,0,0,0,0,0,0,0,0,824,0,0,4,0,0 +841,,2,0,3,282,0,0,0,0,0,0,0,17118,17119,17120,17121,17122,0,0,0,0,0,0,0,0,0,0 +842,,4,0,3,282,0,0,0,0,0,0,0,17123,17124,0,0,0,0,0,0,0,0,0,0,0,0,0 +843,,3,0,1,282,0,0,0,0,0,0,0,24968,24969,24970,24971,24972,0,0,0,0,0,0,0,0,0,0 +844,,6,1,1,282,0,0,0,0,0,0,0,18562,0,0,0,0,0,0,0,0,843,0,0,4,0,0 +921,,0,0,2,283,0,0,0,0,0,0,0,17245,17247,17248,17249,0,0,0,0,0,761,0,0,0,0,0 +1122,,5,0,2,181,0,0,0,0,0,0,0,18427,18428,18429,0,0,0,0,0,0,0,0,0,0,0,0 +1123,,3,0,2,183,0,0,0,0,0,0,0,14171,14172,14173,0,0,0,0,0,0,0,0,0,0,0,0 +1162,,4,1,2,281,0,0,0,0,0,0,0,16857,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +1700,,1,0,0,183,0,0,0,0,0,0,0,30892,30893,0,0,0,0,0,0,0,0,0,0,0,0,0 +1701,,4,0,0,183,0,0,0,0,0,0,0,30894,30895,0,0,0,0,0,0,0,0,0,0,0,0,0 +1702,,5,0,2,183,0,0,0,0,0,0,0,30902,30903,30904,30905,30906,0,0,0,0,0,0,0,0,0,0 +1703,,5,0,1,181,0,0,0,0,0,0,0,30919,30920,0,0,0,0,0,0,0,223,0,0,0,0,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/TalentTab.csv b/crates/openlogs-gamedata/tests/fixtures/forever/TalentTab.csv new file mode 100644 index 0000000..69e7a73 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/TalentTab.csv @@ -0,0 +1,28 @@ +ID,Name_lang,BackgroundFile,Description_lang,OrderIndex,Field_4_4_0_53627_004,ClassMask,CategoryEnumID,SpellIconID,RoleMask,MasterySpellID_0,MasterySpellID_1 +41,Fire,MageFire,,1,0,128,0,135810,0,0,0 +61,Frost,MageFrost,,2,0,128,0,135846,0,0,0 +81,Arcane,MageArcane,,0,0,128,0,135932,0,0,0 +161,Arms,WarriorArms,,0,0,1,0,132292,0,0,0 +163,Protection,WarriorProtection,,2,0,1,0,134952,0,0,0 +164,Fury,WarriorFury,,1,0,1,0,132347,0,0,0 +181,Combat,RogueCombat,,1,0,8,0,132090,0,0,0 +182,Assassination,RogueAssassination,,0,0,8,0,132292,0,0,0 +183,Subtlety,RogueSubtlety,,2,0,8,0,132320,0,0,0 +201,Discipline,PriestDiscipline,,0,0,16,0,135987,0,0,0 +202,Holy,PriestHoly,,1,0,16,0,237542,0,0,0 +203,Shadow,PriestShadow,,2,0,16,0,136207,0,0,0 +261,Elemental,ShamanElementalCombat,,0,0,64,0,136048,0,0,0 +262,Restoration,ShamanRestoration,,2,0,64,0,136052,0,0,0 +263,Enhancement,ShamanEnhancement,,1,0,64,0,136051,0,0,0 +281,Feral Combat,DruidFeralCombat,,1,0,1024,0,132276,0,0,0 +282,Restoration,DruidRestoration,,2,0,1024,0,136041,0,0,0 +283,Balance,DruidBalance,,0,0,1024,0,136096,0,0,0 +301,Destruction,WarlockDestruction,,2,0,256,0,136186,0,0,0 +302,Affliction,WarlockCurses,,0,0,256,0,136145,0,0,0 +303,Demonology,WarlockSummoning,,1,0,256,0,136172,0,0,0 +361,Beast Mastery,HunterBeastMastery,,0,0,4,0,132164,0,0,0 +362,Survival,HunterSurvival,,2,0,4,0,132215,0,0,0 +363,Marksmanship,HunterMarksmanship,,1,0,4,0,132222,0,0,0 +381,Retribution,PaladinCombat,,2,0,2,0,135873,0,0,0 +382,Holy,PaladinHoly,,0,0,2,0,135920,0,0,0 +383,Protection,PaladinProtection,,1,0,2,0,135893,0,0,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/TraitDefinition.csv b/crates/openlogs-gamedata/tests/fixtures/forever/TraitDefinition.csv new file mode 100644 index 0000000..1e8f049 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/TraitDefinition.csv @@ -0,0 +1,142 @@ +OverrideName_lang,OverrideSubtext_lang,OverrideDescription_lang,ID,SpellID,OverrideIcon,OverridesSpellID,VisibleSpellID +,,,134236,17056,0,0,0 +,,,134237,17063,0,0,0 +,,,134238,17007,0,0,0 +,,,134239,417051,0,0,0 +,,,134240,1223246,0,0,0 +,,,134241,417046,0,0,0 +,,,134242,417141,0,0,0 +,,,134243,1223242,0,0,0 +,,,134244,22571,0,0,0 +,,,134245,16958,0,0,0 +16972,,,134246,0,0,0,0 +,,,134247,16966,0,0,0 +,,,134248,16942,0,0,0 +,,,134249,16979,0,0,0 +,,,134250,16998,0,0,0 +,,,134251,17002,0,0,0 +,,,134252,16929,0,0,0 +,,,134253,16940,0,0,0 +,,,134254,16947,0,0,0 +,,,134255,17003,0,0,0 +,,,134256,16934,0,0,0 +,,,134257,24858,0,0,0 +,,,134258,16896,0,0,0 +,,,134259,408258,0,0,0 +,,,134260,16880,0,0,0 +,,,134261,408248,0,0,0 +,,,134262,16909,0,0,0 +,,,134263,5570,0,0,0 +,,,134264,16819,0,0,0 +,,,134265,1223083,0,0,0 +,,,134266,16918,0,0,0 +,,,134268,1223082,0,0,0 +,,,134269,16845,0,0,0 +,,,134270,1223081,0,0,0 +,,,134271,16814,0,0,0 +,,,134370,17123,0,0,0 +,,,134371,408120,0,0,0 +,,,134372,1309631,0,0,0 +,,,134373,18562,0,0,0 +,,,134374,17074,0,0,0 +,,,134375,17111,0,0,0 +,,,134376,24968,0,0,0 +,,,134377,17104,0,0,0 +,,,134378,17118,0,0,0 +,,,134379,1328621,0,0,0 +,,,134380,16833,0,0,0 +,,,134381,17106,0,0,0 +,,,134382,17116,0,0,0 +,,,134383,17069,0,0,0 +,,,134384,16814,0,0,0 +,,,134385,1223081,0,0,0 +,,,134386,16845,0,0,0 +,,,134387,16918,0,0,0 +,,,134388,1223082,0,0,0 +,,,134389,1223083,0,0,0 +,,,134390,16819,0,0,0 +,,,134391,5570,0,0,0 +,,,134392,16821,0,0,0 +,,,134393,16909,0,0,0 +,,,134394,16850,0,0,0 +,,,134395,16880,0,0,0 +,,,134396,408248,0,0,0 +,,,134397,16896,0,0,0 +,,,134398,24858,0,0,0 +,,,134399,16934,0,0,0 +,,,134400,17056,0,0,0 +,,,134401,16947,0,0,0 +,,,134402,16940,0,0,0 +,,,134403,16929,0,0,0 +,,,134404,17002,0,0,0 +,,,134405,1238122,0,0,0 +,,,134406,16966,0,0,0 +,,,134407,16942,0,0,0 +,,,134408,16958,0,0,0 +,,,134409,16998,0,0,0 +,,,134410,1328617,0,0,0 +,,,134411,1223242,0,0,0 +,,,134412,1328613,0,0,0 +,,,134413,16972,0,0,0 +,,,134414,1223246,0,0,0 +,,,134415,417051,0,0,0 +,,,134416,17007,0,0,0 +,,,134417,407995,0,0,0 +,,,134418,17063,0,0,0 +,,,134419,17003,0,0,0 +,,,135238,14162,0,0,0 +,,,135239,399956,0,0,0 +,,,135240,14186,0,0,0 +,,,135241,14174,0,0,0 +,,,135242,1329328,0,0,0 +,,,135243,14113,0,0,0 +,,,135244,16513,0,0,0 +,,,135245,14177,0,0,0 +,,,135246,14128,0,0,0 +,,,135247,14168,0,0,0 +,,,135248,1329256,0,0,0 +,,,135249,1224716,0,0,0 +,,,135250,14983,0,0,0 +,,,135251,14156,0,0,0 +,,,135252,14138,0,0,0 +,,,135253,14144,0,0,0 +,,,135254,13750,0,0,0 +,,,135256,30919,0,0,0 +,,,135257,13960,0,0,0 +,,,135258,13877,0,0,0 +,,,135260,18427,0,0,0 +,,,135262,13743,0,0,0 +,,,135263,13754,0,0,0 +,,,135265,14251,0,0,0 +,,,135266,13742,0,0,0 +,,,135267,13705,0,0,0 +,,,135268,13713,0,0,0 +,,,135269,14165,0,0,0 +,,,135270,1329284,0,0,0 +,,,135271,13732,0,0,0 +,,,135272,13741,0,0,0 +,,,135273,14183,0,0,0 +,,,135275,14082,0,0,0 +,,,135276,14185,0,0,0 +,,,135277,30894,0,0,0 +,,,135278,16511,0,0,0 +,,,135279,14079,0,0,0 +,,,135280,1329286,0,0,0 +,,,135281,13983,0,0,0 +,,,135282,14171,0,0,0 +,,,135283,13981,0,0,0 +,,,135284,14278,0,0,0 +,,,135285,13976,0,0,0 +,,,135286,13975,0,0,0 +,,,135287,1224782,0,0,0 +,,,135289,1329265,0,0,0 +,,,135290,14057,0,0,0 +,,,135291,13958,0,0,0 +,,,138268,1310711,0,0,0 +,,,142590,17245,0,0,0 +,,,142618,1316709,0,0,0 +,,,142619,1310728,0,0,0 +,,,145370,13712,0,0,0 +,,,145859,1322605,0,0,0 +,,,145964,14179,0,0,0 +,,,145965,13715,0,0,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/TraitNode.csv b/crates/openlogs-gamedata/tests/fixtures/forever/TraitNode.csv new file mode 100644 index 0000000..e4292b1 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/TraitNode.csv @@ -0,0 +1,143 @@ +ID,TraitTreeID,PosX,PosY,Type,Flags,TraitSubTreeID +104775,1083,7500,600,0,8,0 +104776,1083,6900,600,0,8,0 +104777,1083,4500,4200,0,8,0 +104778,1083,5100,3000,0,8,0 +104779,1083,3900,3600,0,8,0 +104780,1083,3300,3600,0,8,0 +104781,1083,4500,3000,0,8,0 +104782,1083,3300,3000,0,8,0 +104783,1083,5100,2400,0,8,0 +104784,1083,4500,2400,0,8,0 +104785,1083,3900,2400,0,8,0 +104786,1083,3300,2400,0,8,0 +104787,1083,4500,1800,0,8,0 +104788,1083,3900,1800,0,8,0 +104789,1083,5100,1800,0,8,0 +104790,1083,5100,1200,0,8,0 +104791,1083,4500,1200,0,8,0 +104792,1083,3900,1200,0,8,0 +104793,1083,3300,1200,0,8,0 +104794,1083,4500,600,0,8,0 +104795,1083,3900,600,0,8,0 +104796,1083,900,4200,0,8,0 +104797,1083,900,3600,0,8,0 +104798,1083,1500,3000,0,8,0 +104799,1083,900,3000,0,8,0 +104800,1083,1500,2400,0,8,0 +104801,1083,900,2400,0,8,0 +104802,1083,300,2400,0,8,0 +104803,1083,2100,1800,0,8,0 +104804,1083,1500,1800,0,8,0 +104805,1083,300,1800,0,8,0 +104806,1083,1500,1200,0,8,0 +104807,1083,900,1200,0,8,0 +104808,1083,300,1200,0,8,0 +104809,1083,1500,600,0,8,0 +104810,1083,900,600,0,8,0 +104909,1089,10880,4530,0,0,0 +104910,1089,9680,5730,0,0,0 +104911,1089,9680,4530,0,0,0 +104912,1089,10880,3930,0,0,0 +104913,1089,10280,5130,0,0,0 +104914,1089,10280,3930,0,0,0 +104915,1089,9680,3930,0,0,0 +104916,1089,10280,3330,0,0,0 +104917,1089,9680,3330,0,0,0 +104918,1089,10880,3330,0,0,0 +104919,1089,10280,2730,0,0,0 +104920,1089,9680,2730,0,0,0 +104921,1089,9080,4530,0,0,0 +104922,1089,9080,2730,0,0,0 +104923,1089,1620,2130,0,0,0 +104924,1089,2220,2130,0,0,0 +104925,1089,1020,2730,0,0,0 +104926,1089,1020,3330,0,0,0 +104927,1089,2220,2730,0,0,0 +104928,1089,2220,3330,0,0,0 +104929,1089,2820,2730,0,0,0 +104930,1089,1020,3930,0,0,0 +104931,1089,1620,2730,0,0,0 +104932,1089,1620,3930,0,0,0 +104933,1089,2220,3930,0,0,0 +104934,1089,1620,4530,0,0,0 +104935,1089,2220,4530,0,0,0 +104936,1089,1620,5130,0,0,0 +104937,1089,1620,5730,0,0,0 +104938,1089,5620,2130,0,0,0 +104939,1089,6220,2130,0,0,0 +104940,1089,5620,2730,0,0,0 +104941,1089,6220,2730,0,0,0 +104942,1089,6820,2730,0,0,0 +104943,1089,5020,2730,0,0,0 +104944,1089,6220,3330,0,0,0 +104945,1089,5020,3330,0,0,0 +104946,1089,6820,3330,0,0,0 +104947,1089,6820,3930,0,0,0 +104948,1089,5620,3330,0,0,0 +104949,1089,5620,3930,0,0,0 +104950,1089,6820,4530,0,0,0 +104951,1089,6220,3930,0,0,0 +104952,1089,5020,3930,0,0,0 +104953,1089,5020,5130,0,0,0 +104954,1089,6820,5130,0,0,0 +104955,1089,5620,4530,0,0,0 +104956,1089,5620,5730,0,0,0 +104957,1089,9680,2130,0,0,0 +104958,1089,10280,2130,0,0,0 +105708,1111,5020,2130,0,0,0 +105709,1111,1620,5730,0,0,0 +105710,1111,2220,5130,0,0,0 +105711,1111,2220,4530,0,0,0 +105712,1111,1620,4530,0,0,0 +105713,1111,2220,3930,0,0,0 +105714,1111,1020,3930,0,0,0 +105715,1111,1620,3930,0,0,0 +105716,1111,2220,3330,0,0,0 +105717,1111,1620,2730,0,0,0 +105718,1111,1620,3330,0,0,0 +105719,1111,5020,2730,0,0,0 +105720,1111,1020,3330,0,0,0 +105721,1111,1020,2730,0,0,0 +105722,1111,2220,2130,0,0,0 +105723,1111,1620,2130,0,0,0 +105724,1111,5620,5730,0,0,0 +105726,1111,6220,3930,0,0,0 +105727,1111,6220,4530,0,0,0 +105728,1111,5620,4530,0,0,0 +105730,1111,6820,3930,0,0,0 +105732,1111,6820,2730,0,0,0 +105733,1111,5020,3930,0,0,0 +105735,1111,5620,3330,0,0,0 +105736,1111,5020,3330,0,0,0 +105737,1111,6220,2730,0,0,0 +105738,1111,5620,2730,0,0,0 +105739,1111,2820,2730,0,0,0 +105740,1111,6220,5130,0,0,0 +105741,1111,5620,2130,0,0,0 +105742,1111,1020,2130,0,0,0 +105743,1111,9680,3330,0,0,0 +105745,1111,9080,2730,0,0,0 +105746,1111,9680,4530,0,0,0 +105747,1111,9080,4530,0,0,0 +105748,1111,10280,4530,0,0,0 +105749,1111,10280,2730,0,0,0 +105750,1111,10280,5130,0,0,0 +105751,1111,9080,2130,0,0,0 +105752,1111,10280,3330,0,0,0 +105753,1111,9080,3930,0,0,0 +105754,1111,9680,3930,0,0,0 +105755,1111,9080,3330,0,0,0 +105756,1111,9680,2730,0,0,0 +105757,1111,10880,2730,0,0,0 +105759,1111,6820,3330,0,0,0 +105760,1111,10280,2130,0,0,0 +105761,1111,9680,2130,0,0,0 +108100,1111,5620,3930,0,0,0 +110844,1089,1020,4530,0,8,0 +110866,1111,9680,5730,0,0,0 +110867,1111,10880,3930,0,0,0 +113398,1111,6220,2130,0,0,0 +113563,1089,6220,5730,0,8,0 +113633,1111,1020,4530,0,8,0 +113635,1111,5020,4530,0,8,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/TraitNodeEntry.csv b/crates/openlogs-gamedata/tests/fixtures/forever/TraitNodeEntry.csv new file mode 100644 index 0000000..cfcae94 --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/TraitNodeEntry.csv @@ -0,0 +1,142 @@ +ID,TraitDefinitionID,MaxRanks,NodeEntryType,TraitSubTreeID +129435,134236,5,1,0 +129436,134237,5,1,0 +129437,134238,1,1,0 +129438,134239,5,1,0 +129439,134240,5,1,0 +129440,134241,5,1,0 +129441,134242,1,1,0 +129442,134243,2,1,0 +129443,134244,1,1,0 +129444,134245,2,1,0 +129445,134246,3,1,0 +129446,134247,2,1,0 +129447,134248,3,1,0 +129448,134249,1,1,0 +129449,134250,2,1,0 +129450,134251,2,1,0 +129451,134252,5,1,0 +129452,134253,2,1,0 +129453,134254,3,1,0 +129454,134255,5,1,0 +129455,134256,5,1,0 +129456,134257,1,1,0 +129457,134258,5,1,0 +129458,134259,3,1,0 +129459,134260,1,1,0 +129460,134261,3,1,0 +129461,134262,5,1,0 +129462,134263,1,1,0 +129463,134264,2,1,0 +129464,134265,1,1,0 +129465,134266,3,1,0 +129467,134268,2,1,0 +129468,134269,3,1,0 +129469,134270,5,1,0 +129470,134271,5,1,0 +129569,134370,2,1,0 +129570,134371,1,1,0 +129571,134372,3,1,0 +129572,134373,1,1,0 +129573,134374,5,1,0 +129574,134375,3,1,0 +129575,134376,5,1,0 +129576,134377,5,1,0 +129577,134378,3,1,0 +129578,134379,1,1,0 +129579,134380,3,1,0 +129580,134381,3,1,0 +129581,134382,1,1,0 +129582,134383,5,1,0 +129583,134384,5,1,0 +129584,134385,5,1,0 +129585,134386,3,1,0 +129586,134387,3,1,0 +129587,134388,2,1,0 +129588,134389,1,1,0 +129589,134390,2,1,0 +129590,134391,1,1,0 +129591,134392,2,1,0 +129592,134393,5,1,0 +129593,134394,5,1,0 +129594,134395,1,1,0 +129595,134396,3,1,0 +129596,134397,5,1,0 +129597,134398,1,1,0 +129598,134399,5,1,0 +129599,134400,5,1,0 +129600,134401,3,1,0 +129601,134402,2,1,0 +129602,134403,3,1,0 +129603,134404,2,1,0 +129604,134405,1,1,0 +129605,134406,3,1,0 +129606,134407,2,1,0 +129607,134408,2,1,0 +129608,134409,2,1,0 +129609,134410,1,1,0 +129610,134411,2,1,0 +129611,134412,1,1,0 +129612,134413,3,1,0 +129613,134414,5,1,0 +129614,134415,5,1,0 +129615,134416,1,1,0 +129616,134417,1,1,0 +129617,134418,5,1,0 +129618,134419,5,1,0 +130437,135238,3,1,0 +130438,135239,1,1,0 +130439,135240,3,1,0 +130440,135241,2,1,0 +130441,135242,1,1,0 +130442,135243,5,1,0 +130443,135244,5,1,0 +130444,135245,1,1,0 +130445,135246,2,1,0 +130446,135247,2,1,0 +130447,135248,1,1,0 +130448,135249,3,1,0 +130449,135250,2,1,0 +130450,135251,3,1,0 +130451,135252,5,1,0 +130452,135253,2,1,0 +130453,135254,1,1,0 +130455,135256,2,1,0 +130456,135257,5,1,0 +130457,135258,1,1,0 +130459,135260,3,1,0 +130461,135262,2,1,0 +130462,135263,2,1,0 +130464,135265,1,1,0 +130465,135266,2,1,0 +130466,135267,3,1,0 +130467,135268,3,1,0 +130468,135269,3,1,0 +130469,135270,5,1,0 +130470,135271,2,1,0 +130471,135272,3,1,0 +130472,135273,1,1,0 +130474,135275,2,1,0 +130475,135276,1,1,0 +130476,135277,2,1,0 +130477,135278,1,1,0 +130478,135279,3,1,0 +130479,135280,5,1,0 +130480,135281,3,1,0 +130481,135282,3,1,0 +130482,135283,2,1,0 +130483,135284,1,1,0 +130484,135285,3,1,0 +130485,135286,3,1,0 +130486,135287,2,1,0 +130488,135289,2,1,0 +130489,135290,5,1,0 +130490,135291,3,1,0 +133482,138268,1,1,0 +137836,142590,2,1,0 +137864,142618,1,1,0 +137865,142619,2,1,0 +140697,145370,5,1,0 +141188,145859,1,1,0 +141295,145964,5,1,0 +141297,145965,2,1,0 diff --git a/crates/openlogs-gamedata/tests/fixtures/forever/TraitNodeXTraitNodeEntry.csv b/crates/openlogs-gamedata/tests/fixtures/forever/TraitNodeXTraitNodeEntry.csv new file mode 100644 index 0000000..9117b1a --- /dev/null +++ b/crates/openlogs-gamedata/tests/fixtures/forever/TraitNodeXTraitNodeEntry.csv @@ -0,0 +1,142 @@ +ID,TraitNodeID,TraitNodeEntryID,_Index +126902,104775,129435,100 +126903,104776,129436,100 +126904,104777,129437,100 +126905,104778,129438,100 +126906,104779,129439,100 +126907,104780,129440,100 +126908,104781,129441,100 +126909,104782,129442,100 +126910,104783,129443,100 +126911,104784,129444,100 +126912,104785,129445,100 +126913,104786,129446,100 +126914,104787,129447,100 +126915,104788,129448,100 +126916,104789,129449,100 +126917,104790,129450,100 +126918,104791,129451,100 +126919,104792,129452,100 +126920,104793,129453,100 +126921,104794,129454,100 +126922,104795,129455,100 +126923,104796,129456,100 +126924,104797,129457,100 +126925,104798,129458,100 +126926,104799,129459,100 +126927,104800,129460,100 +126928,104801,129461,100 +126929,104802,129462,100 +126930,104803,129463,100 +126931,104804,129464,100 +126932,104805,129465,100 +126934,104807,129467,100 +126935,104808,129468,100 +126936,104809,129469,100 +126937,104810,129470,100 +127036,104909,129569,100 +127037,104910,129570,100 +127038,104911,129571,100 +127039,104912,129572,100 +127040,104913,129573,100 +127041,104914,129574,100 +127042,104915,129575,100 +127043,104916,129576,100 +127044,104917,129577,100 +127045,104918,129578,100 +127046,104919,129579,100 +127047,104920,129580,100 +127048,104921,129581,100 +127049,104922,129582,100 +127050,104923,129583,100 +127051,104924,129584,100 +127052,104925,129585,100 +127053,104926,129586,100 +127054,104927,129587,100 +127055,104928,129588,100 +127056,104929,129589,100 +127057,104930,129590,100 +127058,104931,129591,100 +127059,104932,129592,100 +127060,104933,129593,100 +127061,104934,129594,100 +127062,104935,129595,100 +127063,104936,129596,100 +127064,104937,129597,100 +127065,104938,129598,100 +127066,104939,129599,100 +127067,104940,129600,100 +127068,104941,129601,100 +127069,104942,129602,100 +127070,104943,129603,100 +127071,104944,129604,100 +127072,104945,129605,100 +127073,104946,129606,100 +127074,104947,129607,100 +127075,104948,129608,100 +127076,104949,129609,100 +127077,104950,129610,100 +127078,104951,129611,100 +127079,104952,129612,100 +127080,104953,129613,100 +127081,104954,129614,100 +127082,104955,129615,100 +127083,104956,129616,100 +127084,104957,129617,100 +127085,104958,129618,100 +127904,105708,130437,100 +127905,105709,130438,100 +127906,105710,130439,100 +127907,105711,130440,100 +127908,105712,130441,100 +127909,105713,130442,100 +127910,105714,130443,100 +127911,105715,130444,100 +127912,105716,130445,100 +127913,105717,130446,100 +127914,105718,130447,100 +127915,105719,130448,100 +127916,105720,130449,100 +127917,105721,130450,100 +127918,105722,130451,100 +127919,105723,130452,100 +127920,105724,130453,100 +127922,105726,130455,100 +127923,105727,130456,100 +127924,105728,130457,100 +127926,105730,130459,100 +127928,105732,130461,100 +127929,105733,130462,100 +127931,105735,130464,100 +127932,105736,130465,100 +127933,105737,130466,100 +127934,105738,130467,100 +127935,105739,130468,100 +127936,105740,130469,100 +127937,105741,130470,100 +127938,105742,130471,100 +127939,105743,130472,100 +127941,105745,130474,100 +127942,105746,130475,100 +127943,105747,130476,100 +127944,105748,130477,100 +127945,105749,130478,100 +127946,105750,130479,100 +127947,105751,130480,100 +127948,105752,130481,100 +127949,105753,130482,100 +127950,105754,130483,100 +127951,105755,130484,100 +127952,105756,130485,100 +127953,105757,130486,100 +127955,105759,130488,100 +127956,105760,130489,100 +127957,105761,130490,100 +130951,108100,133482,100 +136275,110844,137836,100 +136302,110866,137864,100 +136303,110867,137865,100 +139139,113398,140697,100 +139870,113563,141188,100 +139981,113633,141295,100 +139983,113635,141297,100 diff --git a/crates/openlogs-gamedata/tests/online.rs b/crates/openlogs-gamedata/tests/online.rs index 98a2fda..5fb0bd0 100644 --- a/crates/openlogs-gamedata/tests/online.rs +++ b/crates/openlogs-gamedata/tests/online.rs @@ -73,6 +73,38 @@ fn wago_tools_provides_the_forever_tables() { tables.spells.icons.icon(5487).is_some(), "Bear Form has an icon" ); + assert_eq!(tables.talent_trees.len(), 27, "every class has three trees"); + let rogue = [ + (105722, 5), + (105708, 3), + (105715, 1), + (105716, 2), + (105720, 2), + (105721, 3), + (105724, 1), + (105726, 2), + (105727, 5), + (105728, 1), + (105730, 3), + (105732, 2), + (105736, 2), + (105737, 3), + (105738, 1), + (105739, 3), + (105740, 5), + (105741, 2), + (105759, 2), + (108100, 1), + (113635, 2), + ]; + assert_eq!( + tables + .talent_trees + .spec_of(rogue) + .map(|tree| tree.name.as_str()), + Some("Combat") + ); + assert_eq!(tables.talent_trees.class_of_spec(1484), Some(11)); assert!( tables.classes.class_spell_count() > 1_000, "got {} class spells", diff --git a/crates/openlogs-gamedata/tests/talent_trees.rs b/crates/openlogs-gamedata/tests/talent_trees.rs new file mode 100644 index 0000000..02ca5f5 --- /dev/null +++ b/crates/openlogs-gamedata/tests/talent_trees.rs @@ -0,0 +1,156 @@ +//! Forever talent trees from trimmed real exports of the rogue and druid trees. + +use openlogs_gamedata::{Role, TalentTreeCsvs, TalentTrees, TalentTreesError, TreeRole, tree_role}; + +const ASSASSINATION: u32 = 182; +const COMBAT: u32 = 181; +const SUBTLETY: u32 = 183; + +/// Left, middle and right column of the rogue tree. +const ASSASSINATION_NODE: u32 = 105722; +const COMBAT_NODE: u32 = 105724; +const SUBTLETY_NODE: u32 = 105743; +/// A classic Assassination talent that Forever placed in the middle column. +const MOVED_TO_COMBAT: u32 = 105708; +/// A Forever talent without a classic one, in the middle column. +const NEW_IN_COMBAT: u32 = 105719; +/// The druid tree's middle column. +const FERAL_NODE: u32 = 104938; +const FERAL_COMBAT: u32 = 281; +/// A node of a tree no class uses. +const UNUSED_TREE_NODE: u32 = 104775; + +fn trees() -> TalentTrees { + TalentTrees::from_csv(&TalentTreeCsvs { + trait_node: include_bytes!("fixtures/forever/TraitNode.csv"), + node_x_entry: include_bytes!("fixtures/forever/TraitNodeXTraitNodeEntry.csv"), + node_entry: include_bytes!("fixtures/forever/TraitNodeEntry.csv"), + definition: include_bytes!("fixtures/forever/TraitDefinition.csv"), + talent: include_bytes!("fixtures/forever/Talent.csv"), + talent_tab: include_bytes!("fixtures/forever/TalentTab.csv"), + skill_line_x_trait_tree: include_bytes!("fixtures/forever/SkillLineXTraitTree.csv"), + chr_specialization: include_bytes!("fixtures/forever/ChrSpecialization.csv"), + manifest: include_bytes!("fixtures/forever/ManifestInterfaceData.csv"), + }) + .unwrap() +} + +fn tree_of(trees: &TalentTrees, node: u32) -> Option { + trees.spec_of([(node, 1)]).map(|tree| tree.id) +} + +#[test] +fn a_column_is_the_classic_tree_most_of_its_nodes_belong_to() { + let trees = trees(); + assert_eq!(tree_of(&trees, ASSASSINATION_NODE), Some(ASSASSINATION)); + assert_eq!(tree_of(&trees, COMBAT_NODE), Some(COMBAT)); + assert_eq!(tree_of(&trees, SUBTLETY_NODE), Some(SUBTLETY)); + assert_eq!(tree_of(&trees, MOVED_TO_COMBAT), Some(COMBAT)); + assert_eq!(tree_of(&trees, NEW_IN_COMBAT), Some(COMBAT)); + assert_eq!(tree_of(&trees, FERAL_NODE), Some(FERAL_COMBAT)); +} + +#[test] +fn only_class_trees_count() { + assert_eq!(tree_of(&trees(), UNUSED_TREE_NODE), None); +} + +#[test] +fn the_tree_with_most_points_is_the_spec() { + let trees = trees(); + let spec = trees + .spec_of([(COMBAT_NODE, 35), (ASSASSINATION_NODE, 16)]) + .unwrap(); + assert_eq!( + ( + spec.id, + spec.class_id, + spec.name.as_str(), + spec.icon.as_str() + ), + (COMBAT, 4, "Combat", "ability_backstab") + ); +} + +#[test] +fn a_tie_gives_no_spec() { + assert!( + trees() + .spec_of([(COMBAT_NODE, 25), (ASSASSINATION_NODE, 25)]) + .is_none() + ); +} + +#[test] +fn a_forever_spec_id_gives_its_class() { + let trees = trees(); + assert_eq!(trees.class_of_spec(1488), Some(4)); + assert_eq!(trees.class_of_spec(1484), Some(11)); + assert_eq!( + trees.class_of_spec(1493), + None, + "the default spec has no class" + ); +} + +#[test] +fn the_table_survives_json() { + let trees = TalentTrees::from_json(&trees().to_json()).unwrap(); + assert_eq!(trees.len(), 27); + assert_eq!(tree_of(&trees, MOVED_TO_COMBAT), Some(COMBAT)); + assert_eq!(trees.tree(COMBAT).unwrap().icon, "ability_backstab"); + assert_eq!(trees.class_of_spec(1488), Some(4)); +} + +#[test] +fn roles_follow_our_table() { + assert_eq!(tree_role(163), TreeRole::Fixed(Role::Tank)); + assert_eq!(tree_role(282), TreeRole::Fixed(Role::Healer)); + assert_eq!(tree_role(281), TreeRole::BearForm); + assert_eq!(tree_role(COMBAT), TreeRole::Fixed(Role::Damage)); +} + +#[test] +fn a_class_tree_without_three_named_columns_is_an_error() { + let err = TalentTrees::from_csv(&TalentTreeCsvs { + trait_node: b"ID,TraitTreeID,PosX +1,1111,1000 +2,1111,5000 +3,1111,9000 +", + node_x_entry: b"TraitNodeID,TraitNodeEntryID +1,1 +2,2 +3,3 +", + node_entry: b"ID,TraitDefinitionID +1,1 +2,2 +3,3 +", + definition: b"ID,SpellID +1,101 +2,102 +3,999 +", + talent: b"TabID,SpellRank_0 +182,101 +181,102 +", + talent_tab: include_bytes!("fixtures/forever/TalentTab.csv"), + skill_line_x_trait_tree: b"SkillLineID,TraitTreeID +38,1111 +", + chr_specialization: b"ID,ClassID +1488,4 +", + manifest: include_bytes!("fixtures/forever/ManifestInterfaceData.csv"), + }) + .err() + .unwrap(); + + assert!( + matches!(err, TalentTreesError::UnresolvedTree(1111)), + "got {err}" + ); +} diff --git a/crates/openlogs-index/src/builder.rs b/crates/openlogs-index/src/builder.rs index bc51fb1..08221fc 100644 --- a/crates/openlogs-index/src/builder.rs +++ b/crates/openlogs-index/src/builder.rs @@ -1,11 +1,11 @@ use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use openlogs_parser::{ - ChallengeModeEnd, ChallengeModeStart, CombatEvent, CombatKind, CombatantInfo, EncounterEnd, - EncounterStart, Event, LogLine, Timestamp, + ChallengeModeEnd, ChallengeModeStart, CombatEvent, CombatKind, EncounterEnd, EncounterStart, + Event, LogLine, Timestamp, }; -use crate::combat::{DeadEnemies, Exchange, OpenCombat, counted_damage, exchange}; +use crate::combat::{DeadEnemies, Exchange, KnownSpec, OpenCombat, counted_damage, exchange}; use crate::markers::MarkerState; use crate::model::{ BOSS_TAIL_MICROS, ChallengeMode, DUNGEON_DIFFICULTIES, END_GRACE_LINES, END_GRACE_MICROS, @@ -52,7 +52,7 @@ pub struct IndexBuilder { zone_instance_id: u32, zone_difficulty: u32, /// Spec of each player's latest `COMBATANT_INFO`, by GUID. - last_specs: HashMap, + last_specs: HashMap, markers: MarkerState, /// Latest bounds per `MAP_CHANGE` map ID; facts about the map, so never reset. map_bounds: BTreeMap, @@ -175,13 +175,21 @@ impl IndexBuilder { Event::ChallengeModeStart(_) => {} Event::ChallengeModeEnd(end) => self.end_run(end), Event::CombatantInfo(info) => { - self.last_specs.insert(info.guid.to_string(), info.spec_id); + let known = KnownSpec { + spec_id: info.spec_id, + talents: if self.index.flavor == Some(GameFlavor::Forever) { + info.talents().collect() + } else { + Vec::new() + }, + }; if let Some(fight) = &mut self.open { - add_combatant(&mut fight.summary.roster, info); + add_combatant(&mut fight.summary.roster, info.guid, &known); } if let Some(run) = &mut self.run { - add_combatant(&mut run.summary.roster, info); + add_combatant(&mut run.summary.roster, info.guid, &known); } + self.last_specs.insert(info.guid.to_string(), known); } Event::Combat(event) => { if let Some(run) = &mut self.run { @@ -892,12 +900,13 @@ fn extend(summary: &mut FightSummary, span: LineSpan, timestamp: Timestamp) { summary.end_offset = span.next_offset; } -fn add_combatant(roster: &mut Vec, info: &CombatantInfo<'_>) { - if roster.iter().all(|entry| entry.guid != info.guid) { +fn add_combatant(roster: &mut Vec, guid: &str, known: &KnownSpec) { + if roster.iter().all(|entry| entry.guid != guid) { roster.push(RosterEntry { - guid: info.guid.to_string(), + guid: guid.to_string(), name: None, - spec_id: info.spec_id, + spec_id: known.spec_id, + talents: known.talents.clone(), }); } } diff --git a/crates/openlogs-index/src/combat.rs b/crates/openlogs-index/src/combat.rs index 6616a1f..3342d9c 100644 --- a/crates/openlogs-index/src/combat.rs +++ b/crates/openlogs-index/src/combat.rs @@ -7,6 +7,13 @@ use crate::model::{ COMBAT_QUIET_MICROS, CombatPull, DEAD_ENEMY_MEMORY_MICROS, FightSummary, Outcome, RosterEntry, }; +/// A player's spec and talents from their latest `COMBATANT_INFO`. +#[derive(Debug, Clone, Default)] +pub(crate) struct KnownSpec { + pub(crate) spec_id: u32, + pub(crate) talents: Vec<(u32, u32)>, +} + /// A combat pull still going on. #[derive(Clone)] pub(crate) struct OpenCombat { @@ -147,7 +154,11 @@ impl OpenCombat { } /// An `Ended` pull ends at its last exchange, any other at its latest line. - pub(crate) fn finish(mut self, outcome: Outcome, specs: &HashMap) -> FightSummary { + pub(crate) fn finish( + mut self, + outcome: Outcome, + specs: &HashMap, + ) -> FightSummary { let summary = &mut self.summary; summary.outcome = outcome; if outcome == Outcome::Ended { @@ -173,7 +184,10 @@ impl OpenCombat { self.players.len() } as u32; for entry in &mut summary.roster { - entry.spec_id = specs.get(&entry.guid).copied().unwrap_or(0); + if let Some(known) = specs.get(&entry.guid) { + entry.spec_id = known.spec_id; + entry.talents.clone_from(&known.talents); + } } self.summary } @@ -185,6 +199,7 @@ impl OpenCombat { guid: player.guid.to_string(), name: player.name.map(str::to_string), spec_id: 0, + talents: Vec::new(), }); } } diff --git a/crates/openlogs-index/src/model.rs b/crates/openlogs-index/src/model.rs index da15118..3788577 100644 --- a/crates/openlogs-index/src/model.rs +++ b/crates/openlogs-index/src/model.rs @@ -4,7 +4,7 @@ use openlogs_parser::Timestamp; use serde::{Deserialize, Serialize}; /// Bumped whenever the index layout or its rules change; invalidates cached indexes. -pub const INDEX_FORMAT_VERSION: u32 = 16; +pub const INDEX_FORMAT_VERSION: u32 = 17; /// The combat log format this tool is built and tested against. pub const SUPPORTED_LOG_VERSION: u32 = 22; /// Lookback before `ENCOUNTER_START` that belongs to a fight (pre-pots, pre-casts). @@ -274,6 +274,9 @@ pub struct RosterEntry { /// `None` if the player never appeared in a combat event during the fight. pub name: Option, pub spec_id: u32, + /// `(node, rank)` of each talent; kept for Forever only, whose spec comes from them. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub talents: Vec<(u32, u32)>, } /// Display name of a difficulty ID; `None` for unknown IDs, which are shown raw. diff --git a/crates/openlogs-index/tests/combat_pulls.rs b/crates/openlogs-index/tests/combat_pulls.rs index fcf7105..a67f302 100644 --- a/crates/openlogs-index/tests/combat_pulls.rs +++ b/crates/openlogs-index/tests/combat_pulls.rs @@ -429,6 +429,66 @@ fn combat_pulls_take_the_last_known_spec() { ); } +/// A boss pull with Faelan's combatant info, then a trash pull, logged by `project_id`. +fn boss_then_trash(project_id: u32) -> String { + [ + &format!("10/7/2026 19:03:00.0000 COMBAT_LOG_VERSION,22,ADVANCED_LOG_ENABLED,1,BUILD_VERSION,1.60.1,PROJECT_ID,{project_id} +"), + "10/7/2026 19:03:02.0762 ENCOUNTER_START,3492,\"Ula'tek\",15,23,3004 +", + "10/7/2026 19:03:02.0762 COMBATANT_INFO,Player-4101-8E8C0182,1,100,200,300,400,0,0,0,0,10,10,10,0,92,1025,1025,1025,230,807,110,110,110,2726,1488,[(105722,130451,5),(105724,130453,3)],(0,0,0,0),[(249976,330,(),(7364,0),())],[],57,0,0,0 +", + &hit("10/7/2026 19:03:03.0000", &FAELAN, &KNIGHT, 100), + "10/7/2026 19:04:02.0762 ENCOUNTER_END,3492,\"Ula'tek\",15,23,0,60000 +", + &hit("10/7/2026 19:05:00.0000", &FAELAN, &KNIGHT, 100), + &hit("10/7/2026 19:05:01.0000", &KNIGHT, &PYRRIN, 100), + ] + .concat() +} + +/// Each player's `(node, rank)` talents, by GUID. +type RosterTalents<'a> = Vec<(&'a str, Vec<(u32, u32)>)>; + +fn talents_of_pulls(index: &openlogs_index::LogIndex) -> Vec> { + index + .fights + .iter() + .map(|fight| { + fight + .roster + .iter() + .map(|entry| (entry.guid.as_str(), entry.talents.clone())) + .collect() + }) + .collect() +} + +#[test] +fn a_forever_combat_pull_keeps_the_last_logged_talents() { + let index = index_bytes(boss_then_trash(18).as_bytes()); + let faelan = vec![(105722, 5), (105724, 3)]; + assert_eq!( + talents_of_pulls(&index), + [ + vec![(FAELAN.guid, faelan.clone())], + vec![(FAELAN.guid, faelan), (PYRRIN.guid, vec![])], + ] + ); +} + +#[test] +fn a_retail_index_keeps_no_talents() { + let index = index_bytes(boss_then_trash(1).as_bytes()); + assert!( + index + .fights + .iter() + .flat_map(|fight| &fight.roster) + .all(|entry| entry.talents.is_empty()) + ); +} + #[test] fn boss_pulls_are_unchanged() { let index = index_bytes(MINI_RAID.as_bytes()); diff --git a/crates/openlogs-index/tests/index_mini.rs b/crates/openlogs-index/tests/index_mini.rs index f904174..b8a5360 100644 --- a/crates/openlogs-index/tests/index_mini.rs +++ b/crates/openlogs-index/tests/index_mini.rs @@ -66,12 +66,14 @@ fn wipe_with_roster_boss_hp_and_prelude() { RosterEntry { guid: "Player-4101-8E8C0182".into(), name: Some("Faelan-Emberfall-EU".into()), - spec_id: 62 + spec_id: 62, + talents: Vec::new(), }, RosterEntry { guid: "Player-4101-77D4A765".into(), name: Some("Pyrrin-Emberfall-EU".into()), - spec_id: 105 + spec_id: 105, + talents: Vec::new(), }, ] ); diff --git a/crates/openlogs-index/tests/index_runs.rs b/crates/openlogs-index/tests/index_runs.rs index a84c23a..63009cb 100644 --- a/crates/openlogs-index/tests/index_runs.rs +++ b/crates/openlogs-index/tests/index_runs.rs @@ -120,12 +120,14 @@ fn a_run_is_indexed_with_its_key_its_roster_and_its_prelude() { RosterEntry { guid: "Player-4101-8E8C0182".into(), name: Some("Faelan-Emberfall-EU".into()), - spec_id: 62 + spec_id: 62, + talents: Vec::new(), }, RosterEntry { guid: "Player-4101-77D4A765".into(), name: Some("Pyrrin-Emberfall-EU".into()), - spec_id: 105 + spec_id: 105, + talents: Vec::new(), }, ] ); diff --git a/crates/openlogs-parser/src/event.rs b/crates/openlogs-parser/src/event.rs index 402048a..c3f47df 100644 --- a/crates/openlogs-parser/src/event.rs +++ b/crates/openlogs-parser/src/event.rs @@ -109,13 +109,26 @@ pub struct ChallengeModeEnd { pub total_time_ms: u64, } -/// Player snapshot written right after `ENCOUNTER_START`. Talents and gear are not -/// modelled yet. +/// Player snapshot written right after `ENCOUNTER_START`. Gear is not modelled yet. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct CombatantInfo<'a> { pub guid: &'a str, pub faction: u32, pub spec_id: u32, + /// As logged, `[(node,entry,rank),…]`; empty when the line has none. + pub talents: &'a str, +} + +impl<'a> CombatantInfo<'a> { + /// `(node, rank)` of each talent. + pub fn talents(&self) -> impl Iterator + 'a { + self.talents.split(')').filter_map(|tuple| { + let mut parts = tuple.trim_start_matches(['[', ',', '(']).split(','); + let node = parts.next()?.parse().ok()?; + let rank = parts.nth(1)?.parse().ok()?; + Some((node, rank)) + }) + } } /// `COMBATLOG_OBJECT_*` bits of a unit's flags. diff --git a/crates/openlogs-parser/src/parse.rs b/crates/openlogs-parser/src/parse.rs index 78915a1..207fd2c 100644 --- a/crates/openlogs-parser/src/parse.rs +++ b/crates/openlogs-parser/src/parse.rs @@ -91,6 +91,7 @@ fn parse_event<'a>(f: &Fields<'_, 'a>) -> Result, ParseError> { guid: f.str(1)?, faction: f.num(2)?, spec_id: f.num(25)?, + talents: f.str(26).unwrap_or(""), }), name => match parse_combat(f)? { Some(event) => Event::Combat(event), diff --git a/crates/openlogs-parser/tests/events_meta.rs b/crates/openlogs-parser/tests/events_meta.rs index ad5397d..c5c64d0 100644 --- a/crates/openlogs-parser/tests/events_meta.rs +++ b/crates/openlogs-parser/tests/events_meta.rs @@ -118,19 +118,36 @@ fn parses_log_encounter_and_key_events() { } } +fn combatant_info(line: &str) -> CombatantInfo<'_> { + match event(line) { + Event::CombatantInfo(info) => info, + other => panic!("not combatant info: {other:?}"), + } +} + #[test] fn combatant_info_from_a_real_log() { - let text = include_str!("fixtures/combatant_info.txt").trim_end(); + let info = combatant_info(include_str!("fixtures/combatant_info.txt").trim_end()); assert_eq!( - event(text), - Event::CombatantInfo(CombatantInfo { - guid: "Player-4101-0EE857C6", - faction: 1, - spec_id: 71, - }) + (info.guid, info.faction, info.spec_id), + ("Player-4101-0EE857C6", 1, 71) ); } +#[test] +fn combatant_info_reads_the_talents() { + let line = include_str!("fixtures/combatant_info_forever.txt").trim_end(); + let talents: Vec<(u32, u32)> = combatant_info(line).talents().collect(); + assert_eq!(talents.len(), 21); + assert_eq!(talents[..2], [(105722, 5), (105708, 3)]); + assert_eq!(talents.iter().map(|&(_, rank)| rank).sum::(), 51); + + let without_talents = &line[..line.find(",[").unwrap()]; + let info = combatant_info(without_talents); + assert_eq!(info.spec_id, 1488); + assert_eq!(info.talents().count(), 0); +} + #[test] fn affix_ids_of_a_key_start() { for (line, affixes) in [ diff --git a/crates/openlogs-parser/tests/fixtures/combatant_info_forever.txt b/crates/openlogs-parser/tests/fixtures/combatant_info_forever.txt new file mode 100644 index 0000000..8fcf451 --- /dev/null +++ b/crates/openlogs-parser/tests/fixtures/combatant_info_forever.txt @@ -0,0 +1 @@ +11/18/2026 20:31:52.3481 COMBATANT_INFO,Player-6949-00A1B2C3,0,118,217,173,35,63,0,0,0,56,56,56,0,0,0,0,0,0,0,0,0,0,1372,1488,[(105722,130451,5),(105708,130437,3),(105715,130444,1),(105716,130445,2),(105720,130449,2),(105721,130450,3),(105724,130453,1),(105726,130455,2),(105727,130456,5),(105728,130457,1),(105730,130459,3),(105732,130461,2),(105736,130465,2),(105737,130466,3),(105738,130467,1),(105739,130468,3),(105740,130469,5),(105741,130470,2),(105759,130488,2),(108100,133482,1),(113635,141297,2)],(0,0,0,0) diff --git a/crates/openlogs-service/src/overview_dto.rs b/crates/openlogs-service/src/overview_dto.rs index f5ad828..796ac5f 100644 --- a/crates/openlogs-service/src/overview_dto.rs +++ b/crates/openlogs-service/src/overview_dto.rs @@ -110,6 +110,8 @@ pub struct PlayerRef { pub spec_id: Option, /// E.g. "Arcane Mage"; `None` without a known spec. pub spec_name: Option, + /// Icon name of the spec; `None` without a known spec. + pub spec_icon: Option, pub class_id: Option, pub class_token: Option, pub role: Option, @@ -568,13 +570,14 @@ pub fn quick_overview_dto( /// Name, class, spec and role of an actor for the UI. pub fn player_ref(fight: &Fight, id: ActorId) -> PlayerRef { let actor = fight.actors.get(id); - let spec = actor.spec_id.and_then(openlogs_gamedata::spec); + let spec = actor.shown_spec(); let class = actor.class().and_then(openlogs_gamedata::class); PlayerRef { actor_id: id, name: actor.name.clone().unwrap_or_else(|| actor.guid.clone()), spec_id: actor.spec_id, spec_name: crate::player_dto::spec_name(fight, id), + spec_icon: spec.map(|s| s.icon.to_string()), class_id: class.map(|c| c.id), class_token: class.map(|c| c.token.clone()), role: spec.map(|s| s.role), @@ -606,6 +609,29 @@ mod tests { } } + #[test] + fn a_retail_player_ref_keeps_its_spec() { + let mut actors = Actors::new(); + let mage = unit(&mut actors, "Player-1", "Faelan-Emberfall-EU", PLAYER_FLAGS); + actors.set_spec(mage, 62); + let player = player_ref(&fight(actors, Vec::new()), mage); + let arcane = openlogs_gamedata::spec(62).unwrap(); + assert_eq!( + ( + player.spec_name.as_deref(), + player.spec_icon.as_deref(), + player.role, + player.class_id + ), + ( + Some("Arcane Mage"), + Some(arcane.icon.as_str()), + Some(Role::Damage), + Some(8) + ) + ); + } + #[test] fn death_context_names_each_spell_from_the_log_or_the_curated_lists() { let mut actors = Actors::new(); diff --git a/crates/openlogs-service/src/player_dto.rs b/crates/openlogs-service/src/player_dto.rs index 698df45..b4d3e81 100644 --- a/crates/openlogs-service/src/player_dto.rs +++ b/crates/openlogs-service/src/player_dto.rs @@ -248,8 +248,9 @@ pub struct PlayerDetailDto { } pub(crate) fn spec_name(fight: &Fight, player: ActorId) -> Option { - let spec = openlogs_gamedata::spec(fight.actors.get(player).spec_id?)?; - let class = openlogs_gamedata::class(spec.class_id)?; + let actor = fight.actors.get(player); + let spec = actor.shown_spec()?; + let class = openlogs_gamedata::class(actor.class()?)?; Some(format!("{} {}", spec.name, class.name)) } diff --git a/crates/openlogs-service/src/replay_dto.rs b/crates/openlogs-service/src/replay_dto.rs index 425da8e..e688e91 100644 --- a/crates/openlogs-service/src/replay_dto.rs +++ b/crates/openlogs-service/src/replay_dto.rs @@ -70,6 +70,7 @@ pub struct ReplayUnitDto { pub name: String, pub kind: UnitKindDto, pub spec_id: Option, + pub spec_icon: Option, pub class_id: Option, pub owner: Option, pub add_number: Option, @@ -350,6 +351,7 @@ fn unit_dto(unit: &ReplayUnit) -> ReplayUnitDto { UnitKind::Add => UnitKindDto::Add, }, spec_id: unit.spec_id, + spec_icon: unit.spec_icon.clone(), class_id: unit.class_id, owner: unit.owner, add_number: unit.add_number, diff --git a/crates/openlogs-service/src/set_merge.rs b/crates/openlogs-service/src/set_merge.rs index 7fd56ff..35dd01e 100644 --- a/crates/openlogs-service/src/set_merge.rs +++ b/crates/openlogs-service/src/set_merge.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, HashMap}; use std::mem::take; use openlogs_analysis::{ - ActorId, COLOR_GROUPS, SpellId, TOP_ABILITIES_PER_GROUP, largest_first, per_second, spec_class, + ActorId, COLOR_GROUPS, SpellId, TOP_ABILITIES_PER_GROUP, largest_first, per_second, }; use serde::Serialize; @@ -399,12 +399,7 @@ fn merge_rows( /// Keeps the later pull's entry unless only an earlier one knows the spec, or without a known /// spec the class. fn merge_roster(roster: &mut Vec, next: Vec) { - let knowledge = |player: &PlayerRef| { - ( - spec_class(player.spec_id).is_some(), - player.class_id.is_some(), - ) - }; + let knowledge = |player: &PlayerRef| (player.spec_name.is_some(), player.class_id.is_some()); for player in next { match roster .iter_mut() @@ -1418,6 +1413,7 @@ mod tests { name: "Ravel-Ashwood-EU".into(), spec_id: None, spec_name: None, + spec_icon: None, class_id, class_token: class_id.map(|_| "ROGUE".into()), role: None, diff --git a/crates/openlogs-service/src/test_fight.rs b/crates/openlogs-service/src/test_fight.rs index 52617de..a95bebc 100644 --- a/crates/openlogs-service/src/test_fight.rs +++ b/crates/openlogs-service/src/test_fight.rs @@ -1,6 +1,6 @@ //! Hand-built fights for DTO unit tests. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use openlogs_analysis::{ ActorId, Actors, Damage, DamageVia, Event, EventKind, Fight, FightKind, Heal, NOBODY, SpellId, @@ -47,6 +47,7 @@ pub fn fight(actors: Actors, mut events: Vec) -> Fight { logger_turned: Vec::new(), heal_grants: Vec::new(), delayed_hits: Vec::new(), + talents: HashMap::new(), roster: BTreeSet::new(), flavor: None, } diff --git a/crates/openlogs-wasm/src/engine.rs b/crates/openlogs-wasm/src/engine.rs index 04cab2f..707464b 100644 --- a/crates/openlogs-wasm/src/engine.rs +++ b/crates/openlogs-wasm/src/engine.rs @@ -1,9 +1,10 @@ use std::collections::BTreeSet; use openlogs_analysis::{ - Actors, Fight, LANDED_MATCH_MS, infer_classes, load_fight_slice, load_fight_slice_with, + Actors, Fight, LANDED_MATCH_MS, assign_talent_specs, infer_classes, load_fight_slice, + load_fight_slice_with, }; -use openlogs_gamedata::{ChannelSpells, Curated, DungeonTable, SpellClasses}; +use openlogs_gamedata::{ChannelSpells, Curated, DungeonTable, SpellClasses, TalentTrees}; use openlogs_index::{FightSummary, GameFlavor, Indexer, LogIndex}; use openlogs_service::auras_dto::AuraKindDto; use openlogs_service::casts_dto::CastsReportDto; @@ -55,6 +56,7 @@ impl DataGame { struct GameTables { channels: ChannelSpells, spell_classes: SpellClasses, + talent_trees: TalentTrees, } #[derive(Default)] @@ -123,6 +125,12 @@ impl Engine { Ok(()) } + pub fn set_talent_trees(&mut self, game: DataGame, json: &str) -> Result<(), String> { + self.spell_tables.of_mut(game).talent_trees = + TalentTrees::from_json(json).map_err(|err| err.to_string())?; + Ok(()) + } + fn tables(&self) -> &GameTables { self.spell_tables.of_flavor(self.index.flavor) } @@ -217,7 +225,7 @@ impl Engine { ) -> Result<(), String> { let summary = self.summary(fight_index)?.clone(); let mut fight = load_fight_slice(part, base_offset, &summary); - ready_for_reports(&mut fight, self.index.flavor, &self.tables().spell_classes); + ready_for_reports(&mut fight, self.index.flavor, self.tables()); self.fights.retain(|pulled| pulled.index != fight_index); self.fights.insert( 0, @@ -269,7 +277,7 @@ impl Engine { let mut fight = load_fight_slice_with(part, base_offset, summary, pass.actors.carried_over()); let tables = self.spell_tables.of_flavor(self.index.flavor); - ready_for_reports(&mut fight, self.index.flavor, &tables.spell_classes); + ready_for_reports(&mut fight, self.index.flavor, tables); let mut cuts = PullCuts::new(&fight); for command in &mut pass.commands { command.add(fight_index, &fight, &self.curated, &mut cuts); @@ -533,9 +541,12 @@ struct LoadedPull { summary: FightSummary, } -fn ready_for_reports(fight: &mut Fight, flavor: Option, spell_classes: &SpellClasses) { +fn ready_for_reports(fight: &mut Fight, flavor: Option, tables: &GameTables) { fight.flavor = flavor; - infer_classes(fight, spell_classes); + if !tables.talent_trees.is_empty() { + assign_talent_specs(fight, &tables.talent_trees); + } + infer_classes(fight, &tables.spell_classes); } fn summary_of(index: &LogIndex, fight_index: u32) -> Result<&FightSummary, String> { diff --git a/crates/openlogs-wasm/src/lib.rs b/crates/openlogs-wasm/src/lib.rs index e387f06..54b6aa4 100644 --- a/crates/openlogs-wasm/src/lib.rs +++ b/crates/openlogs-wasm/src/lib.rs @@ -49,6 +49,11 @@ impl Session { self.engine.set_spell_classes(game, json).map_err(to_js) } + pub fn set_talent_trees(&mut self, json: &str, game: &str) -> Result<(), JsValue> { + let game = DataGame::from_name(game).map_err(to_js)?; + self.engine.set_talent_trees(game, json).map_err(to_js) + } + pub fn begin_index(&mut self) { self.engine.begin_index(); } diff --git a/crates/openlogs-wasm/tests/engine.rs b/crates/openlogs-wasm/tests/engine.rs index 698e7d1..0e8b55d 100644 --- a/crates/openlogs-wasm/tests/engine.rs +++ b/crates/openlogs-wasm/tests/engine.rs @@ -956,6 +956,61 @@ fn a_log_reads_the_spell_classes_of_its_own_game() { ); } +#[test] +fn a_forever_player_shows_the_tree_of_their_talents() { + const OPEN_WORLD: &str = + include_str!("../../openlogs-index/tests/fixtures/forever_open_world.txt"); + let header_end = OPEN_WORLD.find('\n').unwrap() + 1; + let log = format!( + "{}11/5/2026 02:45:20.8301 COMBATANT_INFO,Player-6949-0066C9DA,0,118,217,173,35,63,0,0,0,56,56,56,0,0,0,0,0,0,0,0,0,0,1372,1488,[(1,1,5),(1,2,30),(2,1,16)],(0,0,0,0),[],[],0,0,0,0\n{}", + &OPEN_WORLD[..header_end], + &OPEN_WORLD[header_end..] + ); + let mut engine = Engine::default(); + engine + .set_talent_trees( + DataGame::Forever, + r#"{"trees":[{"id":181,"classId":4,"name":"Combat","icon":"ability_backstab"},{"id":182,"classId":4,"name":"Assassination","icon":"ability_rogue_eviscerate"}],"nodes":[[1,181],[2,182]],"specClasses":[[1488,4]]}"#, + ) + .unwrap(); + let (mut engine, view) = open_with(engine, &log); + let pull = view["fights"] + .as_array() + .unwrap() + .iter() + .find(|f| !f["combat"].is_null()) + .unwrap()["index"] + .as_u64() + .unwrap() as u32; + load(&mut engine, &log, pull); + let report = call( + &engine, + "damage_done_report", + json!({ "fightIndex": pull, "filter": whole_pull() }), + ); + let ravel = report["roster"] + .as_array() + .unwrap() + .iter() + .find(|p| p["name"] == "Ravel-Ashwood-Normal-EU") + .unwrap(); + + assert_eq!( + ( + &ravel["classId"], + &ravel["specName"], + &ravel["specIcon"], + &ravel["role"] + ), + ( + &json!(4), + &json!("Combat Rogue"), + &json!("ability_backstab"), + &json!("damage") + ) + ); +} + #[test] fn players_without_a_spec_take_the_class_of_their_casts() { const OPEN_WORLD: &str = diff --git a/ui/scripts/fetch-images.mjs b/ui/scripts/fetch-images.mjs index 7f987b5..dba35b3 100644 --- a/ui/scripts/fetch-images.mjs +++ b/ui/scripts/fetch-images.mjs @@ -14,9 +14,10 @@ const ATTEMPTS = 4; const TIMEOUT_MS = 30_000; const readJson = async (path) => JSON.parse(await readFile(join(ui, path), 'utf8')); -const [spellIcons, foreverSpellIcons, portraits, mapArt, classesSpecs] = await Promise.all([ +const [spellIcons, foreverSpellIcons, foreverTalentTrees, portraits, mapArt, classesSpecs] = await Promise.all([ readJson('public/game-data/spell-icons.json'), readJson('public/game-data/forever/spell-icons.json'), + readJson('public/game-data/forever/talent-trees.json'), readJson('public/game-data/boss-portraits.json'), readJson('public/game-data/map-art.json'), readJson('../crates/openlogs-gamedata/data/classes_specs.json'), @@ -25,6 +26,7 @@ const [spellIcons, foreverSpellIcons, portraits, mapArt, classesSpecs] = await P const iconNames = [ ...spellIcons.names, ...foreverSpellIcons.names, + ...foreverTalentTrees.trees.map((tree) => tree.icon), ...classesSpecs.classes.map((c) => classIconName(c.token)), ...classesSpecs.specs.map((s) => s.icon), ...NAMED_ICONS, diff --git a/ui/src/api/client.test.ts b/ui/src/api/client.test.ts index 35dc80c..f9f5f8e 100644 --- a/ui/src/api/client.test.ts +++ b/ui/src/api/client.test.ts @@ -62,6 +62,7 @@ function fakeEngine() { setDungeons: async () => {}, setChannelSpells: async () => {}, setSpellClasses: async () => {}, + setTalentTrees: async () => {}, beginIndex: async () => { state.beginIndexCalls += 1; fed.splice(0); @@ -135,7 +136,7 @@ function client() { engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => null, - spellClasses: async () => null, + spellClasses: async () => null, talentTrees: async () => null, db: memoryDatabase(), now: () => ++clock, }); @@ -174,7 +175,7 @@ describe('opening logs', () => { engine: () => fake.engine, dungeons: async () => 'keys', channelSpells: async () => channels, - spellClasses: async () => classes, + spellClasses: async () => classes, talentTrees: async () => null, db: memoryDatabase(), now: () => 1, }); @@ -195,7 +196,7 @@ describe('opening logs', () => { engine: () => fake.engine, dungeons: async () => null, channelSpells: async (game) => `${game}-channels`, - spellClasses: async (game) => `${game}-classes`, + spellClasses: async (game) => `${game}-classes`, talentTrees: async () => null, db: memoryDatabase(), now: () => 1, }); @@ -210,6 +211,26 @@ describe('opening logs', () => { ]); }); + it('gives only a Forever log the talent trees', async () => { + const fake = fakeEngine(); + const given: string[] = []; + fake.engine.setTalentTrees = async (json, game) => void given.push(`${json}:${game}`); + fake.engine.finishIndex = async (logId) => ({ ...view(logId), game: { kind: logId.startsWith('f') ? 'forever' : 'retail' } }); + const api = createClient({ + engine: () => fake.engine, + dungeons: async () => null, + channelSpells: async () => null, + spellClasses: async () => null, + talentTrees: async (game) => (game === 'forever' ? 'trees' : null), + db: memoryDatabase(), + now: () => 1, + }); + await api.openLog(source('r.txt', 10)); + await api.openLog(source('f.txt', 10)); + await api.openLog(source('f.txt', 11)); + expect(given).toEqual(['trees:forever']); + }); + it('gives a Forever log reopened from its stored index the Forever tables', async () => { const db = memoryDatabase(); const forever = (engine: Engine) => { @@ -218,7 +239,7 @@ describe('opening logs', () => { }; const first = fakeEngine(); forever(first.engine); - const deps = { dungeons: async () => null, channelSpells: async () => null, spellClasses: async () => 'classes', db, now: () => 1 }; + const deps = { dungeons: async () => null, channelSpells: async () => null, spellClasses: async () => 'classes', talentTrees: async () => null, db, now: () => 1 }; await createClient({ engine: () => first.engine, ...deps }).openLog(source('f.txt', 10)); const second = fakeEngine(); @@ -239,7 +260,7 @@ describe('opening logs', () => { engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => '{}', - spellClasses: async () => null, + spellClasses: async () => null, talentTrees: async () => null, db: memoryDatabase(), now: () => 1, }); @@ -251,7 +272,7 @@ describe('opening logs', () => { const bossPull = runLogFixture.fights[1]; const trash: FightRow = { ...bossPull, index: 20, encounterId: 0, name: 'Arathi Knight', combat: { enemyCount: 2 } }; fake.engine.finishIndex = async (logId) => ({ ...view(logId), fights: [...runLogFixture.fights, trash, { ...trash, index: 21, runIndex: null }] }); - const api = createClient({ engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => null, spellClasses: async () => null, db: memoryDatabase(), now: () => 1 }); + const api = createClient({ engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => null, spellClasses: async () => null, talentTrees: async () => null, db: memoryDatabase(), now: () => 1 }); await api.openLog(source('a.txt', 10)); expect((await api.recentLogs())[0].pullCount).toBe(6); }); @@ -427,7 +448,7 @@ describe('following a log that grows', () => { const given: string[] = []; fake.engine.setSpellClasses = async (_, game) => void given.push(game); fake.engine.refreshIndex = async (logId) => ({ ...view(logId), game: { kind: 'forever' } }); - const api = createClient({ engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => null, spellClasses: async () => '{}', db: memoryDatabase(), now: () => 1 }); + const api = createClient({ engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => null, spellClasses: async () => '{}', talentTrees: async () => null, db: memoryDatabase(), now: () => 1 }); const log = growable('today.txt', 0); await api.openLog(log); @@ -558,7 +579,7 @@ describe('following a log that grows', () => { engine: () => fake.engine, dungeons: async () => null, channelSpells: async () => null, - spellClasses: async () => null, + spellClasses: async () => null, talentTrees: async () => null, db, now: () => clock, }); diff --git a/ui/src/api/client.ts b/ui/src/api/client.ts index 3cefa0e..a2202bb 100644 --- a/ui/src/api/client.ts +++ b/ui/src/api/client.ts @@ -1,5 +1,5 @@ import { type Engine, workerEngine } from '../engine/engine'; -import { type DataGame, channelSpellsJson, dataGameOf, dungeonsJson, spellClassesJson } from '../gameData'; +import { type DataGame, channelSpellsJson, dataGameOf, dungeonsJson, spellClassesJson, talentTreesJson } from '../gameData'; import { t } from '../i18n/i18n'; import { browserDatabase, type Database } from './db'; import { fileGone, fileMissing, type LogSource, reopenHandle } from './logSource'; @@ -61,6 +61,7 @@ export interface ClientDeps { dungeons: () => Promise; channelSpells: (game: DataGame) => Promise; spellClasses: (game: DataGame) => Promise; + talentTrees: (game: DataGame) => Promise; db: Database; now: () => number; } @@ -83,7 +84,7 @@ async function readSome(source: LogSource, offset: number): Promise export class SetCancelled extends Error {} -export function createClient({ engine: getEngine, dungeons, channelSpells, spellClasses, db, now }: ClientDeps) { +export function createClient({ engine: getEngine, dungeons, channelSpells, spellClasses, talentTrees, db, now }: ClientDeps) { let current: { source: LogSource; /** The `openLog` call that opened it; a later one supersedes it. */ @@ -158,6 +159,7 @@ export function createClient({ engine: getEngine, dungeons, channelSpells, spell async function loadSpellTables(engine: Engine, game: DataGame) { await loadTable(`channelSpells:${game}`, () => channelSpells(game), (json) => engine.setChannelSpells(json, game)); await loadTable(`spellClasses:${game}`, () => spellClasses(game), (json) => engine.setSpellClasses(json, game)); + await loadTable(`talentTrees:${game}`, () => talentTrees(game), (json) => engine.setTalentTrees(json, game)); } async function index( @@ -395,6 +397,7 @@ export const api = createClient({ dungeons: dungeonsJson, channelSpells: channelSpellsJson, spellClasses: spellClassesJson, + talentTrees: talentTreesJson, db: browserDatabase, now: Date.now, }); diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index 61453bb..c5d4980 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -154,6 +154,8 @@ export interface PlayerRef { specId: number | null; /** E.g. "Arcane Mage"; `null` without a known spec. */ specName: string | null; + /** Icon name of the spec; `null` without a known spec. */ + specIcon: string | null; classId: number | null; classToken: string | null; role: Role | null; @@ -1206,6 +1208,7 @@ export interface ReplayUnit { name: string; kind: ReplayUnitKind; specId: number | null; + specIcon: string | null; classId: number | null; owner: number | null; /** Adds of one name are numbered from 1 in the order they were first positioned. */ diff --git a/ui/src/components/deaths/DeathsTab.test.tsx b/ui/src/components/deaths/DeathsTab.test.tsx index f7c5965..bb815f8 100644 --- a/ui/src/components/deaths/DeathsTab.test.tsx +++ b/ui/src/components/deaths/DeathsTab.test.tsx @@ -29,7 +29,7 @@ const report: DeathsReport = { ...recapFixture, roster: [ ...recapFixture.roster, - { actorId: 7, name: 'Sabrel-Emberfall-EU', specId: 269, specName: 'Windwalker Monk', classId: 10, classToken: 'MONK', role: 'damage' }, + { actorId: 7, name: 'Sabrel-Emberfall-EU', specId: 269, specIcon: 'spell_monk_windwalker_spec', specName: 'Windwalker Monk', classId: 10, classToken: 'MONK', role: 'damage' }, ], deaths: [faelan, sabrel], }; diff --git a/ui/src/components/deaths/set/SetDeathsPage.test.tsx b/ui/src/components/deaths/set/SetDeathsPage.test.tsx index fede5cc..05adf80 100644 --- a/ui/src/components/deaths/set/SetDeathsPage.test.tsx +++ b/ui/src/components/deaths/set/SetDeathsPage.test.tsx @@ -24,7 +24,7 @@ const report: SetDeaths = { ...recapFixture, roster: [ ...recapFixture.roster, - { actorId: 8, name: 'Tovric-Emberfall-EU', specId: 71, specName: 'Arms Warrior', classId: 1, classToken: 'WARRIOR', role: 'damage' }, + { actorId: 8, name: 'Tovric-Emberfall-EU', specId: 71, specIcon: 'ability_warrior_savageblow', specName: 'Arms Warrior', classId: 1, classToken: 'WARRIOR', role: 'damage' }, ], deaths: [], pulls: [ diff --git a/ui/src/components/overview/DeathsPanel.test.tsx b/ui/src/components/overview/DeathsPanel.test.tsx index 8dfff93..a0d4fc2 100644 --- a/ui/src/components/overview/DeathsPanel.test.tsx +++ b/ui/src/components/overview/DeathsPanel.test.tsx @@ -23,4 +23,11 @@ describe('DeathsPanel', () => { await userEvent.click(screen.getByRole('button', { name: 'Death recap of Faelan' })); expect(openDeathRecap).toHaveBeenCalledWith(4, 239_100); }); + + it('shows the class icon of a player without a known spec', () => { + const players = overviewFixture.players.map((p) => (p.actorId === 4 ? { ...p, specId: 1482, specName: null, specIcon: null } : p)); + render(); + const faelan = screen.getByRole('button', { name: 'Death recap of Faelan' }).parentElement; + expect(faelan?.querySelector('img')?.getAttribute('src')).toMatch(/class\/8$/); + }); }); diff --git a/ui/src/components/overview/DeathsPanel.tsx b/ui/src/components/overview/DeathsPanel.tsx index c848136..82b3bb7 100644 --- a/ui/src/components/overview/DeathsPanel.tsx +++ b/ui/src/components/overview/DeathsPanel.tsx @@ -1,9 +1,10 @@ import type { DeathEntry, PlayerRef, QuickOverview } from '../../api/types'; -import { specIcon, spellIcon } from '../../icons'; +import { spellIcon } from '../../icons'; import { formatAmountWhole, formatEventTime, formatPercent } from '../../i18n/format'; import { t } from '../../i18n/i18n'; import { useApp } from '../../store'; import { GameIcon } from '../GameIcon'; +import { PlayerIcon } from '../reports/PlayerName'; import { hitIcon, hitName } from '../reports/reportData'; import { contextBadges, damageParts, deathSource } from './deathModel'; import { classColor, playerIndex, shortName, spellName } from './players'; @@ -69,7 +70,7 @@ function DeathRow({ n, death, player, overview }: { n: number; death: DeathEntry {t('deaths.ordinal', { n })}
- {player && player.specId !== null && } + {player && (player.specIcon !== null || player.classId !== null) && }