Compare commits
2 Commits
main
...
complexity
| Author | SHA1 | Date |
|---|---|---|
|
|
bb6ab0fa6f | |
|
|
bcc0c814c5 |
|
|
@ -14,7 +14,7 @@ pub struct GraphConfig {
|
||||||
pub target: GraphTargetType,
|
pub target: GraphTargetType,
|
||||||
|
|
||||||
/// Alternative origin
|
/// Alternative origin
|
||||||
#[arg(short, long, default_value = "Images/Radar/radar.csv")]
|
#[arg(short, long, default_value = "Ecoles")]
|
||||||
pub origin: String,
|
pub origin: String,
|
||||||
|
|
||||||
/// Alternative destination
|
/// Alternative destination
|
||||||
|
|
@ -87,24 +87,30 @@ pub struct FinalClassRadar {
|
||||||
/// The ability to deal damage.
|
/// The ability to deal damage.
|
||||||
#[serde(rename = "Dégats")]
|
#[serde(rename = "Dégats")]
|
||||||
pub damage: f64,
|
pub damage: f64,
|
||||||
/// The ability to move.
|
// /// The ability to move.
|
||||||
#[serde(rename = "Mobilité")]
|
// Mobility is merged with survivability & QoL
|
||||||
pub mobility: f64,
|
// #[serde(rename = "Mobilité")]
|
||||||
/// The ability to inflict state alterations.
|
// pub mobility: f64,
|
||||||
#[serde(rename = "Altérations")]
|
// /// The ability to inflict state alterations.
|
||||||
pub alterations: f64,
|
// Altérations is now merged with damage
|
||||||
/// The armor break of the class
|
// #[serde(rename = "Altérations")]
|
||||||
#[serde(rename = "Brise-Armure")]
|
// pub alterations: f64,
|
||||||
pub armorbreak: f64,
|
|
||||||
/// The ability to provide support.
|
/// The ability to provide support.
|
||||||
#[serde(rename = "Support")]
|
#[serde(rename = "Support")]
|
||||||
pub support: f64,
|
pub support: f64,
|
||||||
/// The ability to inflict crowd control.
|
/// The ability to inflict crowd control.
|
||||||
#[serde(rename = "C.C")]
|
#[serde(rename = "C.C")]
|
||||||
pub cc: f64,
|
pub cc: f64,
|
||||||
/// The ability to improve quality of life.
|
// /// The ability to improve quality of life.
|
||||||
#[serde(rename = "QoL")]
|
// QoL is part of complexity
|
||||||
pub qol: f64,
|
// #[serde(rename = "QoL")]
|
||||||
|
// pub qol: f64,
|
||||||
|
/// The armor break of the class
|
||||||
|
#[serde(rename = "Brise-Armure")]
|
||||||
|
pub armorbreak: f64,
|
||||||
|
/// The complexity to play the class
|
||||||
|
#[serde(rename = "Complexité")]
|
||||||
|
pub complexity: f64,
|
||||||
// / The class complexity
|
// / The class complexity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,6 +133,8 @@ pub struct LoadedClassRadar {
|
||||||
pub cc: f64,
|
pub cc: f64,
|
||||||
/// The ability to improve quality of life.
|
/// The ability to improve quality of life.
|
||||||
pub qol: f64,
|
pub qol: f64,
|
||||||
|
/// The class complexity
|
||||||
|
pub complexity: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the categories to load from the tables
|
/// All the categories to load from the tables
|
||||||
|
|
@ -162,6 +170,8 @@ pub struct RawRow {
|
||||||
pub qol: String,
|
pub qol: String,
|
||||||
/// The ability to break armor.
|
/// The ability to break armor.
|
||||||
pub armorbreak: String,
|
pub armorbreak: String,
|
||||||
|
/// The complexity of the skill
|
||||||
|
pub complexity: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RawRow> for LoadedClassRadar {
|
impl From<RawRow> for LoadedClassRadar {
|
||||||
|
|
@ -175,6 +185,7 @@ impl From<RawRow> for LoadedClassRadar {
|
||||||
cc: value.cc.parse().unwrap_or(0.0),
|
cc: value.cc.parse().unwrap_or(0.0),
|
||||||
qol: value.qol.parse().unwrap_or(0.0),
|
qol: value.qol.parse().unwrap_or(0.0),
|
||||||
armorbreak: value.armorbreak.parse().unwrap_or(0.0),
|
armorbreak: value.armorbreak.parse().unwrap_or(0.0),
|
||||||
|
complexity: value.complexity.parse().unwrap_or(0.0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,6 +203,7 @@ impl Add for LoadedClassRadar {
|
||||||
cc: self.cc + rhs.cc,
|
cc: self.cc + rhs.cc,
|
||||||
qol: self.qol + rhs.qol,
|
qol: self.qol + rhs.qol,
|
||||||
armorbreak: self.armorbreak + rhs.armorbreak,
|
armorbreak: self.armorbreak + rhs.armorbreak,
|
||||||
|
complexity: self.complexity + rhs.complexity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,31 +211,49 @@ impl Add for LoadedClassRadar {
|
||||||
impl FinalClassRadar {
|
impl FinalClassRadar {
|
||||||
/// A very wastful (but simple) way to only add the max value
|
/// A very wastful (but simple) way to only add the max value
|
||||||
pub fn find_max(self, rhs: &Self) -> Self {
|
pub fn find_max(self, rhs: &Self) -> Self {
|
||||||
|
// Self {
|
||||||
|
// survivability: self.survivability.max(rhs.survivability),
|
||||||
|
// damage: self.damage.max(rhs.damage),
|
||||||
|
// mobility: self.mobility.max(rhs.mobility),
|
||||||
|
// alterations: self.alterations.max(rhs.alterations),
|
||||||
|
// support: self.support.max(rhs.support),
|
||||||
|
// cc: self.cc.max(rhs.cc),
|
||||||
|
// qol: self.qol.max(rhs.qol),
|
||||||
|
// armorbreak: self.armorbreak.max(rhs.armorbreak),
|
||||||
|
// name: self.name,
|
||||||
|
// }
|
||||||
Self {
|
Self {
|
||||||
|
name: self.name,
|
||||||
survivability: self.survivability.max(rhs.survivability),
|
survivability: self.survivability.max(rhs.survivability),
|
||||||
damage: self.damage.max(rhs.damage),
|
damage: self.damage.max(rhs.damage),
|
||||||
mobility: self.mobility.max(rhs.mobility),
|
|
||||||
alterations: self.alterations.max(rhs.alterations),
|
|
||||||
support: self.support.max(rhs.support),
|
support: self.support.max(rhs.support),
|
||||||
cc: self.cc.max(rhs.cc),
|
cc: self.cc.max(rhs.cc),
|
||||||
qol: self.qol.max(rhs.qol),
|
|
||||||
armorbreak: self.armorbreak.max(rhs.armorbreak),
|
armorbreak: self.armorbreak.max(rhs.armorbreak),
|
||||||
name: self.name,
|
complexity: self.complexity.max(rhs.complexity),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a class from a loaded categories
|
/// Create a class from a loaded categories
|
||||||
pub fn from_radar_with_name(name: String, categorie: LoadedClassRadar) -> Self {
|
pub fn from_radar_with_name(name: String, categorie: LoadedClassRadar) -> Self {
|
||||||
|
// Self {
|
||||||
|
// name,
|
||||||
|
// survivability: categorie.survivability,
|
||||||
|
// damage: categorie.damage,
|
||||||
|
// mobility: categorie.mobility,
|
||||||
|
// alterations: categorie.alterations,
|
||||||
|
// support: categorie.support,
|
||||||
|
// cc: categorie.cc,
|
||||||
|
// qol: categorie.qol,
|
||||||
|
// armorbreak: categorie.armorbreak,
|
||||||
|
// }
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
survivability: categorie.survivability,
|
survivability: (categorie.survivability + categorie.mobility / 2.) / 1.5,
|
||||||
damage: categorie.damage,
|
damage: (categorie.damage + categorie.alterations) / 2.,
|
||||||
mobility: categorie.mobility,
|
|
||||||
alterations: categorie.alterations,
|
|
||||||
support: categorie.support,
|
support: categorie.support,
|
||||||
cc: categorie.cc,
|
cc: categorie.cc,
|
||||||
qol: categorie.qol,
|
|
||||||
armorbreak: categorie.armorbreak,
|
armorbreak: categorie.armorbreak,
|
||||||
|
complexity: (categorie.complexity),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ fn del_graphs(args: &GraphConfig) -> Result<()> {
|
||||||
fn load_graph(args: &GraphConfig) -> Result<()> {
|
fn load_graph(args: &GraphConfig) -> Result<()> {
|
||||||
let _ = args;
|
let _ = args;
|
||||||
// load_categories_from_tsv("./test.csv")?;
|
// load_categories_from_tsv("./test.csv")?;
|
||||||
generate_csv()?;
|
generate_csv(&args)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
///Generate the graph and save it
|
///Generate the graph and save it
|
||||||
|
|
@ -114,11 +114,11 @@ fn gen_graph(args: &GraphConfig) -> Result<()> {
|
||||||
|
|
||||||
println!("Writing to {}", path_svg);
|
println!("Writing to {}", path_svg);
|
||||||
let context = r.svg().context("Converting to SVG")?;
|
let context = r.svg().context("Converting to SVG")?;
|
||||||
f.write_all(context.as_bytes())?;
|
f.write_all(context.as_bytes()).context("Writing SVG")?;
|
||||||
|
|
||||||
let png = svg_to_png_with_size(&context, Some(860), Some(560)).context("Writing png")?;
|
let png = svg_to_png_with_size(&context, Some(980), Some(560)).context("Creating PNG")?;
|
||||||
let mut f = File::create(path_png)?;
|
let mut f = File::create(path_png)?;
|
||||||
f.write_all(&png).context("Writing png")?;
|
f.write_all(&png).context("Writing PNG")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -128,15 +128,15 @@ fn import_csv(args: &GraphConfig) -> Result<GraphValues> {
|
||||||
let file = File::open(&args.origin)
|
let file = File::open(&args.origin)
|
||||||
.context("Opening the radar file")
|
.context("Opening the radar file")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let rdr = csv::ReaderBuilder::new().from_reader(file);
|
cleanup_csv(csv::ReaderBuilder::new().from_reader(file))
|
||||||
|
|
||||||
cleanup_csv(rdr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate the csv from all the classes
|
/// Generate the csv from all the classes
|
||||||
fn generate_csv() -> Result<()> {
|
fn generate_csv(args: &GraphConfig) -> Result<()> {
|
||||||
// Acquire the data from all classes
|
// Acquire the data from all classes
|
||||||
let list_class = list_dir("Tables/??? - *.tsv");
|
let list_class = list_dir(&format!("{}/??? - *.tsv", args.origin));
|
||||||
|
|
||||||
|
println!("{:?}", list_class);
|
||||||
let mut final_class_list = Vec::with_capacity(list_class.len() + 1);
|
let mut final_class_list = Vec::with_capacity(list_class.len() + 1);
|
||||||
// Very ugly space reservation for the last operation, need to check if no way of skipping an element is possible
|
// Very ugly space reservation for the last operation, need to check if no way of skipping an element is possible
|
||||||
final_class_list.push(FinalClassRadar::default());
|
final_class_list.push(FinalClassRadar::default());
|
||||||
|
|
@ -149,8 +149,8 @@ fn generate_csv() -> Result<()> {
|
||||||
.context("Generating new name")?[12..]
|
.context("Generating new name")?[12..]
|
||||||
.strip_suffix(".tsv")
|
.strip_suffix(".tsv")
|
||||||
.context("Stripping extention")?;
|
.context("Stripping extention")?;
|
||||||
let categories =
|
let categories = load_categories_from_tsv(single_class.clone())
|
||||||
load_categories_from_tsv(single_class.clone()).context("Loading from csv")?;
|
.context(format!("Loading class {:?} from it's tsv", &single_class))?;
|
||||||
final_class_list.push(FinalClassRadar::from_radar_with_name(
|
final_class_list.push(FinalClassRadar::from_radar_with_name(
|
||||||
class_name.to_string(),
|
class_name.to_string(),
|
||||||
categories,
|
categories,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue