Cleanup and adds a Flow doc

This commit is contained in:
Dandaedre 2025-03-06 01:37:24 +01:00
parent b855455596
commit d7e7ffcb17
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
10 changed files with 104 additions and 416 deletions

View File

@ -1,4 +1,4 @@
![code coverage](badges/coverage.svg) ![version](badges/version.svg) ![code coverage](badges/test.svg)
![version](badges/version.svg) ![code coverage](badges/plastic.svg)
# ravenous-tools

View File

@ -2,7 +2,7 @@
// File: make/src/lib.rs
//! The module `makepdf` is responsible for making a pdf using pdflatex.
//!
//! The main function, [`make_pdf`](crate::makepdf::make_pdf), orchestrates the entire process of preparing,
//! The main function, [`make_pdf`], orchestrates the entire process of preparing,
//! building, and cleaning up LaTeX files to produce a final PDF. It relies on several other modules
//! within the `makepdf` workspace to perform specific tasks.
//!

View File

@ -1,13 +1,13 @@
// Workspace: more_fields_macro
// File: more_fields_macro/src/lib.rs
//! A very simple proc macro in chage of giving a field slice over ("name","sql_type")
//! This macro is a fork of the excellent work of : https://crates.io/crates/struct_iterable
//! This macro is a fork of the excellent work of : <https://crates.io/crates/struct_iterable>
//!
//! Other ressources include:
//! - https://github.com/rust-lang/reference/blob/master/src/procedural-macros.md#attribute-macros
//! - https://docs.rs/syn/latest/syn/struct.Attribute.html
//! - https://docs.rs/syn/latest/syn/struct.Attribute.html#parsing-from-tokens-to-attribute
//! - https://docs.rs/syn/latest/syn/struct.Ident.html
//! - <https://github.com/rust-lang/reference/blob/master/src/procedural-macros.md#attribute-macros>
//! - <https://docs.rs/syn/latest/syn/struct.Attribute.html>
//! - <https://docs.rs/syn/latest/syn/struct.Attribute.html#parsing-from-tokens-to-attribute>
//! - <https://docs.rs/syn/latest/syn/struct.Ident.html>
//!
// use proc_macro::TokenStream;
// use quote::quote;

View File

@ -1,180 +0,0 @@
// use charming::{
// Chart, WasmRenderer,
// component::{Axis, Title},
// element::AxisType,
// series::Line,
// };
// use leptos::prelude::*;
// use leptos_use::use_interval_fn;
// use leptos_use::utils::Pausable;
// #[component]
// fn App() -> impl IntoView {
// let data = RwSignal::new(vec![150, 230, 224, 218, 135, 147, 260]);
// let action = Action::new(move |_input: &()| {
// let local = data.get();
// async move {
// let chart = Chart::new()
// .title(Title::new().text("Demo: Leptos + Charming"))
// .x_axis(Axis::new().type_(AxisType::Category).data(vec!["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]))
// .y_axis(Axis::new().type_(AxisType::Value))
// .series(Line::new().data(local));
// let renderer = WasmRenderer::new(600, 400);
// renderer.render("chart", &chart).unwrap();
// }
// });
// let Pausable { pause, resume, is_active: _ } = use_interval_fn(
// move || {
// data.update(|d| d.rotate_right(1));
// action.dispatch(());
// },
// 1000,
// );
// action.dispatch(());
// view! {
// <div>
// <div id="chart"></div>
// <button on:click=move |_| pause()>"Pause"</button>
// <button on:click=move |_| resume()>"Resume"</button>
// </div>
// }
// }
// fn main() {
// mount_to_body(|| view! { <App /> })
// }
use charming::{
Chart,
component::{
Axis, DataZoom, DataZoomType, Feature, Grid, Restore, SaveAsImage, Title, Toolbox,
ToolboxDataZoom, VisualMap, VisualMapType,
},
element::{AxisType, Tooltip, Trigger},
series::Line,
};
// use rand::Rng;
pub fn chart() -> Chart {
let raw_data = vec![
("2000-06-05", 116),
("2000-06-06", 129),
("2000-06-07", 135),
("2000-06-08", 86),
("2000-06-09", 73),
("2000-06-10", 85),
("2000-06-11", 73),
("2000-06-12", 68),
("2000-06-13", 92),
("2000-06-14", 130),
("2000-06-15", 245),
("2000-06-16", 139),
("2000-06-17", 115),
("2000-06-18", 111),
("2000-06-19", 309),
("2000-06-20", 206),
("2000-06-21", 137),
("2000-06-22", 128),
("2000-06-23", 85),
("2000-06-24", 94),
("2000-06-25", 71),
("2000-06-26", 106),
("2000-06-27", 84),
("2000-06-28", 93),
("2000-06-29", 85),
("2000-06-30", 73),
("2000-07-01", 83),
("2000-07-02", 125),
("2000-07-03", 107),
("2000-07-04", 82),
("2000-07-05", 44),
("2000-07-06", 72),
("2000-07-07", 106),
("2000-07-08", 107),
("2000-07-09", 66),
("2000-07-10", 91),
("2000-07-11", 92),
("2000-07-12", 113),
("2000-07-13", 107),
("2000-07-14", 131),
("2000-07-15", 111),
("2000-07-16", 64),
("2000-07-17", 69),
("2000-07-18", 88),
("2000-07-19", 77),
("2000-07-20", 83),
("2000-07-21", 111),
("2000-07-22", 57),
("2000-07-23", 55),
("2000-07-24", 60),
];
let mut data_list = vec![];
let mut value_list = vec![];
raw_data.into_iter().for_each(|(date, value)| {
data_list.push(date);
value_list.push(value);
});
Chart::new()
.title(
Title::new()
.text("Gradient along the y axis")
.left("center"),
)
// .title(Title::new().text("Gradient along the x axis").left("center").top("55%"))
.tooltip(Tooltip::new().trigger(Trigger::Axis))
.visual_map(
VisualMap::new()
.show(false)
.type_(VisualMapType::Continuous)
.series_index(0)
.min(0)
.max(400),
)
// .visual_map(VisualMap::new().show(false).type_(VisualMapType::Continuous).series_index(1).dimension(0).min(0).max(10).max((data_list.len() - 1) as f64))
.x_axis(
Axis::new()
.data(data_list.to_vec())
.type_(AxisType::Category)
.boundary_gap(false),
)
// .x_axis(Axis::new().data(data_list.to_vec()).grid_index(1))
.y_axis(Axis::new())
// .y_axis(Axis::new().grid_index(1))
.grid(Grid::new())
// .grid(Grid::new().top("60%"))
.series(Line::new().show_symbol(false).data(value_list.clone()))
.data_zoom(
DataZoom::new()
.type_(DataZoomType::Inside)
.start(0)
.end(100),
)
.data_zoom(DataZoom::new().start(0).end(100))
.toolbox(
Toolbox::new().feature(
Feature::new()
.data_zoom(ToolboxDataZoom::new().y_axis_index("none"))
.restore(Restore::new())
.save_as_image(SaveAsImage::new()),
),
)
.tooltip(Tooltip::new().trigger(Trigger::Axis))
// .series(Line::new().show_symbol(false).x_axis_index(1).y_axis_index(1).data(value_list))
}
fn main() {
let chart = chart();
use charming::HtmlRenderer;
let mut renderer = HtmlRenderer::new("MOOO", 1800, 1800).theme(charming::theme::Theme::Dark);
// // Render the chart as HTML string.
// let html_str = renderer.render(&chart).unwrap();
// Save the chart as HTML file.
renderer.save(&chart, "./chart.html").unwrap();
}

View File

@ -1,215 +0,0 @@
// Workspace: weaponry
// File: examples/usage_import_tex.rs
//! Example of a first initialisation
//! All this work is cursed and rushed
// use logos::Logos;
// use more_fields::FieldsAsSlice;
// use serde::Serialize;
// use serde_rusqlite::to_params_named;
use weaponry::interfaces::RecipeDatabase;
use weaponry::weaponry_structs::equipement_impl_database::EquipementDatabase;
// use weaponry::weaponry_structs::{DamageMod, DamageType, WeaponMetaCategory};
// use weaponry::weaponry_structs::PhysicalDamageType;
use weaponry::weaponry_structs::equipement_structs::{DatabaseEquipementStats, InnerEquipementStats};
// #[derive(Logos, Debug, PartialEq)]
// enum ModeParser {
// #[regex(r"\[\[\w+\]\]", |lex| std::convert::TryInto::<PhysicalDamageType>::try_into(&lex.slice()[2..lex.slice().len()-2]).unwrap())]
// Tertiary(PhysicalDamageType),
// #[regex(r"\[\w+\]", |lex| std::convert::TryInto::<PhysicalDamageType>::try_into(&lex.slice()[1..lex.slice().len()-1]).unwrap())]
// Secondary(PhysicalDamageType),
// #[regex(r"\w+", |lex| std::convert::TryInto::<PhysicalDamageType>::try_into(lex.slice()).unwrap())]
// Primary(PhysicalDamageType),
// }
// let b = DamageMod::Primary()
fn main() {
let db = EquipementDatabase::new("./databases/weapons.db").unwrap();
// init_db(&db);
let initial_deserialisation = db.serialize_vec_from_table::<DatabaseEquipementStats>("Equipements", None);
// println!("Initial deserialisation in DatabaseEquipementStats: {:?}", initial_deserialisation);
// println!("First entry: {:?}", initial_deserialisation.as_ref().unwrap()[0]);
let intermediate_deserialisation = initial_deserialisation.unwrap().into_iter().map(InnerEquipementStats::try_from).collect::<Vec<_>>();
// let v = intermediate_deserialisation
// .iter()
// .scan(0, |status, eq| {
// if eq.is_ok() {
// *status = 1;
// } else {
// *status = 0;
// }
// Some(*status)
// })
// .sum::<i32>();
let f = intermediate_deserialisation.iter().fold((0, 0), |val, res| (val.0 + res.is_ok() as usize, val.1 + 1_usize));
println!("Final data {:#?}", intermediate_deserialisation);
println!("Succeded in parsing {}/{}", f.0, f.1);
}
// #[derive(Default)]
// struct FoundFields {
// reload: Option<u8>,
// range: Option<u8>,
// parmor: Option<u8>,
// }
// fn init_db(db: &EquipementDatabase) {
// let mut global_index = 0;
// let b = load_base(&mut global_index);
// db.initialize_empty_table::<DatabaseEquipementStats>("Equipements").unwrap();
// db.conn.execute("DELETE FROM Equipements", []).unwrap();
// println!("Added {global_index} ids to the new database");
// b.iter().for_each(|v| insert_into_db(db, v));
// }
// fn parse_special_field(fields: &str) -> FoundFields {
// // "Arbalète & Distance & 4 & 1 & 3 0 & 3 & 1 & 8 & 16 & pierce & -1 & -1 & 0 & -1 & 2reload, Gls{parmure} 2, 80m & ddlvl{1} ",
// let re = regex::Regex::new(r"((?<reload>\d)reload)?(, )?(Gls\{parmure\} (?<parmure>\d))?(, )?((?<range>\d+)m)?").unwrap();
// re.captures(fields).map_or(FoundFields::default(), |f| FoundFields {
// reload: f.name("reload").map(|n| n.as_str().parse().unwrap()),
// range: f.name("range").map(|v| v.as_str().parse().unwrap()),
// parmor: f.name("parmor").map(|v| v.as_str().parse().unwrap()),
// })
// }
// #[allow(dead_code)]
// fn insert_into_db<T: Serialize>(db: &EquipementDatabase, row: T) {
// let sql = &format!(
// "INSERT INTO Equipements ({}) VALUES ({})",
// DatabaseEquipementStats::attributes_slice()
// .iter()
// // .filter_map(|(k, _v)| (*k != "id").then_some(*k))
// .map(|(k, _v)| *k)
// .collect::<Vec<_>>()
// .join(", "),
// DatabaseEquipementStats::attributes_slice()
// .iter()
// // .filter_map(|(k, _v)| (*k != "id").then_some(":".to_string() + *k))
// .map(|(k, _v)| ":".to_string() + *k)
// .collect::<Vec<_>>()
// .join(", ")
// );
// // println!("Database Request {}", sql);
// let r = db.conn.execute(sql, to_params_named(&row).unwrap().to_slice().as_slice());
// match r {
// Ok(_r) => {
// // println!("Loaded {:?} entries into the database", _r);
// }
// Err(e) => println!("Error: {} while processing entry", e),
// };
// }
// // fn load_base(index: &mut u8) -> Vec<DatabaseEquipementStats> {
// // BASE_FORME
// // .iter()
// // .map(|row| {
// // let fields = row.split("&").map(|field| field.trim()).collect::<Vec<_>>();
// // let FoundFields { reload, range, parmor } = parse_special_field(fields[15]);
// // *index += 1;
// // // "% Nom & Type & Dé & + & RM & AB & Pr & In & T2 & T1 & Md & Esq. & Par. & Vit. & Disc. & Spc. & Diff ",
// // // 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15
// // DatabaseEquipementStats {
// // id: *index,
// // meta_category: "Forme".into(),
// // name: fields[0].to_string(),
// // category: serde_json::to_string(&parse_to_type(fields[1]).unwrap()).unwrap(),
// // rarity: 0,
// // cost: 0,
// // precision: 0,
// // difficulty: fields[16].parse().unwrap_or_default(), // NOT PARSED YET
// // // tier: ,
// // damage: fields[2].parse().unwrap_or_default(),
// // p_damage: fields[3].parse().unwrap_or_default(),
// // rmax: fields[4].parse().unwrap_or_default(),
// // armor_break: fields[5].parse().unwrap_or_default(),
// // protection: fields[6].parse().unwrap_or_default(),
// // integrity: fields[7].parse().unwrap_or_default(),
// // torque_two_handed: serde_json::to_string(&match fields[8] {
// // "-" => None,
// // v => Some(v.parse::<u8>().unwrap()),
// // })
// // .unwrap(),
// // torque_one_handed: serde_json::to_string(&match fields[9] {
// // "-" => None,
// // v => Some(v.parse::<u8>().unwrap()),
// // })
// // .unwrap(), // The or default is a problem
// // damage_type: serde_json::to_string(&parse_to_damagetype(fields[10])).unwrap(),
// // dodge: fields[11].parse().unwrap_or_default(),
// // parry: fields[12].parse().unwrap_or_default(),
// // speed: fields[13].parse().unwrap_or_default(),
// // stealth: fields[14].parse().unwrap_or_default(),
// // reload_cost: serde_json::to_string(&reload).unwrap(),
// // range: range.unwrap_or_default(),
// // armor_pierce: parmor.unwrap_or_default(),
// // // meta_category: parse_to_type(fields[1]),
// // // target: fields[5].parse().unwrap(), // Armors ?
// // ..Default::default()
// // }
// // })
// // .collect::<Vec<_>>()
// // }
// fn parse_to_damagetype(fields: &str) -> DamageType {
// DamageType(fields.split(",").map(|v| ModeParser::lexer(v.trim()).next().unwrap().unwrap().into()).collect::<Vec<_>>())
// }
// impl From<ModeParser> for DamageMod {
// fn from(value: ModeParser) -> Self {
// match value {
// ModeParser::Primary(v) => DamageMod::Primary(v),
// ModeParser::Secondary(v) => DamageMod::Secondary(v),
// ModeParser::Tertiary(v) => DamageMod::Tertiary(v),
// }
// }
// }
// fn parse_to_type(text: &str) -> Option<WeaponMetaCategory> {
// match text {
// "Hast" => Some(WeaponMetaCategory::Staves),
// "Tranchantes" => Some(WeaponMetaCategory::Slash),
// "Contondantes" => Some(WeaponMetaCategory::Blunt),
// "Distance" => Some(WeaponMetaCategory::Ranged),
// "Boucliers" => Some(WeaponMetaCategory::Shields),
// "Armures" => Some(WeaponMetaCategory::Armor),
// "Exotiques" => Some(WeaponMetaCategory::Exotic),
// _ => None,
// }
// }
// const BASE_FORME: &[&str] = &[
// // "% Nom & Type & Dé & + & RM & AB & Pr & In & T2 & T1 & Md & Esq. & Par. & Vit. & Disc. & Spc. & Diff ",
// // "Name & Type & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & mode & 9 & 10 & 11 & 12 & 3reload, & ddlvl{13} ",
// "Griffes & Tranchantes & 2 & 1 & 4 & 1 & 1 & 2 & 3 & 6 & slash & 2 & 0 & 3 & 1 & - & ddlvl{1} ",
// "Hast & Hast & 4 & 1 & 2 & 1 & 4 & 3 & 10 & 18 & pierce, [slash] & -1 & -3 & 1 & 0 & - & ddlvl{1} ",
// "Épée & Tranchantes & 3 & 1 & 3 & 1 & 3 & 4 & 12 & 15 & slash, [pierce] & 0 & 1 & 0 & 0 & - & ddlvl{1} ",
// "Marteau & Contondantes & 5 & 1 & 1 & 1 & 4 & 3 & 11 & 18 & blunt & -1 & -1 & 0 & -2 & - & ddlvl{1} ",
// "Hache & Tranchantes & 4 & 2 & 1 & 3 & 4 & 3 & 9 & 14 & slash & 0 & -1 & 1 & 0 & - & ddlvl{1} ",
// "Arbalète & Distance & 4 & 1 & 3 & 0 & 3 & 1 & 8 & 16 & pierce & -1 & -1 & 0 & -1 & 2reload, Gls{parmure} 2, 80m & ddlvl{1} ",
// "Arc & Distance & 3 & 1 & 4 & 0 & 2 & 1 & - & 7 & pierce & 0 & 0 & 0 & 0 & 1reload, Gls{parmure} 2, 120m & ddlvl{1} ",
// "Boucliers & Boucliers & 1 & 1 & 2 & 0 & 3 & 2 & 6 & 8 & blunt & -2 & 0 & -1 & -2 & - & ddlvl{1} ",
// "Armures & Armures & & & & & 3 & 2 & 10 & - & blunt & -1 & 0 & 0 & -1 & - & ddlvl{1} ",
// // "% Explosive & Exotiques & 3 & 1 & 3 & 1 & 2 & 2 & 20 & 10 & slash & 0 & 0 & 0 & 0 & - & ddlvl{5} ",
// // "% Flexible & Exotiques & 3 & 1 & 3 & 1 & 2 & 2 & 20 & 10 & slash & 0 & 0 & 0 & 0 & - & ddlvl{2} ",
// // "% Exotique & Exotiques & 3 & 1 & 3 & 1 & 2 & 2 & 20 & 10 & slash & 0 & 0 & 0 & 0 & - & ddlvl{3} ",
// ];
// #[allow(dead_code)]
// const BASE_SHAPE: &[&str] = &[
// // " Maniement & damagew & + & rmax & arbreakw & faShield* & faShieldVirus & $mathbb{T}2$ & $mathbb{T}$1 & Esq. & Par. & Vit. & Disc. & Spécial & Diff. "
// // " % Nom & Dg & + & RM & AB & Pr & In & T2 & T1 & Esq. & Par. & Vit. & Disc. & Sp & Diff",
// " Arme Légère & -1 & 0 & 2 & -1 & -1 & -1 & -5 & -6 & 2 & 2 & 0 & 0 & Ag+half, Esq.+half & ddlvl{1}",
// " Arme Moyenne & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & - & ddzero",
// " Arme Lourde & 2 & 1 & 1 & 0 & 1 & 0 & 8 & 11 & -2 & -2 & -1 & -1 & - & ddlvl{1}",
// " Arme Super-lourde & 3 & 2 & 1 & 1 & 2 & 1 & 23 & 23 & -3 & -3 & -3 & -3 & 2A, Ag-1, [[blunt]], Précision-1 & ddlvl{2}",
// // " Arme Combinée & - & - & - & - & - & -2 & - & - & - & - & - & - & - & ddlvl{3}", // We'll have to think about this one
// // " Arme Escamotable & - & - & - & - & - & - & - & - & - & - & - & - & - & ddlvl{3}", // We'll have to think about this one
// " Armure Légère & - & - & - & - & -1 & -1 & -1 & - & 1 & 0 & 0 & 1 & Ag+1 & ddlvl{1}",
// " Armure Moyenne & - & - & - & - & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & - & ddzero",
// " Armure Lourde & - & - & - & - & 1 & 1 & 13 & - & -3 & -3 & -2 & -3 & Ag-1, Précision -1 & ddlvl{1}",
// " Armure Super-lourde & - & - & - & - & 3 & 3 & 25 & - & -5 & -4 & -4 & -6 & Ag-1, Précision -1 & ddlvl{2}",
// ];

View File

@ -0,0 +1,40 @@
# Introduction
The generic nature of the recipe generator makes it rather complicated to navigate and comprehend;
however while suffering from many developpement mistakes and shortcommings, a good deal of code reuse was averted
# Structure
The inner structures follow the following.
| Underlaying data | Encapsulating Element | Encapsulating list of elements |
|-----------------------|----------------------------|--------------------------------|
| DatabaseInner (DeSer) | None | None |
| BaseInner (Converted) | InitialElement | InitialElementList |
| AdvancedInner (Calc) | RefinedElement (+BaseInner)| RefinedElementList |
# Explainations
| Category | Explainations | Traits | Impls |
|---------------------|------------------------------|----------------------------------------|------------------------|
| DatabaseInner | Deserialization InnerData | FieldsAsSclice | DatabaseEquipementStats|
| BaseInner | BuildingBlock InnerData | FieldAsSlice, Add, From<DatabaseInner> | InnerEquipementStats |
| AdvancedInner | Calculated data for analysis | Serialize, From<DatabaseInner> | AdvancedStats |
| IntermediateElement | Setup InitialElement | | EqFinishing, etc.. |
| InitialElement | Real Elements by Combination | From<InitalElement>, Combinable | Equipement |
| RefinedElement | Export & Analysis | Serialize | RefinedEquipement |
| InitialElementList | Create list by cross combin. | RecipeCollection | InitialEquipementList |
| RefinedElementList | Analysis & Export | From<InitialElementList, (TBD) | RefinedEquipemenList |
# Workflow
* Deserialize data in a deserializing struct
* Convert it to a valid inner element data
* Wrap in in an intermediate element to allow custom filters and advanced checks
* Create an initial element from it
* Wrap these element in a serie of list (by part, shape, finishing, etc).
* Combine these list to create all final elements (by inner combination)
* Process this combination of list into a RefinedElementList
* Analysis or export
* ????
* Profit
# Implementation

View File

@ -94,7 +94,7 @@ where
/// Create a collection from a vector
fn from_vectored(list: Vec<Self::Recipes>) -> Self;
/// Create a collection from an iterator of intermediate values <T>
/// Create a collection from an iterator of intermediate values T
fn from_iter_intermediate<T>(
iter_inter: impl Iterator<Item = Result<T, FatalEquipementError>>,
) -> Result<Self, FatalEquipementError>
@ -302,7 +302,7 @@ pub trait Scenario where for<'a> &'a <<<Self as Scenario>::InitialEquipementList
/// Automatically deserialize into an equipement
fn deserde_into_equipement<T>(
fn deserde_into_processed_representation<T>(
&self,
filter: Option<&str>,
) -> Result<Self::InitialEquipementListType, FatalEquipementError>

View File

@ -58,7 +58,7 @@ pub enum PhysicalDamageType {
/// Weapon damage, combining the base weapon damage type and it's level
///
/// Signifying wether the damage is pure or [secondary] or [[tertiary]]
/// Signifying wether the damage is pure or \[secondary\] or \[\[tertiary\]\]
#[allow(clippy::missing_docs_in_private_items, missing_docs)]
#[derive(Clone, Debug, Display, Deserialize, Serialize)]
#[cfg_attr(test, derive(PartialEq))]
@ -85,7 +85,7 @@ impl Deref for DamageType {
}
impl DamageType {
/// Create a new DamageType from a vector of [DamageMod]
/// Create a new DamageType from a vector of *DamageMod*
pub fn new(inner_data: Vec<DamageMod>) -> Self {
Self(inner_data)
}

View File

@ -63,24 +63,27 @@ impl CrossRecipeScenario {
) -> Result<Vec<InitialEquipementList>, FatalEquipementError> {
let mut operations = Vec::with_capacity(8);
if self.config.shape.is_some() {
operations
.push(self.deserde_into_equipement::<EqShape>(Some("META_CATEGORY LIKE 'Shape'"))?);
operations.push(self.deserde_into_processed_representation::<EqShape>(Some(
"META_CATEGORY LIKE 'Shape'",
))?);
}
if let Some(qt) = self.config.materials {
for _ in 0..qt {
operations.push(self.deserde_into_equipement::<EqMaterial>(Some(
"META_CATEGORY LIKE 'Materials'",
))?);
operations.push(
self.deserde_into_processed_representation::<EqMaterial>(Some(
"META_CATEGORY LIKE 'Materials'",
))?,
);
}
}
if self.config.nature.is_some() {
operations.push(
self.deserde_into_equipement::<EqNature>(Some("META_CATEGORY LIKE 'Nature'"))?,
);
operations.push(self.deserde_into_processed_representation::<EqNature>(Some(
"META_CATEGORY LIKE 'Nature'",
))?);
}
if self.config.finishing.is_some() {
operations.push(
self.deserde_into_equipement::<EqFinishing>(Some(
self.deserde_into_processed_representation::<EqFinishing>(Some(
"META_CATEGORY LIKE 'Finishing'",
))?,
);
@ -138,6 +141,46 @@ impl Scenario for CrossRecipeScenario {
#[cfg(test)]
mod test {
use more_fields::FieldsAsSlice;
use crate::{
interfaces::{RecipeDatabase, Scenario},
weaponry_structs::{
equipement_impl_database::EquipementDatabase,
equipement_structs::{DatabaseEquipementStats, EqFinishing, InnerEquipementStats},
},
};
use super::{ConfigEquipementScenario, CrossRecipeScenario};
struct TestStruct {
id: usize,
name: String,
}
#[test]
fn test_scenario() {}
#[test]
fn test_deserde_into() {
let b = CrossRecipeScenario {
database: EquipementDatabase {
conn: rusqlite::Connection::open_in_memory().unwrap(),
},
config: ConfigEquipementScenario {
table_name: "TestStruct".to_owned(),
db_path: "None".to_owned(),
shape: None,
materials: None,
nature: None,
finishing: None,
},
};
b.get_database().conn.execute("CREATE TABLE IF NOT EXISTS Finishing (id INTEGER UNIQUE, name TEXT, PRIMARY KEY('id' AUTOINCREMENT));",[]).unwrap();
b.get_database()
.initialize_empty_table::<DatabaseEquipementStats>("Finishing")
.unwrap();
// let r = b
// .deserde_into_processed_representation::<EqFinishing>(None)
// .unwrap();
}
}

View File

@ -104,7 +104,7 @@ pub struct InnerEquipementStats {
///
/// The categories are: Staves, Blunt, Slash, Ranged, Armors, Shields, Exotic, None,
pub category_base: Option<WeaponBaseShape>,
/// The category size as [WeaponBaseSize]
/// The category size as WeaponBaseSize
///
/// Categories are : (Light, Medium, Heavy and SuperHeavy)
pub category_size: Option<WeaponBaseSize>,