wowlab_engine_application/
rotation_validation.rs1use wowlab_engine_domain::rotation::{
4 CheckResult, build_spec_resolver, check, extract_names_from_rotation,
5};
6use wowlab_engine_ports::ContentCatalog;
7use wowlab_types::{game::SpecId, sim::Rotation};
8
9use crate::{ApplicationError, introspect_spec};
10
11pub fn validate_rotation_for_spec(
13 catalog: &ContentCatalog,
14 spec_id: SpecId,
15 rotation: &Rotation,
16) -> Result<CheckResult, ApplicationError> {
17 let descriptor = catalog.descriptor(spec_id).map_err(|source| {
18 ApplicationError::from_engine(crate::ApplicationStage::RotationValidation, source.into())
19 })?;
20 let introspection = introspect_spec(catalog, spec_id)?;
21 let names = extract_names_from_rotation(rotation);
22 let talent_names: Vec<&str> = descriptor
23 .metadata
24 .talents
25 .iter()
26 .map(|(name, _)| *name)
27 .collect();
28 let resolver = build_spec_resolver(&introspection, spec_id, &talent_names);
29
30 Ok(check(&names, &resolver))
31}
32
33#[cfg(test)]
34mod tests;