made the switch to using bracket-lib directly, instead of rltk wrapper

this should solve the build issues; it makes using the non-crashing github build a lot easier, because it lets the explicit rltk dependency be removed.
This commit is contained in:
Llywelwyn 2023-09-05 02:23:31 +01:00
parent 455b8f2d80
commit 85efe13dc5
93 changed files with 1528 additions and 770 deletions

View file

@ -25,7 +25,7 @@ use super::{
WeaponAttribute,
config::CONFIG,
};
use rltk::prelude::*;
use bracket_lib::prelude::*;
use specs::prelude::*;
pub struct MeleeCombatSystem {}
@ -50,7 +50,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
ReadStorage<'a, HungerClock>,
ReadStorage<'a, MultiAttack>,
ReadStorage<'a, Blind>,
WriteExpect<'a, rltk::RandomNumberGenerator>,
WriteExpect<'a, RandomNumberGenerator>,
);
fn run(&mut self, data: Self::SystemData) {
@ -194,7 +194,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
armour_ac_bonus += ac.amount;
}
}
let actual_armour_class = bac - attribute_ac_bonus - skill_ac_bonus - armour_ac_bonus;
let actual_armour_class =
bac - attribute_ac_bonus - skill_ac_bonus - armour_ac_bonus;
let mut armour_class_roll = actual_armour_class;
if actual_armour_class < 0 {
@ -205,13 +206,17 @@ impl<'a> System<'a> for MeleeCombatSystem {
}
// Monster attacks receive a +10 to-hit bonus against the player.
let monster_v_player_bonus = if wants_melee.target == *player_entity { 10 } else { 0 };
let monster_v_player_bonus = if wants_melee.target == *player_entity {
10
} else {
0
};
let target_number = monster_v_player_bonus + armour_class_roll + attacker_bonuses;
let target_name = names.get(wants_melee.target).unwrap();
if CONFIG.logging.log_combat {
rltk::console::log(
console::log(
format!(
"ATTACKLOG: {} *{}* {}: rolled ({}) 1d20 vs. {} ({} + {}AC + {}to-hit)",
&name.name,
@ -228,8 +233,14 @@ impl<'a> System<'a> for MeleeCombatSystem {
if d20 < target_number {
// Target hit!
let base_damage = rng.roll_dice(weapon_info.damage_n_dice, weapon_info.damage_die_type);
let skill_damage_bonus = gamesystem::skill_bonus(Skill::Melee, &*attacker_skills);
let base_damage = rng.roll_dice(
weapon_info.damage_n_dice,
weapon_info.damage_die_type
);
let skill_damage_bonus = gamesystem::skill_bonus(
Skill::Melee,
&*attacker_skills
);
let mut attribute_damage_bonus = weapon_info.damage_bonus;
match weapon_info.attribute {
WeaponAttribute::Dexterity => {
@ -239,17 +250,23 @@ impl<'a> System<'a> for MeleeCombatSystem {
attribute_damage_bonus += attacker_attributes.strength.bonus;
}
WeaponAttribute::Finesse => {
if attacker_attributes.dexterity.bonus > attacker_attributes.strength.bonus {
if
attacker_attributes.dexterity.bonus >
attacker_attributes.strength.bonus
{
attribute_damage_bonus += attacker_attributes.dexterity.bonus;
} else {
attribute_damage_bonus += attacker_attributes.strength.bonus;
}
}
}
let mut damage = i32::max(0, base_damage + skill_damage_bonus + attribute_damage_bonus);
let mut damage = i32::max(
0,
base_damage + skill_damage_bonus + attribute_damage_bonus
);
if CONFIG.logging.log_combat {
rltk::console::log(
console::log(
format!(
"ATTACKLOG: {} HIT for {} ({}[{}d{}]+{}[skill]+{}[attr])",
&name.name,
@ -267,7 +284,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
let ac_damage_reduction = rng.roll_dice(1, -actual_armour_class);
damage = i32::min(1, damage - ac_damage_reduction);
if CONFIG.logging.log_combat {
rltk::console::log(
console::log(
format!(
"ATTACKLOG: {} reduced their damage taken by {} (1dAC), and took {} hp damage.",
&target_name.name,
@ -321,7 +338,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
}
} else {
if CONFIG.logging.log_combat {
rltk::console::log(format!("ATTACKLOG: {} *MISSED*", &name.name));
console::log(format!("ATTACKLOG: {} *MISSED*", &name.name));
}
let pos = positions.get(wants_melee.target);
@ -365,7 +382,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
}
fn get_natural_attacks(
rng: &mut rltk::RandomNumberGenerator,
rng: &mut RandomNumberGenerator,
nat: NaturalAttacks,
multi_attack: bool,
attacks: &mut Vec<(MeleeWeapon, String)>