database_monsters #133
|
|
@ -6,7 +6,7 @@ resolver = "3"
|
|||
# edition = "2024"
|
||||
# license = "MIT OR Apache-2.0"
|
||||
[workspace.package]
|
||||
version = "0.3.11"
|
||||
version = "0.3.13"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
|||
|
|
@ -1,113 +0,0 @@
|
|||
\begin{tblr}{
|
||||
vspan=even, hspan=minimal,
|
||||
colspec={X[-1] X[-1]},
|
||||
cell{1}{1}={c=2}{c},
|
||||
}
|
||||
|
||||
\includegraphics[height=5cm] ./bob.png & \\
|
||||
& \\
|
||||
Nom & Bobifron 3000 \\
|
||||
Dénomination & \\
|
||||
Calamité & Yanouïlle \\
|
||||
Niveau de danger (HSE) & 9001 \\
|
||||
& \\
|
||||
Habitat & \SetCell{font=\footnotesize} House \\
|
||||
Dysmorphisme & \SetCell{font=\footnotesize} \\
|
||||
Couleurs & \SetCell{font=\footnotesize} 7 \\
|
||||
Réaction à l'homme & \SetCell{font=\footnotesize} 8 \\
|
||||
Variantes & \SetCell{font=\footnotesize} 8\\
|
||||
Mœurs & \SetCell{font=\footnotesize} 9 \\
|
||||
\end{tblr}
|
||||
\vfill
|
||||
\begin{tblr}{
|
||||
colspec={X[-1]},
|
||||
hline{2,4,6},
|
||||
row{2,4,6}={font=\footnotesize}
|
||||
}
|
||||
\textbf{Description} \\
|
||||
9 \\
|
||||
\textbf{Annotations} \\
|
||||
8 \\
|
||||
\textbf{Récompenses} \\
|
||||
\end{tblr}
|
||||
\begin{tblr}{
|
||||
colspec={X[-1] X[-1,c] X[-1,j]},
|
||||
vspan=even, hspan=minimal,
|
||||
row{1-Z}={font=\footnotesize},
|
||||
rows={m},
|
||||
}
|
||||
\SetCell[c=2]{j} Sang (base, combat, dépeçage) & & 10, 5, 5 \\
|
||||
Larewoard & Reward & 4\blood{}, 4\Tox. Gives much love. \\
|
||||
\end{tblr}
|
||||
\vfill
|
||||
\begin{tblr}{
|
||||
colspec={X[l,-1] X[-1] X[-1] X[] X[] X[-1] X[-1] X[] X[]},
|
||||
rowspec={X[t] X[t,c] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[c,2em] X[j,5em]},
|
||||
hspan=minimal,
|
||||
cell{1}{2}={c=4}{c},
|
||||
cell{1}{6}={c=4}{c},
|
||||
row{2,12}={font=\footnotesize},
|
||||
vline{6} = {2-11}{solid},
|
||||
}
|
||||
& P1 & & & & P2 & \\
|
||||
& Seuil & Prot & Intégrité & PV & Seuil & Prot & Intégrité & PV\\
|
||||
\hline
|
||||
\SetCell{font=\footnotesize} VV & $1$ & $2$ & \SetCell{r,f}\tiny$3$ & \SetCell{r,f}\tiny$4$ & $5$ & $6$ & \SetCell{r,f}\tiny$7$ & \SetCell{r,f}\tiny$8$\\ \hline
|
||||
\SetCell[c=9]{j,h} {\textbf{Notes} \\ \\
|
||||
\hline
|
||||
\end{tblr} \center{
|
||||
\begin{tblr}{
|
||||
colspec={Q[3.5em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em]},
|
||||
rowspec={Q[c,f] Q[c,m] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c]},
|
||||
row{3-11}={font=\tiny},
|
||||
}
|
||||
& & & & & & & \small{*} & & & & \small{*} & \small{*} & \\
|
||||
\SetCell{c} Res & \slash & \pierce & \blunt & \symceleste & \symfire & \symearth & \symwood & \symmagma & \symabyss & \symwater & \symwind & \symice & \symthunder \\
|
||||
\hline
|
||||
\SetCell{font=\footnotesize} & $9$ & $$ & $10$ & $12$ & $13$ & $15$ & $16$ & $14$ & $$ & $19$ & $18$ & $20$ & $21$ \\
|
||||
\end{tblr}\begin{tblr}{
|
||||
colspec={c c c c c c c c c c c c c c c c c c c},
|
||||
row{2}={font=\footnotesize},
|
||||
row{3-6}={font=\tiny},
|
||||
}
|
||||
& \SetCell[c=2]{c} P1 & & \SetCell[c=2]{c} P2 & & & \SetCell[c=7]{c} Stats & & & & & & & & \SetCell[c=4]{c} Mouvement & & & & \\
|
||||
\cline{2-3} \cline{4-5} \cline{7-13} \cline{15-18}
|
||||
\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} \\
|
||||
\SetCell{font=\footnotesize}$t_1$ & ${{p1_init}}$ & $4$A & ${{p2_init}}$ & $4$A & & ${{strength}}$ & ${{perception}}$ & ${{willpower}}$ & ${{alteration_resistance}}$ & ${{torque}}$ & ${{awareness}}$ & ${{fatigue}}$ & & ${{mvt_walk}}$ & ${{mvt_trot}}$ & ${{mvt_run}}$ & ${{mvt_flight}}$ \\
|
||||
\begin{tblr}{
|
||||
colspec={c c c c c c c c c c c c c c c c c c c},
|
||||
row{2}={font=\footnotesize},
|
||||
row{3-6}={font=\tiny},
|
||||
}
|
||||
& \SetCell[c=2]{c} P1 & & \SetCell[c=2]{c} P2 & & & \SetCell[c=7]{c} Stats & & & & & & & & \SetCell[c=4]{c} Mouvement & & & & \\
|
||||
\cline{2-3} \cline{4-5} \cline{7-13} \cline{15-18}
|
||||
\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} \\
|
||||
\SetCell{font=\footnotesize}$t_1$ & $500$ & $4$A & $22$ & $4$A & & $8$ & $6$ & $5$ & $4$ & $40$ & $6$ & $20$ & & $10$ & $20$ & $50$ & $0$ \\
|
||||
\SetCell{font=\footnotesize}$t_2$ & $10$ & & $12$ & 52A \\
|
||||
\SetCell{font=\footnotesize}$t_3$ & $5$ & & $2$ & 21A \\
|
||||
\scriptsize{
|
||||
\begin{tblr}{
|
||||
colspec={X[0.05] X[4,l] X[1,c] X[1,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[2,r] X[2,c] X[0.3,c] X[0.3,c]},
|
||||
hspan=minimal,
|
||||
colsep=2pt,
|
||||
row{2}={font=\tiny},
|
||||
}
|
||||
& & & & & \SetCell[c=2]{c} Coûts & & & \SetCell[c=2]{c} Dégâts & & & \SetCell[c=2]{c} Seuils & \\
|
||||
\cline{6-7} \cline{9-10} \cline{12-13}
|
||||
& \SetCell{c} & {ID} & {Type} & \rb{Ciblage} & \rb{Fatigue} & \rb{Action} & \rb{Élément} & \rb{Fatigue} & \SetCell{c} \rb{Normaux} & {Effets} & \rb{Parade} & \rb{Esquive} \\
|
||||
\SetHline{1-13}{solid}
|
||||
\end{tblr}
|
||||
}
|
||||
\vfill
|
||||
\renewcommand{\rb}{\undefined}
|
||||
\begin{tblr}{
|
||||
colspec={X[7] X[3]},
|
||||
rowspec={X[c] X[j,h,8cm]},
|
||||
vline{2},
|
||||
hline{2},
|
||||
row{2}={font=\footnotesize},
|
||||
}
|
||||
Plan de combat & Graphique d'intentions \\
|
||||
9 & 7 \\
|
||||
\end{tblr}
|
||||
\vfill
|
||||
|
|
@ -50,7 +50,7 @@ pub struct WeaponConfig {
|
|||
pub target: ExportTarget,
|
||||
|
||||
/// The path to export to
|
||||
#[arg(short, long, default_value = "./Craft")]
|
||||
#[arg(short, long, default_value = "./Craft/")]
|
||||
pub export: String,
|
||||
|
||||
#[arg(long, default_value_t = String::from("safe"))]
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ pub enum MonsterTarget {
|
|||
// Clean,
|
||||
/// Generate the monster list
|
||||
Export,
|
||||
// /// Show useful data
|
||||
// Show,
|
||||
/// Balancing data
|
||||
Balance,
|
||||
}
|
||||
|
||||
/// Configuration data for generating a monster sheet.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ serde_rusqlite = {workspace = true}
|
|||
serde_json = {workspace = true}
|
||||
handlebars = {workspace = true}
|
||||
strum = { version = "0.28.0", features = ["derive"] }
|
||||
comfy-table = "7.2.2"
|
||||
colored = "3.1.1"
|
||||
|
||||
[dev-dependencies]
|
||||
regex = {workspace = true}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,15 @@
|
|||
//! (`MonsterConfig`) and delegates to the appropriate sub‑routine (clean, export or show).
|
||||
//!
|
||||
|
||||
use crate::monster_export::generate_monsters_tex;
|
||||
use crate::{monster_analysis::show_balancing_data, monster_export::generate_monsters_tex};
|
||||
|
||||
use config::monsters::MonsterTarget;
|
||||
|
||||
use anyhow::Context;
|
||||
mod monster_analysis;
|
||||
mod monster_database;
|
||||
mod monster_export;
|
||||
mod monster_render;
|
||||
pub mod monster_structs;
|
||||
|
||||
use anyhow::Result;
|
||||
|
|
@ -37,6 +40,7 @@ pub fn monsters_dispatch(args: &MonsterConfig, config: &Config) -> Result<()> {
|
|||
// MonsterTarget::Clean => unimplemented!("implement cleaning logic"),
|
||||
MonsterTarget::Export => generate_monsters_tex(args, config, connection)?,
|
||||
// MonsterTarget::Show => unimplemented!("implement show logic"),
|
||||
MonsterTarget::Balance => show_balancing_data(args, config, connection)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
//! Monster export module
|
||||
|
||||
use crate::{
|
||||
Config, Connection, MonsterConfig,
|
||||
monster_database::{fetch_all_creature_data, fetch_all_player_data},
|
||||
monster_render::ToRow,
|
||||
monster_structs::PlayerBalancing,
|
||||
};
|
||||
use comfy_table::presets::UTF8_FULL;
|
||||
use comfy_table::*;
|
||||
use more_fields::FieldsAsSlice;
|
||||
|
||||
/// Shows balancing information for monsters and players.
|
||||
pub fn show_balancing_data(
|
||||
args: &MonsterConfig,
|
||||
config: &Config,
|
||||
connection: Connection,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let _ = args;
|
||||
let _data = fetch_all_creature_data(&connection, config)?;
|
||||
let player_data = fetch_all_player_data(&connection, config)?;
|
||||
|
||||
let mut table = Table::new();
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic)
|
||||
.set_width(120)
|
||||
.set_header(
|
||||
PlayerBalancing::attributes_slice()
|
||||
.iter()
|
||||
.map(|(a, _b)| Cell::new(a)),
|
||||
);
|
||||
// table.add_row(player_data.as_slice());
|
||||
|
||||
for entry in player_data {
|
||||
table.add_row(entry.to_row());
|
||||
}
|
||||
// for creature in data {
|
||||
// println!("{} {:#?}", creature.name, creature.balancing);
|
||||
// }
|
||||
println!("{table}");
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use crate::monster_structs::{self, CreatureReward, MonsterAllAttacks, MonsterRepetableInitRow};
|
||||
use crate::monster_structs::{
|
||||
self, CreatureReward, MonsterAllAttacks, MonsterRepetableInitRow, PlayerBalancing,
|
||||
};
|
||||
use crate::monster_structs::{
|
||||
CreatureBodyPart, CreatureData, CreatureListAttacks, CreatureStats, FullMonster,
|
||||
MonsterSingleAttack,
|
||||
};
|
||||
use anyhow::{Context, anyhow};
|
||||
use cli_parser::Config;
|
||||
use more_fields::FieldsAsSlice;
|
||||
use rusqlite::Connection;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
|
|
@ -26,12 +29,12 @@ macro_rules! fetch_from {
|
|||
|
||||
/// Fetch all data from the database
|
||||
// TODO: WARN the master filter is hardcoded here
|
||||
pub(crate) fn fetch_all_data(
|
||||
connection: Connection,
|
||||
pub(crate) fn fetch_all_creature_data(
|
||||
connection: &Connection,
|
||||
config: &Config,
|
||||
) -> Result<Vec<FullMonster>, anyhow::Error> {
|
||||
let list_creatures = generic_deserialize::<CreatureData>(
|
||||
&connection,
|
||||
connection,
|
||||
"creature",
|
||||
Some("show_to_master=1"),
|
||||
Some("id"),
|
||||
|
|
@ -39,39 +42,8 @@ pub(crate) fn fetch_all_data(
|
|||
let mut finished_creatures = Vec::new();
|
||||
for creature in list_creatures.iter() {
|
||||
// println!("Working on {}@{}", creature.id, creature.name);
|
||||
let creature_attacks = fetch_from!(
|
||||
MonsterSingleAttack,
|
||||
connection,
|
||||
creature,
|
||||
"creature_abilities",
|
||||
Some("phase, attack_group, ordering")
|
||||
);
|
||||
let creature_resistances = fetch_from!(
|
||||
CreatureBodyPart,
|
||||
connection,
|
||||
creature,
|
||||
"creature_body_parts",
|
||||
None
|
||||
);
|
||||
|
||||
let creature_stats =
|
||||
fetch_from!(CreatureStats, connection, creature, "creature_stats", None);
|
||||
if creature_stats.len() != 1 {
|
||||
return Err(anyhow!(
|
||||
"The stat line for the creature {} should be exactly one found {}",
|
||||
creature.name,
|
||||
creature_stats.len()
|
||||
));
|
||||
};
|
||||
let creature_stats = creature_stats.first().unwrap().clone();
|
||||
|
||||
let creature_rewards = fetch_from!(
|
||||
CreatureReward,
|
||||
connection,
|
||||
creature,
|
||||
"creature_rewards",
|
||||
None
|
||||
);
|
||||
let creature_stats: CreatureStats =
|
||||
fetch_one_field(connection, creature, "creature_stats")?;
|
||||
finished_creatures.push(FullMonster {
|
||||
id: creature.id,
|
||||
name: creature.name.clone(),
|
||||
|
|
@ -81,23 +53,81 @@ pub(crate) fn fetch_all_data(
|
|||
&creature_stats.p1_actions,
|
||||
&creature_stats.p2_actions,
|
||||
),
|
||||
stats: creature_stats,
|
||||
all_attacks: MonsterAllAttacks::from_retrieved_data(&creature_attacks, config),
|
||||
stats: creature_stats, // fetch_one_field(connection, creature, "creature_stats")?,
|
||||
all_attacks: MonsterAllAttacks::from_retrieved_data(
|
||||
&fetch_from!(
|
||||
MonsterSingleAttack,
|
||||
connection,
|
||||
creature,
|
||||
"creature_abilities",
|
||||
Some("phase, attack_group, ordering")
|
||||
),
|
||||
config,
|
||||
),
|
||||
attacks: CreatureListAttacks {
|
||||
attacks: creature_attacks,
|
||||
attacks: fetch_from!(
|
||||
MonsterSingleAttack,
|
||||
connection,
|
||||
creature,
|
||||
"creature_abilities",
|
||||
Some("phase, attack_group, ordering")
|
||||
),
|
||||
},
|
||||
body_parts: monster_structs::CreatureListBodyParts {
|
||||
body_parts: creature_resistances,
|
||||
body_parts: fetch_from!(
|
||||
CreatureBodyPart,
|
||||
connection,
|
||||
creature,
|
||||
"creature_body_parts",
|
||||
None
|
||||
),
|
||||
},
|
||||
data: creature.clone(),
|
||||
rewards: monster_structs::CreatureListRewards {
|
||||
rewards: creature_rewards,
|
||||
rewards: fetch_from!(
|
||||
CreatureReward,
|
||||
connection,
|
||||
creature,
|
||||
"creature_rewards",
|
||||
None
|
||||
),
|
||||
},
|
||||
balancing: fetch_one_field(connection, creature, "creature_balancing")?,
|
||||
data: creature.clone(),
|
||||
});
|
||||
}
|
||||
Ok(finished_creatures)
|
||||
}
|
||||
|
||||
pub(crate) fn fetch_all_player_data(
|
||||
connection: &Connection,
|
||||
config: &Config,
|
||||
) -> Result<Vec<PlayerBalancing>, anyhow::Error> {
|
||||
let _ = config;
|
||||
generic_deserialize::<PlayerBalancing>(connection, "player_balancing", None, None)
|
||||
}
|
||||
|
||||
/// Fetches **the single** row that matches `creature` from the given `table_name`.
|
||||
///
|
||||
/// The query is performed through the `fetch_from!` macro, which returns a vector of
|
||||
/// values deserialised into `T`. If the resulting vector does not contain exactly
|
||||
/// one element an error is returned; otherwise the sole value is extracted.
|
||||
fn fetch_one_field<T: DeserializeOwned + FieldsAsSlice>(
|
||||
connection: &Connection,
|
||||
creature: &CreatureData,
|
||||
table_name: &str,
|
||||
) -> Result<T, anyhow::Error> {
|
||||
let mut creature_stats = fetch_from!(T, connection, creature, table_name, None);
|
||||
if creature_stats.len() != 1 {
|
||||
return Err(anyhow!(
|
||||
"The number of {} entries for the creature {} should be exactly one found {}",
|
||||
table_name,
|
||||
creature.name,
|
||||
creature_stats.len()
|
||||
));
|
||||
};
|
||||
Ok(creature_stats.pop().unwrap())
|
||||
}
|
||||
|
||||
/// A generic Deserialisation from a database
|
||||
fn generic_deserialize<T: more_fields::FieldsAsSlice + DeserializeOwned>(
|
||||
connection: &Connection,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use indexmap::IndexMap;
|
|||
use rusqlite::Connection;
|
||||
use std::{fmt::Write, fs::File, io::Write as OtherWrite};
|
||||
|
||||
use crate::monster_database::fetch_all_data;
|
||||
use crate::monster_database::fetch_all_creature_data;
|
||||
use crate::monster_structs::{MonsterAllAttacks, MonsterFullAttack, MonsterSingleAttack};
|
||||
|
||||
/// Load a template from a struct field into a `templates` collection.
|
||||
|
|
@ -44,7 +44,7 @@ pub fn generate_monsters_tex(
|
|||
config: &Config,
|
||||
connection: Connection,
|
||||
) -> std::result::Result<(), anyhow::Error> {
|
||||
let all_monsters = fetch_all_data(connection, config)?;
|
||||
let all_monsters = fetch_all_creature_data(&connection, config)?;
|
||||
let templates = load_templates(config)?;
|
||||
println!("Processing");
|
||||
let mut m_out = String::new();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
use comfy_table::Color;
|
||||
use comfy_table::{Cell, Row};
|
||||
|
||||
use crate::monster_structs::{PlayerBalancing, ProfileHSE, ProfileStance};
|
||||
|
||||
/// Handy trait: “give me the table row that represents this record”
|
||||
pub trait ToCell {
|
||||
fn to_cell(&self) -> Cell;
|
||||
}
|
||||
|
||||
pub trait ToRow {
|
||||
fn to_row(&self) -> Row;
|
||||
}
|
||||
|
||||
impl ToRow for PlayerBalancing {
|
||||
fn to_row(&self) -> Row {
|
||||
vec![
|
||||
self.profile_hse.to_cell(),
|
||||
self.profile_stance.to_cell(),
|
||||
Cell::new(format!("{:?}", self.damage_per_s)),
|
||||
Cell::new(format!("{:?}", self.successes)),
|
||||
Cell::new(format!("{:?}", self.protection)),
|
||||
Cell::new(format!("{:?}", self.strength)),
|
||||
Cell::new(format!("{:?}", self.integrity)),
|
||||
Cell::new(format!("{:?}", self.health)),
|
||||
]
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCell for ProfileHSE {
|
||||
fn to_cell(&self) -> Cell {
|
||||
match self {
|
||||
ProfileHSE::Lowest => Into::<Cell>::into(format!("{self:?}")).fg(Color::DarkRed),
|
||||
ProfileHSE::Low => Into::<Cell>::into(format!("{self:?}")).fg(Color::Red),
|
||||
ProfileHSE::Mid => Into::<Cell>::into(format!("{self:?}")).fg(Color::Yellow),
|
||||
ProfileHSE::High => Into::<Cell>::into(format!("{self:?}")).fg(Color::Green),
|
||||
ProfileHSE::Highest => Into::<Cell>::into(format!("{self:?}")).fg(Color::Blue),
|
||||
ProfileHSE::HighestPlus => Into::<Cell>::into(format!("{self:?}")).fg(Color::DarkBlue),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCell for ProfileStance {
|
||||
fn to_cell(&self) -> Cell {
|
||||
match self {
|
||||
ProfileStance::Defensive => Into::<Cell>::into(format!("{self:?}")).fg(Color::Blue),
|
||||
ProfileStance::Offensive => Into::<Cell>::into(format!("{self:?}")).fg(Color::Red),
|
||||
ProfileStance::Neutral => Into::<Cell>::into(format!("{self:?}")).fg(Color::Yellow),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,9 @@ use indexmap::IndexMap;
|
|||
use more_fields::FieldsAsSlice;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Full data, including monster_data & balancing data
|
||||
pub struct FullData {}
|
||||
|
||||
/// A monster ready for consumption by other modules.
|
||||
///
|
||||
/// This struct is extremely export centric
|
||||
|
|
@ -47,6 +50,9 @@ pub struct FullMonster {
|
|||
|
||||
/// Serialized stats directly copied from the database table.
|
||||
pub stats: CreatureStats,
|
||||
|
||||
/// Serialized balancing data
|
||||
pub balancing: CreatureBalancing,
|
||||
}
|
||||
|
||||
/// One row from the `creature` table.
|
||||
|
|
@ -350,7 +356,7 @@ pub struct GroupedResists {
|
|||
// }
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
/// All creature stats
|
||||
/// All creature stats used in combat calculations.
|
||||
pub struct CreatureStats {
|
||||
#[INTEGER]
|
||||
pub creature_id: i64,
|
||||
|
|
@ -395,6 +401,79 @@ pub struct CreatureStats {
|
|||
#[INTEGER]
|
||||
pub blood_carve: i64,
|
||||
}
|
||||
/// Balancing metadata for a creature.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
pub struct CreatureBalancing {
|
||||
#[INTEGER]
|
||||
creature_id: i64,
|
||||
#[TEXT]
|
||||
/// (Fixed) HSE profile of the monster (see `ProfileHSE`).
|
||||
profile_hse: ProfileHSE,
|
||||
#[INTEGER]
|
||||
/// (Goal) Turns needed to reach phase 2.
|
||||
time_to_p2: i64,
|
||||
#[INTEGER]
|
||||
/// (Goal) Turns until the monster’s armor breaks.
|
||||
time_to_armorbreak: i64,
|
||||
#[INTEGER]
|
||||
/// (GOAL) Avg. turns to kill a single target.
|
||||
time_to_kill_avg: i64,
|
||||
#[INTEGER]
|
||||
/// (FIXED) Size of a single monster group (usually one).
|
||||
monster_groupsize: i64,
|
||||
#[INTEGER]
|
||||
/// (FIXED) The number of players this fight was designed for
|
||||
player_groupsize: i64,
|
||||
}
|
||||
|
||||
/// Balancing info on all the player depending on their level
|
||||
///
|
||||
/// All this info is FIXED and calculated based on average game data
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
pub struct PlayerBalancing {
|
||||
#[INTEGER]
|
||||
/// HSE profile of the player (see `ProfileHSE`).
|
||||
pub profile_hse: ProfileHSE,
|
||||
#[INTEGER]
|
||||
/// Stance used in this datapoint.
|
||||
pub profile_stance: ProfileStance,
|
||||
#[INTEGER]
|
||||
/// Damage dealt per success.
|
||||
pub damage_per_s: f64,
|
||||
#[INTEGER]
|
||||
/// Number of successes per round.
|
||||
pub successes: i64,
|
||||
#[INTEGER]
|
||||
/// Amount of protection (e.g., armor) the player has.
|
||||
pub protection: i64,
|
||||
#[INTEGER]
|
||||
/// Strength stat of the player.
|
||||
pub strength: i64,
|
||||
#[INTEGER]
|
||||
/// Integrity / hit‑point reserve of the player.
|
||||
pub integrity: i64,
|
||||
#[INTEGER]
|
||||
/// Current health points.
|
||||
pub health: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
/// Player stance preference used for balance tables.
|
||||
pub enum ProfileStance {
|
||||
Defensive,
|
||||
Offensive,
|
||||
Neutral,
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
/// Hunter Star Equivalent (roughly level+skill) profile used throughout the system.
|
||||
pub enum ProfileHSE {
|
||||
Lowest,
|
||||
Low,
|
||||
Mid,
|
||||
High,
|
||||
Highest,
|
||||
HighestPlus,
|
||||
}
|
||||
|
||||
// ----------- HERE BE WARCRIMES -------------
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ pub enum FatalEquipementError {
|
|||
pub enum WeaponGenerationError {
|
||||
#[error("An unexpected error occured")]
|
||||
Unexpected,
|
||||
|
||||
#[error("An error was encountered while generating equipement")]
|
||||
FatalEquipementError(#[from] FatalEquipementError),
|
||||
|
||||
#[error("An error occured while writing the file")]
|
||||
IOError(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
// #[derive(Error, Debug)]
|
||||
|
|
|
|||
|
|
@ -37,18 +37,17 @@ pub fn export_weapons(args: &WeaponConfig, config: &Config) -> Result<(), Weapon
|
|||
materials: None,
|
||||
nature: Some(()), //(!args.no_natures).then_some(()),
|
||||
finishing: None, //args.finishing.then_some(()),
|
||||
})
|
||||
.unwrap();
|
||||
})?;
|
||||
|
||||
// let filter = Box::new(|_: &RefinedEquipement| true);
|
||||
let refined_list = scenarios.generate_refined_recipes().unwrap();
|
||||
let refined_list = scenarios.generate_refined_recipes()?;
|
||||
// .inner_filter(filter);
|
||||
|
||||
let tex = refined_list.to_tex(config).unwrap();
|
||||
let tex = refined_list.to_tex(config)?;
|
||||
|
||||
let name = format!("{}gen-forge-table.tex", args.export);
|
||||
let name = format!("{}/gen-forge-table.tex", args.export);
|
||||
println!("Writing to file {name}");
|
||||
let mut f = fs::File::create(name).unwrap();
|
||||
writeln!(f, "{}", tex).unwrap();
|
||||
let mut f = fs::File::create(name)?;
|
||||
writeln!(f, "{}", tex)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,20 @@ pub struct ExportableEquipement {
|
|||
pub needs_break: bool,
|
||||
}
|
||||
|
||||
/// Put half numbers
|
||||
fn halves(f: f32) -> String {
|
||||
let base = f.floor();
|
||||
let extra = f - base;
|
||||
if !(-0.1..=0.1).contains(&extra) {
|
||||
if base == 0. {
|
||||
"\\half{}".to_string()
|
||||
} else {
|
||||
format!("{base:0}\\half{{}}")
|
||||
}
|
||||
} else {
|
||||
format!("{base}")
|
||||
}
|
||||
}
|
||||
impl From<&RefinedEquipement> for ExportableEquipement {
|
||||
fn from(value: &RefinedEquipement) -> Self {
|
||||
let mut special = Vec::new();
|
||||
|
|
@ -108,6 +122,9 @@ impl From<&RefinedEquipement> for ExportableEquipement {
|
|||
value.inner.precision
|
||||
));
|
||||
}
|
||||
if value.inner.agility_bonus != 0. {
|
||||
special.push(format!(r"Ag {}", halves(value.inner.agility_bonus)));
|
||||
}
|
||||
Self {
|
||||
name: value.advanced.display_name.clone(),
|
||||
maniement: value.inner.get_maniement(),
|
||||
|
|
@ -120,7 +137,7 @@ impl From<&RefinedEquipement> for ExportableEquipement {
|
|||
torque_one_handed: value.inner.torque_one_handed,
|
||||
torque_two_handed: value.inner.torque_two_handed,
|
||||
modes: value.inner.get_modes(),
|
||||
esquive: value.inner.dodge.to_string(),
|
||||
esquive: halves(value.inner.dodge),
|
||||
parrade: value.inner.parry.to_string(),
|
||||
vitesse: value.inner.speed.to_string(),
|
||||
discretion: value.inner.stealth.to_string(),
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ impl Display for InnerEquipementStats {
|
|||
self.difficulty,
|
||||
self.tier,
|
||||
self.category_base
|
||||
.clone()
|
||||
.map_or_else(|| "ø".to_string(), |v| v.to_string()),
|
||||
self.category_size
|
||||
.clone()
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 14934910a40cd5fdee09f9ef7df75e1e4d0f2288
|
||||
Subproject commit f52776f917aeaf0e29944351d05f76efb0ecb2f6
|
||||
Loading…
Reference in New Issue