diff --git a/Cargo.toml b/Cargo.toml
index f6e0776..e71620f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,6 +7,9 @@ members = [ "cli_parser", "config", "graphs", "make",
]
resolver = "3"
+[workspace.package]
+version = "0.2.0"
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.dev]
diff --git a/README.md b/README.md
index 0229a44..64c2c63 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
+  
+
# ravenous-tools
Set of tools to handle ravenous rulebook creation
# Installation
Now depends on libsqlite3-dev and sqlite3
-A bundled implementation should be added
+A bundled implementation should be added on all releases
diff --git a/badges/coverage.svg b/badges/coverage.svg
new file mode 100644
index 0000000..d621d76
--- /dev/null
+++ b/badges/coverage.svg
@@ -0,0 +1 @@
+
diff --git a/badges/test.svg b/badges/test.svg
new file mode 100644
index 0000000..3a9c483
--- /dev/null
+++ b/badges/test.svg
@@ -0,0 +1 @@
+
diff --git a/badges/version.svg b/badges/version.svg
new file mode 100644
index 0000000..a22915f
--- /dev/null
+++ b/badges/version.svg
@@ -0,0 +1 @@
+
diff --git a/weaponry/src/weaponry_structs/equipement_advanced_repr.rs b/weaponry/src/weaponry_structs/equipement_advanced_repr.rs
index cb4ffe1..3213d7e 100644
--- a/weaponry/src/weaponry_structs/equipement_advanced_repr.rs
+++ b/weaponry/src/weaponry_structs/equipement_advanced_repr.rs
@@ -14,7 +14,7 @@ use std::fmt::Display;
use crate::interfaces::RefinedList;
use probability::prelude::{Binomial, Discrete};
-use strum::{EnumIter, IntoEnumIterator};
+use strum::{Display, EnumIter, IntoEnumIterator};
use super::{Equipement, InitialEquipementList, equipement_structs::InnerEquipementStats};
@@ -111,8 +111,26 @@ impl DamageMatrix {
impl Display for DamageMatrix {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- let _ = f;
- todo!()
+ // "[{:.3}:{:.3}] {:5.2}", dices, precision,
+ write!(
+ f,
+ "{}",
+ DiceNumber::iter()
+ .map(|dices| {
+ Precision::iter()
+ .map(move |precision| format!("{:5.2}", self.get_damage(precision, dices)))
+ .fold(format!("[{:.3}]", dices.to_string()), |res, new| {
+ res + " " + &new
+ })
+ })
+ .fold(
+ Precision::iter().fold(String::from(" D\\P "), |res, new| format!(
+ "{} [{:.3}]",
+ res, new
+ )),
+ |res, new| res + "\n" + &new
+ )
+ )
}
}
@@ -121,11 +139,11 @@ impl From<&InnerEquipementStats> for DamageMatrix {
// let binomial_distribution = Binomial::new(dices, value.precision);
// binomial_distribution.mass(i) // -> The chance to have this number of success
DamageMatrix {
- damage_matrix: (Precision::iter()
- .flat_map(|precision| {
- DiceNumber::iter()
- .map(move |dices| {
- binomial_dice_distribution(value, precision.value(), dices.value())
+ damage_matrix: (DiceNumber::iter()
+ .flat_map(|dices| {
+ Precision::iter()
+ .map(move |prec| {
+ binomial_dice_distribution(value, prec.value(), dices.value())
})
.collect::>()
})
@@ -136,15 +154,12 @@ impl From<&InnerEquipementStats> for DamageMatrix {
/// Calculate the binomial distribution and average the damage from there
fn binomial_dice_distribution(value: &InnerEquipementStats, precision: usize, dices: usize) -> f64 {
- let p = ((precision as i8 + value.precision) as f64 / 10.).clamp(0., 1. - 1E-10);
- // println!("precision: {},{}", p, 9.99999);
+ let p = ((precision as i8 + value.precision) as f64 / 10.).clamp(0. + 1E-10, 1. - 1E-10);
let binomial = Binomial::new(dices, p);
(0..dices + 1)
.map(|target_dices| {
- // TODO: This non rounding can be veird
let probability_success = binomial.mass(target_dices); // Let's have weird half dices as usize;
- println!("probability : {:?}", probability_success);
if target_dices >= 1 {
(value.damage as f64
+ value.p_damage as f64
@@ -158,7 +173,7 @@ fn binomial_dice_distribution(value: &InnerEquipementStats, precision: usize, di
}
/// The precision infered for a damage calculation event
-#[derive(EnumIter, Clone, Copy)]
+#[derive(EnumIter, Clone, Copy, Display)]
#[allow(clippy::missing_docs_in_private_items)]
pub enum Precision {
High,
@@ -167,12 +182,12 @@ pub enum Precision {
}
/// The number of dices rolled for a damage simulation
-#[derive(EnumIter, Clone, Copy)]
+#[derive(EnumIter, Clone, Copy, Display)]
#[allow(clippy::missing_docs_in_private_items)]
pub enum DiceNumber {
- High,
- Medium,
- Low,
+ Many,
+ Average,
+ Few,
}
impl Precision {
@@ -191,9 +206,9 @@ impl DiceNumber {
/// Associate a value to the different values
fn value(&self) -> usize {
match self {
- DiceNumber::High => 7,
- DiceNumber::Medium => 5,
- DiceNumber::Low => 3,
+ DiceNumber::Many => 7,
+ DiceNumber::Average => 5,
+ DiceNumber::Few => 3,
}
}
}
@@ -217,7 +232,7 @@ mod test {
let mat: DamageMatrix = DamageMatrix::from(&damage);
println!("{:#?}", damage);
println!("{:#?}", mat);
- panic!()
+ println!("{}", mat);
}
#[test]