database_monsters #151
|
|
@ -6,7 +6,7 @@ resolver = "3"
|
|||
# edition = "2024"
|
||||
# license = "MIT OR Apache-2.0"
|
||||
[workspace.package]
|
||||
version = "0.3.18"
|
||||
version = "0.3.20"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub fn show_balancing_data(
|
|||
table.add_row(vec![
|
||||
creature.id.to_cell(),
|
||||
match creature.balancing.monster_groupsize {
|
||||
0 | 1 => creature.name.clone(),
|
||||
1. => creature.name.clone(),
|
||||
n => format!("{} x {}", creature.name, n),
|
||||
}
|
||||
.to_cell()
|
||||
|
|
|
|||
|
|
@ -105,9 +105,10 @@ pub fn attack_player(
|
|||
player_health: victim.health,
|
||||
player_integrity: victim.integrity,
|
||||
threshold,
|
||||
attack_successes: attack.successes,
|
||||
attack_successes: attack.fatigue,
|
||||
mode,
|
||||
showcase,
|
||||
fatigue: attack.fatigue,
|
||||
stance: victim.profile_stance,
|
||||
};
|
||||
Some(report)
|
||||
|
|
@ -118,6 +119,8 @@ pub struct DamageReport {
|
|||
pub name: String,
|
||||
#[INTEGER(name = "dmg_inc")]
|
||||
pub damage_incoming: f64,
|
||||
#[INTEGER(name = "F")]
|
||||
pub fatigue: i64,
|
||||
#[INTEGER(name = "r_left")]
|
||||
pub successes_left: f64,
|
||||
#[INTEGER(name = "dmg_tak")]
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ pub(crate) fn display_player_attacks(
|
|||
.body_parts
|
||||
.iter()
|
||||
.map(|body_part| {
|
||||
let ratio = creature.balancing.monster_groupsize as f64
|
||||
/ creature.balancing.player_groupsize as f64;
|
||||
let ratio = creature.balancing.monster_groupsize / creature.balancing.player_groupsize;
|
||||
let damage_done_p1 =
|
||||
damage_done_to_part(body_part, &profiles[&ProfileStance::Neutral], Phases::P1);
|
||||
let damage_done_p2 =
|
||||
|
|
@ -36,7 +35,11 @@ pub(crate) fn display_player_attacks(
|
|||
+ body_part.life_points_p2.unwrap_or(0) as f64 / damage_done_p2.hp_t);
|
||||
let time_to_armorbreak =
|
||||
ratio * (body_part.integrity_p1.unwrap() as f64 / damage_done_p1.ab_t);
|
||||
|
||||
let time_to_kill_through = ratio
|
||||
* (body_part.life_points_p1.unwrap() as f64
|
||||
/ (damage_done_p1.damage_through - creature.stats.strength as f64).max(0.)
|
||||
+ body_part.life_points_p2.unwrap_or(0) as f64
|
||||
/ (damage_done_p2.damage_through - creature.stats.strength as f64).max(0.));
|
||||
DefenseReport {
|
||||
id: creature.balancing.creature_id,
|
||||
name: creature.name.clone(),
|
||||
|
|
@ -57,12 +60,41 @@ pub(crate) fn display_player_attacks(
|
|||
time_to_armorbreak_target: creature.balancing.time_to_armorbreak,
|
||||
armor_break_per_turn: damage_done_p1.ab_t,
|
||||
integrity_p1: body_part.integrity_p1.unwrap(),
|
||||
damage_through_p1: damage_done_p1.damage_through,
|
||||
damage_through_p2: damage_done_p2.damage_through,
|
||||
time_to_kill_through,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<DefenseReport>>();
|
||||
println!("{}", r.to_table());
|
||||
}
|
||||
|
||||
pub fn resist_physical(part: &CreatureBodyPart, mode: DefenseMode) -> i64 {
|
||||
let res = [&part.slash, &part.blunt, &part.piercing]
|
||||
.into_iter()
|
||||
.map(value_resist);
|
||||
match mode {
|
||||
DefenseMode::Best => res.max().unwrap_or(0),
|
||||
DefenseMode::Worst => res.min().unwrap_or(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn value_resist(resist: &Option<String>) -> i64 {
|
||||
match resist {
|
||||
None => 0,
|
||||
Some(s) => {
|
||||
let mut sum = 0;
|
||||
for c in s.chars() {
|
||||
match c {
|
||||
'+' => sum += 2,
|
||||
'-' => sum -= 2,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
sum
|
||||
}
|
||||
}
|
||||
}
|
||||
pub(crate) fn damage_done_to_part(
|
||||
part: &CreatureBodyPart,
|
||||
profile: &PlayerBalancing,
|
||||
|
|
@ -74,9 +106,17 @@ pub(crate) fn damage_done_to_part(
|
|||
}
|
||||
.unwrap()
|
||||
+ profile.precision;
|
||||
let (_integrity, protection) = match phase {
|
||||
Phases::P1 => (part.integrity_p1.unwrap(), part.protection_p1.unwrap()),
|
||||
Phases::P2 => (part.integrity_p2.unwrap(), part.protection_p2.unwrap()),
|
||||
let (_integrity, protection, resist) = match phase {
|
||||
Phases::P1 => (
|
||||
part.integrity_p1.unwrap(),
|
||||
part.protection_p1.unwrap(),
|
||||
resist_physical(part, DefenseMode::Worst) as f64,
|
||||
),
|
||||
Phases::P2 => (
|
||||
part.integrity_p2.unwrap(),
|
||||
part.protection_p2.unwrap(),
|
||||
resist_physical(part, DefenseMode::Worst) as f64,
|
||||
),
|
||||
};
|
||||
let damage_profile: Vec<i64> = (1..profile.max_successes_off)
|
||||
.map(|v| (v as f64 * profile.damage_per_s) as i64)
|
||||
|
|
@ -84,18 +124,27 @@ pub(crate) fn damage_done_to_part(
|
|||
// Pick the best damage out of all scenarios:
|
||||
// Scenario A : One big hit
|
||||
// Scenario B : Two half hits
|
||||
let damage_a = damage_with_profile(&damage_profile, threshold, profile.successes_off);
|
||||
let damage_b1 = damage_with_profile(&damage_profile, threshold, profile.successes_off / 2);
|
||||
let damage_b2 = damage_with_profile(
|
||||
let damage_a =
|
||||
(damage_with_profile(&damage_profile, threshold, profile.successes_off) - resist).max(0.);
|
||||
let damage_b1 = (damage_with_profile(&damage_profile, threshold, profile.successes_off / 2)
|
||||
- resist)
|
||||
.max(0.);
|
||||
let damage_b2 = (damage_with_profile(
|
||||
&damage_profile,
|
||||
threshold,
|
||||
profile.successes_off - profile.successes_off / 2,
|
||||
);
|
||||
) - resist)
|
||||
.max(0.);
|
||||
let dt_a = (damage_a - protection as f64).max(0.);
|
||||
let dt_b1 = (damage_b1 - protection as f64).max(0.);
|
||||
let dt_b2 = (damage_b2 - protection as f64).max(0.);
|
||||
|
||||
let ab_a = (damage_a - protection as f64).clamp(0., profile.armor_break as f64);
|
||||
let ab_b1 = (damage_b1 - protection as f64).clamp(0., profile.armor_break as f64);
|
||||
let ab_b2 = (damage_b2 - protection as f64).clamp(0., profile.armor_break as f64);
|
||||
let hp_t = damage_a.max(damage_b1 + damage_b2);
|
||||
let ab_t = ab_a.max(ab_b1 + ab_b2);
|
||||
let damage_through = dt_a.max(dt_b2 + dt_b1);
|
||||
|
||||
DamageDealtByPlayer {
|
||||
damage_a,
|
||||
|
|
@ -106,9 +155,10 @@ pub(crate) fn damage_done_to_part(
|
|||
ab_b2,
|
||||
hp_t,
|
||||
ab_t,
|
||||
damage_through,
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Phases {
|
||||
P1,
|
||||
P2,
|
||||
|
|
@ -123,6 +173,7 @@ pub struct DamageDealtByPlayer {
|
|||
pub ab_b2: f64,
|
||||
pub hp_t: f64,
|
||||
pub ab_t: f64,
|
||||
pub damage_through: f64,
|
||||
}
|
||||
|
||||
pub(crate) fn damage_with_profile(damage_profile: &[i64], threshold: i64, dices: i64) -> f64 {
|
||||
|
|
@ -192,10 +243,10 @@ pub struct DefenseReport {
|
|||
/// (Fixed) The number of monsters in a single group.
|
||||
/// Usually `1`, but can be > 1 for bosses that spawn multiple instances.
|
||||
#[SKIP]
|
||||
pub monster_groupsize: i64,
|
||||
pub monster_groupsize: f64,
|
||||
/// (Fixed) Number of players this fight was designed for.
|
||||
#[SKIP]
|
||||
pub player_groupsize: i64,
|
||||
pub player_groupsize: f64,
|
||||
/// (Fixed) Health points during phase 1.
|
||||
#[SKIP]
|
||||
pub health_p1: i64,
|
||||
|
|
@ -206,6 +257,15 @@ pub struct DefenseReport {
|
|||
/// damage points the monster can take before losing its first phase.
|
||||
#[SKIP]
|
||||
pub integrity_p1: i64,
|
||||
/// (Actual) Damage going through the creature during p1
|
||||
#[SKIP]
|
||||
pub damage_through_p1: f64,
|
||||
/// (Actual) Damage going through the creature during p2
|
||||
#[SKIP]
|
||||
pub damage_through_p2: f64,
|
||||
/// (Actual) Time to kill through armor
|
||||
#[INTEGER(name = "P1 ⇝ P2 ⇝ 🕇")]
|
||||
pub time_to_kill_through: f64,
|
||||
}
|
||||
|
||||
pub(crate) fn display_monster_attacks(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ impl From<FullMonster> for Vec<MonsterBalancingAttack> {
|
|||
successes: from_successes(sub_attack.success.as_ref()),
|
||||
armor_break: from_opt_i64(sub_attack.armor_break.as_ref()),
|
||||
action_cost: from_actions(sub_attack.cost_action.as_ref()),
|
||||
fatigue: from_opt_str(sub_attack.damage_fatigue.as_ref()),
|
||||
name: sub_attack.name,
|
||||
threshold_parry: from_opt_i64(sub_attack.threshold_parry.as_ref()),
|
||||
threshold_dodge: from_opt_i64(sub_attack.threshold_dodge.as_ref()),
|
||||
|
|
@ -63,6 +64,8 @@ pub struct MonsterBalancingAttack {
|
|||
pub armor_break: i64,
|
||||
#[INTEGER(name = "A")]
|
||||
pub action_cost: i64,
|
||||
#[INTEGER(name = "F")]
|
||||
pub fatigue: i64,
|
||||
#[SKIP(name = "parry_t")]
|
||||
pub threshold_parry: i64,
|
||||
#[SKIP(name = "dodge_t")]
|
||||
|
|
|
|||
|
|
@ -108,6 +108,12 @@ impl ToRow for DamageReport {
|
|||
)
|
||||
.to_cell()
|
||||
),
|
||||
format!("{}", self.fatigue,)
|
||||
.to_cell()
|
||||
.add_attribute(match self.fatigue == 0 {
|
||||
true => Attribute::Hidden,
|
||||
false => Attribute::NoHidden,
|
||||
}),
|
||||
dim_if_not!(
|
||||
self,
|
||||
format!("{:.1} [>{:.1}]", self.successes_left, self.threshold)
|
||||
|
|
@ -256,6 +262,14 @@ impl ToRow for DefenseReport {
|
|||
.to_cell()
|
||||
.fg(Color::DarkGrey),
|
||||
compare_vals("t", self.time_to_kill, self.time_to_kill_target as f64),
|
||||
format!(
|
||||
"[{:.0} & {:.0}] ⇝ {}",
|
||||
self.damage_through_p1,
|
||||
self.damage_per_turn_p2,
|
||||
fmt_target(self.time_to_kill_through)
|
||||
)
|
||||
.to_cell()
|
||||
.fg(Color::DarkGrey),
|
||||
];
|
||||
row.into()
|
||||
}
|
||||
|
|
@ -269,7 +283,7 @@ pub(crate) fn fmt_target(v: f64) -> String {
|
|||
const THOUSAND: f64 = 1_000.0;
|
||||
|
||||
match v {
|
||||
_ if v >= TOO_MUCH => "⇑⇑⇑⇑B".to_string(),
|
||||
_ if v >= TOO_MUCH => "⇑⇑⇑⇑T".to_string(),
|
||||
_ if v >= TRILLION => format!("⇑{:.1}T", v / TRILLION),
|
||||
_ if v >= BILLION => format!("⇑{:.1}B", v / BILLION),
|
||||
_ if v >= MILLION => format!("⇑{:.1}M", v / MILLION),
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ pub struct FullMonster {
|
|||
}
|
||||
|
||||
/// One row from the `creature` table.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
pub struct CreatureData {
|
||||
/// Primary key – auto‑incremented by SQLite.
|
||||
#[INTEGER]
|
||||
|
|
@ -74,8 +74,8 @@ pub struct CreatureData {
|
|||
#[TEXT]
|
||||
pub image: String,
|
||||
/// The HSE danger level
|
||||
#[INTEGER]
|
||||
pub danger_level: i64,
|
||||
#[REAL]
|
||||
pub danger_level: f64,
|
||||
/// The footprints and such
|
||||
#[TEXT]
|
||||
pub traces: Option<String>,
|
||||
|
|
@ -413,7 +413,7 @@ pub struct CreatureStats {
|
|||
pub blood_carve: i64,
|
||||
}
|
||||
/// Balancing metadata for a creature.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
pub struct CreatureBalancing {
|
||||
#[INTEGER]
|
||||
pub creature_id: i64,
|
||||
|
|
@ -432,12 +432,12 @@ pub struct CreatureBalancing {
|
|||
#[INTEGER]
|
||||
/// (GOAL) Avg. turns to kill a single target.
|
||||
pub time_to_player_kill: i64,
|
||||
#[INTEGER]
|
||||
#[REAL]
|
||||
/// (FIXED) Size of a single monster group (usually one).
|
||||
pub monster_groupsize: i64,
|
||||
#[INTEGER]
|
||||
pub monster_groupsize: f64,
|
||||
#[REAL]
|
||||
/// (FIXED) The number of players this fight was designed for
|
||||
pub player_groupsize: i64,
|
||||
pub player_groupsize: f64,
|
||||
}
|
||||
|
||||
/// Balancing info on all the player depending on their level
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 430114d8e51fc3c85a0e9e2718f62e8ab8848f98
|
||||
Subproject commit b1532527561263e6ae23b8e5a0fe6d4acc52b553
|
||||
Loading…
Reference in New Issue