// Workspace: weaponry // File: examples/usage_scenario.rs //! Test use case of a scenario //! //! use std::path::Path; // TODO : All of these should likely be in the prelude if used like this use weaponry::interfaces::{Reportable, Scenario, ToCSV}; use weaponry::weaponry_structs::CrossRecipeScenario; use weaponry::weaponry_structs::equipement_scenario::ConfigMock; // use weaponry::interfaces:: fn main() { let save_path = "data/first_data.csv"; let scenarios = CrossRecipeScenario::new_with_config(ConfigMock {}).unwrap(); let refined_list = scenarios.generate_refined_recipes().unwrap(); println!("{}", refined_list.get_report(Some("Refined List"))); println!("Saved initial data as {}: {:?}", save_path, refined_list.write_csv(Path::new(save_path))); } // // Load DB // let db = EquipementDatabase::new("./databases/weapons.db").unwrap(); // // Do a first deserialisation // let initial_deserialisation = db.serialize_vec_from_table::("Equipements", None).unwrap(); // // Follow up by parsing this deserialisation by a transformation into the right intermediate representation // let intermediate_deserialisation = initial_deserialisation.into_iter().map(InnerEquipementStats::try_from).collect::>(); // // // Inspect the sucesses/filures // // let f = intermediate_deserialisation.iter().fold((0, 0), |val, res| (val.0 + res.is_ok() as usize, val.1 + 1_usize)); // // println!("Succeded in parsing {}/{}", f.0, f.1); // // println!("Final data {:#?}", intermediate_deserialisation); // // println!("Failed to parse: {:#?}", intermediate_deserialisation.into_iter().filter_map(|v| v.err()).collect::>());