diff --git a/src/character.rs b/src/character.rs new file mode 100644 index 0000000..9c65ac4 --- /dev/null +++ b/src/character.rs @@ -0,0 +1,36 @@ +use serde::Deserialize; + +#[allow(dead_code)] +#[derive(Deserialize, Debug)] +#[serde(rename_all = "snake_case")] +pub struct CharacterSb { + pub name: String, + #[serde(rename = "type")] + pub kind: String, + pub level: serde_json::Value, + #[serde(rename = "trait")] + pub traits: Vec, + pub skill_markdown: Option, + pub hp_raw: String, + pub perception: i32, + pub sense_markdown: String, + pub strength: i32, + pub dexterity: i32, + pub constitution: i32, + pub intelligence: i32, + pub wisdom: i32, + pub charisma: i32, + pub ac: i32, + pub fortitude_save: i32, + pub reflex_save: i32, + pub will_save: i32, + pub immunity_markdown: Option, + pub resistance_markdown: Option, + pub weakness_markdown: Option, + pub speed_markdown: String, + pub markdown: String, + /// If this is a legacy creature that has been remastered, this will be `Some` + pub remaster_id: Option>, + /// If this is a remastered creature, this will be `Some` + pub legacy_id: Option>, +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..7889122 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod character; diff --git a/src/main.rs b/src/main.rs index 1627d4e..f38df41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Context; use clap::Parser; +use nethys_to_obsidian::character::CharacterSb; use regex::Regex; -use serde::Deserialize; use std::fs; use std::io::{Read, stdin}; use std::path::PathBuf; @@ -14,41 +14,6 @@ struct Args { path: Option, } -#[allow(dead_code)] -#[derive(Deserialize, Debug)] -#[serde(rename_all = "snake_case")] -struct CharacterSb { - name: String, - #[serde(rename = "type")] - kind: String, - level: serde_json::Value, - #[serde(rename = "trait")] - traits: Vec, - skill_markdown: Option, - hp_raw: String, - perception: i32, - sense_markdown: String, - strength: i32, - dexterity: i32, - constitution: i32, - intelligence: i32, - wisdom: i32, - charisma: i32, - ac: i32, - fortitude_save: i32, - reflex_save: i32, - will_save: i32, - immunity_markdown: Option, - resistance_markdown: Option, - weakness_markdown: Option, - speed_markdown: String, - markdown: String, - /// If this is a legacy creature that has been remastered, this will be `Some` - remaster_id: Option>, - /// If this is a remastered creature, this will be `Some` - legacy_id: Option>, -} - fn format_val(v: &serde_json::Value) -> String { if v.is_string() { v.as_str().unwrap_or("").to_string()