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