Skip to content

Commit

Permalink
Restructure data modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed May 4, 2024
1 parent 8966977 commit 85a5fb7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 47 deletions.
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#[path = "src/data/structs.rs"]
mod structs;
#[path = "src/data/skill_def.rs"]
mod skill_def;

use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use skill_def::SkillDef;
use std::{
env,
fs::{self, File},
path::PathBuf,
};
use structs::SkillDef;
use winresource::WindowsResource;

fn main() {
Expand Down
10 changes: 4 additions & 6 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
mod buff;
mod condi;
mod skill;
mod structs;
mod skill_def;
mod skill_info;
mod skill_names;

pub use self::buff::*;
pub use self::condi::*;
pub use self::skill::*;
pub use self::structs::*;
pub use self::{buff::*, condi::*, skill_def::*, skill_info::*, skill_names::*};

use std::{
collections::HashMap,
Expand Down
37 changes: 37 additions & 0 deletions src/data/skill_def.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use serde::{Deserialize, Serialize};

// TODO: allow name override?
// TODO: instead of hits allow counting buff apply?
// TODO: support instant casts with buff apply?

/// Skill definition parsed from a file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SkillDef {
/// Skill id.
pub id: u32,

/// Whether the definition is active.
#[serde(default = "default_as_true")]
pub enabled: bool,

/// Additional hit skill ids.
#[serde(default)]
pub hit_ids: Vec<u32>,

/// Total amount of hits.
pub hits: Option<usize>,

/// Minimum amount of hits expected.
pub expected: Option<usize>,

/// Maximum duration (ms) to count as one cast.
pub max_duration: Option<i32>,

/// Whether to include minion hits.
#[serde(default)]
pub minion: bool,
}

fn default_as_true() -> bool {
true
}
39 changes: 1 addition & 38 deletions src/data/structs.rs → src/data/skill_info.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use serde::{Deserialize, Serialize};

// TODO: allow name override?
// TODO: instead of hits allow counting buff apply?
// TODO: support instant casts with buff apply?
use super::SkillDef;

/// Extra error margin for max duration.
const DURATION_EPSILON: i32 = 500;
Expand Down Expand Up @@ -58,7 +54,6 @@ pub struct SkillHits {
pub expected: usize,
}

#[allow(dead_code)] // TODO: cargo/clippy complain despite these being used in cast log?
impl SkillHits {
pub fn has_hits(&self) -> bool {
self.max > 0
Expand Down Expand Up @@ -99,35 +94,3 @@ pub enum SkillHitCount {
Max,
OverMax,
}

/// Skill definition parsed from a file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SkillDef {
/// Skill id.
pub id: u32,

/// Whether the definition is active.
#[serde(default = "default_as_true")]
pub enabled: bool,

/// Additional hit skill ids.
#[serde(default)]
pub hit_ids: Vec<u32>,

/// Total amount of hits.
pub hits: Option<usize>,

/// Minimum amount of hits expected.
pub expected: Option<usize>,

/// Maximum duration (ms) to count as one cast.
pub max_duration: Option<i32>,

/// Whether to include minion hits.
#[serde(default)]
pub minion: bool,
}

fn default_as_true() -> bool {
true
}
File renamed without changes.

0 comments on commit 85a5fb7

Please sign in to comment.