database_monsters #157
12
Cargo.toml
12
Cargo.toml
|
|
@ -6,7 +6,7 @@ resolver = "3"
|
|||
# edition = "2024"
|
||||
# license = "MIT OR Apache-2.0"
|
||||
[workspace.package]
|
||||
version = "0.3.20"
|
||||
version = "0.3.21"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
@ -30,6 +30,16 @@ codegen-units = 256
|
|||
incremental = true
|
||||
panic = "abort"
|
||||
|
||||
# [profile.dev-analysis]
|
||||
# inherits = "dev"
|
||||
# opt-level = 0
|
||||
# debug = 0
|
||||
# strip = "none"
|
||||
# lto = false
|
||||
# # codegen-units = 256
|
||||
# incremental = true
|
||||
# # codegen-backend = "cranelift"
|
||||
|
||||
[workspace.dependencies]
|
||||
config = {path = "./crates/config"}
|
||||
tablegen = {path = "./crates/tablegen"}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ fn init_graph_config(_args: &GraphConfig) -> Result<()> {
|
|||
/// Load the config if given of the default config if none
|
||||
fn load_graph_config(args: &GraphConfig) -> Result<MiniTheme> {
|
||||
if let Some(c) = &args.config {
|
||||
println!("[INFO] Reading config {}", &c);
|
||||
println!("[INFO] Reading config {}", c);
|
||||
let mut f = File::open(c).context("Opening config")?;
|
||||
let mut buf = String::new();
|
||||
f.read_to_string(&mut buf).context("Reading the config")?;
|
||||
|
|
@ -104,8 +104,8 @@ fn gen_graph(args: &GraphConfig) -> Result<()> {
|
|||
let cfg = load_graph_config(args)?;
|
||||
|
||||
for graph in csv.values {
|
||||
let path_svg = format!("{}/{}.svg", args.destination, &graph.name);
|
||||
let path_png = format!("{}/{}.png", args.destination, &graph.name);
|
||||
let path_svg = format!("{}/{}.svg", args.destination, graph.name);
|
||||
let path_png = format!("{}/{}.png", args.destination, graph.name);
|
||||
println!("[INFO] Processing {}", path_svg);
|
||||
|
||||
let mut f = File::create(&path_svg)?;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ pub(super) fn make_file(args: &MakeConfig) -> BuilderParseResult {
|
|||
}
|
||||
|
||||
BuilderParseResult {
|
||||
new_name: format!("{:?}", &path),
|
||||
new_name: format!("{:?}", path),
|
||||
chapt_list: chapters,
|
||||
}
|
||||
}
|
||||
|
|
@ -301,9 +301,9 @@ pub(super) fn make_clean(args: &MakeConfig) {
|
|||
for s in list_suff {
|
||||
// The most ghetto *** I've done so far
|
||||
// cmd.arg(format!("{}{}", &target, s));
|
||||
cmd.arg(format!("{}_build{}", &target, s));
|
||||
cmd.arg(format!("{}_build{}", target, s));
|
||||
}
|
||||
cmd.arg(format!("{}_build{}", &target, ".tex"));
|
||||
cmd.arg(format!("{}_build{}", target, ".tex"));
|
||||
// println!("{:?}", cmd);
|
||||
if let Err(e) = cmd.output() {
|
||||
println!(
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub fn monsters_dispatch(args: &MonsterConfig, config: &Config) -> Result<()> {
|
|||
// MonsterTarget::Show => unimplemented!("implement show logic"),
|
||||
MonsterTarget::Balance(ref args) => {
|
||||
let connection = Connection::open(&args.db.database)
|
||||
.context(format!("Opening database {}", &args.db.database))?;
|
||||
.context(format!("Opening database {}", args.db.database))?;
|
||||
show_balancing_data(args, config, connection)?
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,35 +61,20 @@ pub fn attack_player(
|
|||
} + victim.specialty_def;
|
||||
|
||||
let bin = helpers::binomial_dice_distribution(threshold, victim.successes_def);
|
||||
// let successes_left = attack.successes - thld(victim.successes_def, threshold);
|
||||
let avg_successes_left: f64 = bin
|
||||
.iter()
|
||||
.map(|(dice, p)| (attack.successes - dice) as f64 * p)
|
||||
.sum::<f64>();
|
||||
// TODO : Pretty sure
|
||||
// / bin.len() as f64;
|
||||
let avg_damage_incomming: f64 = bin
|
||||
.iter()
|
||||
.map(|(dices, p)| {
|
||||
helpers::how_much_with_succeses(&attack.damage, attack.successes - dices) as f64 * p
|
||||
})
|
||||
.sum::<f64>();
|
||||
// / bin.len() as f64;
|
||||
|
||||
// println!(
|
||||
// "{} DMG:{:?} {:.2?} Left[{avg_successes_left:.2}/{} with {}] = {avg_damage_incomming}",
|
||||
// attack.name, attack.damage, bin, attack.successes, victim.successes_def
|
||||
// );
|
||||
// let mut damage_incoming = how_much_with_succeses(&attack.damage, successes_left);
|
||||
let damage_incoming = avg_damage_incomming;
|
||||
let damage_tanked = (damage_incoming - (victim.protection + victim.strength) as f64).max(0.0);
|
||||
let armor_loss =
|
||||
(damage_incoming - victim.protection as f64).clamp(0.0, attack.armor_break as f64);
|
||||
// if avg_successes_left < 0.0 {
|
||||
// damage_incoming = 0.0;
|
||||
// damage_tanked = 0.0;
|
||||
// armor_loss = 0.0;
|
||||
// }
|
||||
let report = DamageReport {
|
||||
damage_incoming,
|
||||
damage_tanked,
|
||||
|
|
@ -105,7 +90,7 @@ pub fn attack_player(
|
|||
player_health: victim.health,
|
||||
player_integrity: victim.integrity,
|
||||
threshold,
|
||||
attack_successes: attack.fatigue,
|
||||
attack_successes: attack.successes,
|
||||
mode,
|
||||
showcase,
|
||||
fatigue: attack.fatigue,
|
||||
|
|
|
|||
|
|
@ -216,12 +216,12 @@ pub struct DefenseReport {
|
|||
pub damage_per_turn_p1: f64,
|
||||
/// (Actual) Turns needed to reach phase 2.
|
||||
/// Computed from the monster’s health and damage output or from simulation data.
|
||||
#[INTEGER(name = "P1 🠲 P2")]
|
||||
#[REAL(name = "P1 🠲 P2")]
|
||||
pub time_to_p2: f64,
|
||||
/// (Goal) Desired turns to reach phase 2.
|
||||
/// If the current `time_to_p2` exceeds this value, the fight is considered inefficient.
|
||||
#[SKIP]
|
||||
pub time_to_p2_target: i64,
|
||||
pub time_to_p2_target: f64,
|
||||
/// Damage per turn while in phase 2.
|
||||
#[INTEGER(name = "DPT P2")]
|
||||
pub damage_per_turn_p2: f64,
|
||||
|
|
@ -232,14 +232,14 @@ pub struct DefenseReport {
|
|||
/// (Goal) Desired turns to kill the monster.
|
||||
/// If actual `time_to_kill` is larger, you may need to adjust attack power or strategy.
|
||||
#[SKIP]
|
||||
pub time_to_kill_target: i64,
|
||||
pub time_to_kill_target: f64,
|
||||
/// (Goal) Desired turns until the monster’s armor breaks.
|
||||
/// A lower value indicates a more aggressive strategy.
|
||||
#[SKIP(name = "ttAB")]
|
||||
pub time_to_armorbreak_target: i64,
|
||||
pub time_to_armorbreak_target: f64,
|
||||
/// (Goal) Average turns to kill a single player
|
||||
#[SKIP(name = "ttPK")]
|
||||
pub time_to_player_kill: i64,
|
||||
pub time_to_player_kill: f64,
|
||||
/// (Fixed) The number of monsters in a single group.
|
||||
/// Usually `1`, but can be > 1 for bosses that spawn multiple instances.
|
||||
#[SKIP]
|
||||
|
|
|
|||
|
|
@ -219,8 +219,8 @@ impl DamageCategory {
|
|||
pub fn from_percent(percent: f64) -> Self {
|
||||
match percent {
|
||||
..0.01 => Self::None,
|
||||
0.01..0.15 => Self::Chip,
|
||||
0.15..0.5 => Self::Moderate,
|
||||
0.01..0.25 => Self::Chip,
|
||||
0.25..0.5 => Self::Moderate,
|
||||
0.5..0.8 => Self::High,
|
||||
0.8..1.0 => Self::NearDeath,
|
||||
1.0..1.5 => Self::Kill,
|
||||
|
|
|
|||
|
|
@ -64,14 +64,14 @@ pub fn generate_monsters_tex(
|
|||
if args.player || args.all {
|
||||
println!("Generating Player Bestiaire");
|
||||
let path = format!("./{}/player_bestiaire.tex", args.destination);
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", &path))?;
|
||||
write!(f, "{}", p_out).context(format!("Writing {}", &path))?;
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
||||
write!(f, "{}", p_out).context(format!("Writing {}", path))?;
|
||||
}
|
||||
if args.master || args.all {
|
||||
println!("Generating Master Bestiaire");
|
||||
let path = format!("./{}/master_bestiaire.tex", args.destination);
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", &path))?;
|
||||
write!(f, "{}", m_out).context(format!("Writing {}", &path))?;
|
||||
let mut f = File::create(&path).context(format!("Opening file {}", path))?;
|
||||
write!(f, "{}", m_out).context(format!("Writing {}", path))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,19 +249,15 @@ impl ToRow for DefenseReport {
|
|||
format!("{:.1?}/{}", self.armor_break_per_turn, self.integrity_p1)
|
||||
.to_cell()
|
||||
.fg(Color::DarkGrey),
|
||||
compare_vals(
|
||||
"t",
|
||||
self.time_to_armorbreak,
|
||||
self.time_to_armorbreak_target as f64,
|
||||
),
|
||||
compare_vals("t", self.time_to_armorbreak, self.time_to_armorbreak_target),
|
||||
format!("{:.1?}/{}", self.damage_per_turn_p1, self.health_p1)
|
||||
.to_cell()
|
||||
.fg(Color::DarkGrey),
|
||||
compare_vals("t", self.time_to_p2, self.time_to_p2_target as f64),
|
||||
compare_vals("t", self.time_to_p2, self.time_to_p2_target),
|
||||
format!("{:.1?}/{}", self.damage_per_turn_p2, self.health_p2)
|
||||
.to_cell()
|
||||
.fg(Color::DarkGrey),
|
||||
compare_vals("t", self.time_to_kill, self.time_to_kill_target as f64),
|
||||
compare_vals("t", self.time_to_kill, self.time_to_kill_target),
|
||||
format!(
|
||||
"[{:.0} & {:.0}] ⇝ {}",
|
||||
self.damage_through_p1,
|
||||
|
|
|
|||
|
|
@ -420,18 +420,18 @@ pub struct CreatureBalancing {
|
|||
#[TEXT]
|
||||
/// (Fixed) HSE profile of the monster (see `ProfileHSE`).
|
||||
pub profile_hse: ProfileHSE,
|
||||
#[INTEGER]
|
||||
#[REAL]
|
||||
/// (Goal) Turns needed to reach phase 2.
|
||||
pub time_to_p2: i64,
|
||||
#[INTEGER]
|
||||
pub time_to_p2: f64,
|
||||
#[REAL]
|
||||
/// (Goal) Turns needed to kill from phase 2.
|
||||
pub time_to_kill: i64,
|
||||
#[INTEGER]
|
||||
pub time_to_kill: f64,
|
||||
#[REAL]
|
||||
/// (Goal) Turns until the monster’s armor breaks.
|
||||
pub time_to_armorbreak: i64,
|
||||
#[INTEGER]
|
||||
pub time_to_armorbreak: f64,
|
||||
#[REAL]
|
||||
/// (GOAL) Avg. turns to kill a single target.
|
||||
pub time_to_player_kill: i64,
|
||||
pub time_to_player_kill: f64,
|
||||
#[REAL]
|
||||
/// (FIXED) Size of a single monster group (usually one).
|
||||
pub monster_groupsize: f64,
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ impl WriteTable for ClassesArray {
|
|||
continue;
|
||||
}
|
||||
if lvl != 0 {
|
||||
writeln!(buffer, "{}", &config.classes.sep)?;
|
||||
writeln!(buffer, "{}", config.classes.sep)?;
|
||||
}
|
||||
writeln!(buffer, "{}", formatted_tier)?;
|
||||
for elem in tier {
|
||||
|
|
|
|||
|
|
@ -34,5 +34,8 @@ rayon = "1.12.0"
|
|||
name = "iter_creation"
|
||||
harness = false
|
||||
|
||||
[features]
|
||||
dev-analysis = [] # gate for the feature flag
|
||||
|
||||
# [lints.rust]
|
||||
# unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ where
|
|||
|
||||
/// Generate a SELECT query with fields generated from a struct. Returns a SQL request as a String
|
||||
#[inline]
|
||||
#[coverage(off)] // INCORRECT: Error with line report
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // INCORRECT: Error with line report
|
||||
fn generate_select_query<T: more_fields::FieldsAsSlice>(
|
||||
table_name: &str,
|
||||
filter: Option<&str>,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ where
|
|||
/// A blanket implementation giving all combinaisons of recipes with another RecipeCollection
|
||||
///
|
||||
/// This method doesn't make use of parallel iterators as the workload is way faster than would be the memory dispatch
|
||||
#[coverage(off)] // Tarpaulin cannot deal with iter and long lines
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // Tarpaulin cannot deal with iter and long lines
|
||||
fn combine_all<G>(&mut self, other: &G)
|
||||
where
|
||||
G: RecipeCollection<Recipes = Self::Recipes>,
|
||||
|
|
@ -96,7 +96,7 @@ where
|
|||
fn from_vectored(list: Vec<Self::Recipes>) -> Self;
|
||||
|
||||
/// Create a collection from an iterator of intermediate values T
|
||||
#[coverage(off)] // INCORRECT: Error with line report
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // INCORRECT: Error with line report
|
||||
fn from_iter_intermediate<T>(
|
||||
iter_inter: impl Iterator<Item = Result<T, FatalEquipementError>>,
|
||||
) -> Result<Self, FatalEquipementError>
|
||||
|
|
@ -233,7 +233,7 @@ pub trait RecipeDatabase {
|
|||
}
|
||||
|
||||
/// Insert a row inside the database, while mostly unused this function is needed to initialize the empty table with an empty row if needed
|
||||
#[coverage(off)] // INCORRECT: Error with line report
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // INCORRECT: Error with line report
|
||||
fn insert_row<T: FieldsAsSlice + Serialize>(
|
||||
&self,
|
||||
table_name: &str,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
// File: weaponry/src/lib.rs
|
||||
//! Weaponry module, handling all weaponry creation and analysis
|
||||
|
||||
#![feature(coverage_attribute)]
|
||||
// #![feature(int_roundings)]
|
||||
#![cfg_attr(feature = "dev-analysis", feature(coverage_attribute))]
|
||||
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
|
||||
#![feature(iter_intersperse)]
|
||||
// #![feature(iter_intersperse)]
|
||||
|
||||
pub mod analysis;
|
||||
mod database;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ impl Display for InnerEquipementStats {
|
|||
vec![
|
||||
self.special
|
||||
.iter()
|
||||
.intersperse(&",".to_string())
|
||||
// .intersperse(&",".to_string())
|
||||
.fold(String::new(), |res, new| format!("{}; {}", res, new)),
|
||||
],
|
||||
);
|
||||
|
|
@ -190,7 +190,7 @@ impl<T> Default for FilterFunction<T> {
|
|||
}
|
||||
}
|
||||
impl<T> PartialEq for FilterFunction<T> {
|
||||
// #[coverage(off)] // INCORRECT: Error with line report
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // INCORRECT: Error with line report
|
||||
fn eq(&self, _other: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ impl RecipeDatabase for EquipementDatabase {
|
|||
&self.conn
|
||||
}
|
||||
|
||||
#[coverage(off)] // INCORRECT: Error with line report
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // INCORRECT: Error with line report
|
||||
fn serialize_into_intermediate<T>(
|
||||
&self,
|
||||
table: &str,
|
||||
|
|
@ -132,7 +132,7 @@ impl TryFrom<DatabaseEquipementStats> for InnerEquipementStats {
|
|||
type SubCategories = (Option<WeaponBaseShape>, Option<WeaponBaseSize>);
|
||||
|
||||
/// Infer all subcategories from a deserialized DatabaseCategory
|
||||
#[coverage(off)] // A test would literally be a copy paste of this match
|
||||
#[cfg_attr(feature = "dev-analysis", coverage(off))] // A test would literally be a copy paste of this match
|
||||
fn get_sub_categories_from_serde(category: &str) -> Result<SubCategories, FatalEquipementError> {
|
||||
Ok(if let Some(category) = from_serde!(category)? {
|
||||
match category {
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ master_part = '''
|
|||
\SetCell{c} Res & \slash & \pierce & \blunt & \symceleste & \symfire & \symearth & \symwood & \symmagma & \symabyss & \symwater & \symwind & \symice & \symthunder \\
|
||||
\hline
|
||||
{{#each body_parts.body_parts}}
|
||||
\SetCell{font=\footnotesize} {{{body_part_name}}} & ${{{slash}}} $ & ${{{pierce}}} $ & ${{{blunt}}} $ & ${{{celestial}}} $ & ${{{fire}}} $ & ${{{earth}}} $ & ${{{wood}}} $ & ${{{magma}}} $ & ${{{celeste}}} $ & ${{{water}}} $ & ${{{wind}}} $ & ${{{ice}}} $ & ${{{thunder}}} $ \\
|
||||
\SetCell{font=\footnotesize} {{{body_part_name}}} & ${{{slash}}} $ & ${{{piercing}}} $ & ${{{blunt}}} $ & ${{{celestial}}} $ & ${{{fire}}} $ & ${{{earth}}} $ & ${{{wood}}} $ & ${{{magma}}} $ & ${{{celeste}}} $ & ${{{water}}} $ & ${{{wind}}} $ & ${{{ice}}} $ & ${{{thunder}}} $ \\
|
||||
{{/each}}
|
||||
\end{tblr}
|
||||
\end{center}
|
||||
|
|
@ -241,7 +241,7 @@ master_part = '''
|
|||
}
|
||||
& \SetCell[c=2]{c} P1 & & \SetCell[c=2]{c} P2 & & & \SetCell[c=7]{c} Stats & & & & & & & & \SetCell[c=4]{c} Mouvement & & & & & Extra & \\
|
||||
\cline{2-3} \cline{4-5} \cline{7-13} \cline{15-18} \cline{20-21}
|
||||
\rb{Initiative} & \rb{Valeur} & \rb{Actions} & \rb{Valeur} & \rb{Actions} & & \rb{Force} & \rb{Perception} & \rb{Volonté} & \rb{Res Alt} & \rb{Torque} & \rb{Vigilance} & \rb{Fatigue} & & \rb{Marche} & \rb{Trot} & \rb{Course} & \rb{Vol} & & \rb{Bon. Phy} {{#if elemental_bonus_dmg}}& \rb{Bon. Élém} {{/if}}\\
|
||||
\rb{Initiative} & \rb{Valeur} & \rb{Actions} & \rb{Valeur} & \rb{Actions} & & \rb{Force} & \rb{Perception} & \rb{Volonté} & \rb{Res Alt} & \rb{Torque} & \rb{Vigilance} & \rb{Fatigue} & & \rb{Marche} & \rb{Trot} & \rb{Course} & \rb{Vol} & & \rb{Bon. Phy} {{#if elemental_bonus}}& \rb{Bon. Élém} {{/if}}\\
|
||||
{{#each init_full}}
|
||||
{{#if @index}}
|
||||
\SetCell{font=\footnotesize} $t_{{(plus @index 1)}} $ & ${{{p1_value}}} $ & {{{pt1_actions}}} & ${{{p2_value}}} $ & {{{p2_actions}}} \\
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit b1532527561263e6ae23b8e5a0fe6d4acc52b553
|
||||
Subproject commit 2eb936d1b8b2f2fc897141b1d353692d1bc82476
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "nightly"
|
||||
channel = "stable"
|
||||
|
|
|
|||
Loading…
Reference in New Issue