1use wowlab_common::output;
4use wowlab_fs::{
5 directory::{self, EntryKind},
6 path::{Path, PathBuf},
7};
8
9pub(crate) const DEFAULT_SEED: u64 = 12345;
10
11pub(crate) const DPS_SCALE: f64 = 10.0;
13
14const WORKSPACE_PARENT_DEPTH: usize = 3;
16
17pub(crate) fn workspace_parent() -> &'static Path {
18 Path::new(env!("CARGO_MANIFEST_DIR"))
19 .ancestors()
20 .nth(WORKSPACE_PARENT_DEPTH)
21 .expect("forge crate lives at <parent>/wowlab/crates/forge")
22}
23
24pub(crate) fn default_data_dir() -> String {
25 workspace_parent()
26 .join("wowlab-data")
27 .to_string_lossy()
28 .into_owned()
29}
30
31pub(crate) fn engine_dir() -> PathBuf {
32 let dir = Path::new(env!("CARGO_MANIFEST_DIR"))
33 .parent()
34 .expect("forge parent")
35 .join("engine");
36
37 match directory::inspect(&dir) {
38 Ok(Some(entry)) if entry.kind() == EntryKind::Directory => return dir,
39 Ok(Some(_)) => output::error(&format!(
40 "forge requires the workspace layout, but the expected engine crate is not a \
41 directory: {}",
42 dir.display(),
43 )),
44 Ok(None) => output::error(&format!(
45 "forge requires the workspace layout; run via 'cargo forge' from the repo root \
46 (expected engine crate at {})",
47 dir.display(),
48 )),
49 Err(error) => output::error(&error.to_string()),
50 }
51
52 std::process::exit(1);
54}