From f5534a77a27195572dff39eac2f13447f5fdbb71 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 17 Feb 2025 07:15:07 +0100 Subject: [PATCH] Adds more help on the workflow --- .gitignore | 1 + weaponry/Cargo.toml | 1 + weaponry/helpers/Implementation.drawio | 322 ++++++++++++++++++ weaponry/{ => helpers}/workflow.md | 5 + weaponry/src/error.rs | 31 ++ weaponry/src/interfaces.rs | 41 +++ weaponry/src/lib.rs | 1 + .../weaponry_structs/equipement_impl_logic.rs | 3 +- 8 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 weaponry/helpers/Implementation.drawio rename weaponry/{ => helpers}/workflow.md (89%) create mode 100644 weaponry/src/error.rs diff --git a/.gitignore b/.gitignore index f690d27..deed149 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ Cargo.lock callgrind* cache.out tarpaulin-report.html +*.bkp diff --git a/weaponry/Cargo.toml b/weaponry/Cargo.toml index 9fe62d2..f76b28e 100644 --- a/weaponry/Cargo.toml +++ b/weaponry/Cargo.toml @@ -16,6 +16,7 @@ serde_rusqlite = "0.37.0" serde_json = { version = "1.0.138", features = ["alloc"] } struct-field-names-as-array = "0.3.0" strum = { version = "0.27.0", features = ["derive"] } +thiserror = "2.0.11" [dev-dependencies] criterion = { version = "0.5" } diff --git a/weaponry/helpers/Implementation.drawio b/weaponry/helpers/Implementation.drawio new file mode 100644 index 0000000..c480b0e --- /dev/null +++ b/weaponry/helpers/Implementation.drawio @@ -0,0 +1,322 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/weaponry/workflow.md b/weaponry/helpers/workflow.md similarity index 89% rename from weaponry/workflow.md rename to weaponry/helpers/workflow.md index 1fc616a..e253452 100644 --- a/weaponry/workflow.md +++ b/weaponry/helpers/workflow.md @@ -1,3 +1,8 @@ +# TO-Impl List + - Initial Object Representation + - Final Object Representation + + # Workflow A B C Database -> -> -> Balancing data diff --git a/weaponry/src/error.rs b/weaponry/src/error.rs new file mode 100644 index 0000000..3d85c1e --- /dev/null +++ b/weaponry/src/error.rs @@ -0,0 +1,31 @@ +// Workspace: weaponry +// File: weaponry/src/error.rs +//! Inner weaponry error definition +#![allow(missing_docs, clippy::missing_docs_in_private_items)] + +use thiserror::Error; + +#[derive(Error, Debug)] +/// Unrecoverable Error, all these error cannot gracefully fail and must return to the User for further handling +pub enum FatalEquipementError { + #[error("Unkown error has errored")] + Unknown, +} + +#[derive(Error, Debug)] +/// Recoverable error, all these error exist to signal a retry or another path that should be taken by the program +pub enum TrivialEquipementError { + #[error("Very simple error")] + Oops, +} + +#[derive(Error, Debug)] +/// An equipement error, either unrecoverable, indicating a that the execution +/// flow must be stopped and only an user input can solve the issue +pub enum EquipementError { + #[error("An unrecoverable error occured: {0}")] + Unrecoverable(#[from] FatalEquipementError), + + #[error("A recoverable error occured but wasn't caught by the programming: {0}")] + Recoverable(#[from] TrivialEquipementError), +} diff --git a/weaponry/src/interfaces.rs b/weaponry/src/interfaces.rs index 27b7b65..f642d20 100644 --- a/weaponry/src/interfaces.rs +++ b/weaponry/src/interfaces.rs @@ -7,6 +7,8 @@ use std::{path::Path, rc::Rc}; +use crate::error::EquipementError; + /// Trait representing a view table /// /// These table exist to allow to link several point of interest to a RecipeCollection @@ -171,3 +173,42 @@ pub trait Reportable { /// This report should give detailled information about the inner data, without showing the actual inner data fn get_report(&self) -> String; } + +/// A recipe full stack scenario, from loading database through view table generation +/// +/// The inner working while somehow abstracted are very tied together and tied to the impl +pub trait Scenario { + /// The inner database type + type DatabaseType; //: Database; + /// The type of viewtable that must be returned by the scenario + // Could also use dyn dispatch but since all of it is so tied down... + type ViewTableType: ViewTable; + /// The type of the final recipe list + type FinalListType: RefinedList; + + /// Load all database into intermediate representation + fn load_from_database() -> Result + where + Self: std::marker::Sized; + + // All these steps should be implemented but not required + // enforcing them helps writing new impls more easily but is not really nice in any way + // + // /// Process the inner representations and get a list of results + // fn process_inner_representation(&self) -> Result<(), FatalEquipementError>; //Result<(), EquipementError> + + // /// Process inner recipes into a Final list + // /// + // /// This will generate the recipe list using the prefered method of the Scenario (Fixed Recipes or Cross Recipes or Whatever) + // fn process_recipes(&self); + + // /// Process the recipes into a Refined Recipes + // fn refine_recipes(&self); + + /// Generate the final list type + fn generate_refined_recipes(&self) -> Self::FinalListType; + + /// Gather the selected view tables + /// All the inner generation is done gradually and populate all section to finally generate the views + fn generate_view_tables(&self) -> Self::ViewTableType; +} diff --git a/weaponry/src/lib.rs b/weaponry/src/lib.rs index b3c7dfd..e78998c 100644 --- a/weaponry/src/lib.rs +++ b/weaponry/src/lib.rs @@ -6,6 +6,7 @@ #![feature(iter_intersperse, generic_arg_infer)] mod database; +pub mod error; mod export; pub mod interfaces; mod strategy; diff --git a/weaponry/src/weaponry_structs/equipement_impl_logic.rs b/weaponry/src/weaponry_structs/equipement_impl_logic.rs index 5e7b020..36cd772 100644 --- a/weaponry/src/weaponry_structs/equipement_impl_logic.rs +++ b/weaponry/src/weaponry_structs/equipement_impl_logic.rs @@ -53,7 +53,8 @@ mod test { interfaces::RecipeCollection, weaponry_structs::{ DamageMod, DamageType, Equipement, InitialEquipementList, SpecialCategory, - WeaponCategory, equipement_fields::PhysicalDamageType, equipement_structs::InnerEquipementStats, + WeaponCategory, equipement_fields::PhysicalDamageType, + equipement_structs::InnerEquipementStats, }, }; use pretty_assertions::assert_eq; -- 2.45.1