Work on scenario

This commit is contained in:
Dandaedre 2025-02-21 18:55:26 +01:00
parent bb3041ed8d
commit 7f98215bc2
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
5 changed files with 24 additions and 8 deletions

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 16%"><title>test-coverage: 16%</title><linearGradient id="bms-e68af986cf1a8ea6" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-e68af986cf1a8ea6"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-e68af986cf1a8ea6)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#e05d44"/><rect width="122" height="18" fill="url(#bms-e68af986cf1a8ea6)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">16%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">16%</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 17%"><title>test-coverage: 17%</title><linearGradient id="bms-986ff3b3470c1920" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-986ff3b3470c1920"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-986ff3b3470c1920)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#e05d44"/><rect width="122" height="18" fill="url(#bms-986ff3b3470c1920)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">17%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">17%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -4,15 +4,19 @@
//!
//!
use std::path::Path;
// TODO : All of these should likely be in the prelude if used like this
use weaponry::interfaces::{Reportable, Scenario};
use weaponry::interfaces::{Reportable, Scenario, ToCSV};
use weaponry::weaponry_structs::CrossRecipeScenario;
use weaponry::weaponry_structs::equipement_scenario::ConfigMock;
// use weaponry::interfaces::
fn main() {
let s = CrossRecipeScenario::new_with_config(ConfigMock {}).unwrap();
let re = s.generate_refined_recipes().unwrap();
println!("{}", re.get_report(Some("Refined List")));
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

View File

@ -84,9 +84,11 @@ impl Default for RefinedEquipementList {
}
/// The list of advanced stats infered from an Equipement
// TODO: The two philosophies to drop the old inner or convert the useful fields are considered right now
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
#[derive(Serialize)]
pub struct AdvancedStats {
display_name: String,
damage_per_attack: f64,
damage_per_turn: f64,
damage_per_action: f64,
@ -104,6 +106,7 @@ impl From<&InnerEquipementStats> for AdvancedStats {
(value.damage + value.p_damage * (value.rmax.saturating_sub(1))) as f64;
let armor_break_per_attack = (value.armor_break as f64).min(damage_per_attack);
Self {
display_name: value.name.join(" "),
damage_per_attack,
damage_per_turn: damage_per_attack * 2.,
damage_per_action: damage_per_attack / (value.action_cost as f64),
@ -139,7 +142,12 @@ impl Serialize for DamageMatrix {
where
S: serde::Serializer,
{
serializer.serialize_str(&format!("[{:?}]", self.damage_matrix))
// TODO: Not sure of the right way to do this
// serializer.serialize_str(&format!("[{:?}]", self.damage_matrix))
serializer.serialize_str(&format!(
"{:?}",
self.damage_matrix.iter().sum::<f64>() / self.damage_matrix.len() as f64
))
}
}

View File

@ -9,6 +9,7 @@
#![allow(dead_code)]
#[allow(unused_imports)]
use crate::interfaces::Reportable;
use crate::weaponry_structs::InitialEquipementList;
use crate::weaponry_structs::equipement_structs::DatabaseEquipementStats;
@ -96,6 +97,7 @@ impl Scenario for CrossRecipeScenario {
let eq_shape = deserde_into_equipement!(self.database, "Shape", EqShape);
let eq_material = deserde_into_equipement!(self.database, "Materials", EqMaterial);
let eq_nature = deserde_into_equipement!(self.database, "Nature", EqNature);
#[allow(unused_variables)]
let eq_finishing = deserde_into_equipement!(self.database, "Finishing", EqFinishing);
// println!(

View File

@ -283,12 +283,14 @@ mod test {
#[test]
fn test_creating_all_equipements() {
let shape = vec![EqShape::default().into(), EqShape::default().into()];
let nature = vec![EqNature::default().into(), EqNature::default().into()];
// Commented because of the generic nature and the from not a tryfrom
// TODO: Reinstate this part
// let nature = vec![EqNature::default().into(), EqNature::default().into()];
let material = vec![EqMaterial::default().into(), EqMaterial::default().into()];
let finishing = vec![EqFinishing::default().into(), EqMaterial::default().into()];
let mut leq = InitialEquipementList::from_vectored(shape);
leq.combine_all(&InitialEquipementList::from_vectored(nature));
// leq.combine_all(&InitialEquipementList::from_vectored(nature));
leq.combine_all(&InitialEquipementList::from_vectored(material));
leq.combine_all(&InitialEquipementList::from_vectored(finishing));
}