Address review comments

This commit is contained in:
Sam 2023-06-26 21:27:52 -04:00
parent df0244c5e7
commit 4fd1626e5f
4 changed files with 20 additions and 20 deletions

View File

@ -139,11 +139,11 @@ impl Attack {
if damage.value > 0.0 {
let attacker_penetration = attacker
.and_then(|a| a.stats)
.map_or(0.0, |s| dbg!(s.mitigations_penetration))
.map_or(0.0, |s| s.mitigations_penetration)
.clamp(0.0, 1.0);
let raw_damage_reduction =
Damage::compute_damage_reduction(Some(damage), target.inventory, target.stats, msm);
let damage_reduction = (1.0 - dbg!(attacker_penetration)) * dbg!(raw_damage_reduction);
let damage_reduction = (1.0 - attacker_penetration) * raw_damage_reduction;
let block_reduction =
if let (Some(char_state), Some(ori)) = (target.char_state, target.ori) {
if ori.look_vec().angle_between(-*dir) < char_state.block_angle() {
@ -175,7 +175,7 @@ impl Attack {
} else {
0.0
};
1.0 - (1.0 - dbg!(damage_reduction)) * (1.0 - block_reduction)
1.0 - (1.0 - damage_reduction) * (1.0 - block_reduction)
} else {
0.0
}

View File

@ -6,7 +6,9 @@ use crate::{
character_state::AttackFilters,
inventory::{
item::{
tool::{AbilityContext, AbilityItem, AbilityKind, Stats, ToolKind},
tool::{
AbilityContext, AbilityItem, AbilityKind, ContextualIndex, Stats, ToolKind,
},
ItemKind,
},
slot::EquipSlot,
@ -462,7 +464,7 @@ impl From<GuardAbility> for Ability {
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
pub struct SpecifiedAbility {
pub ability: Ability,
pub context_index: Option<usize>,
pub context_index: Option<ContextualIndex>,
}
impl SpecifiedAbility {
@ -480,7 +482,7 @@ impl SpecifiedAbility {
abilities,
} => spec_ability
.context_index
.and_then(|i| abilities.get(i))
.and_then(|i| abilities.get(i.0))
.map_or(pseudo_id.as_str(), |(_, (_, a))| a.id.as_str()),
}
}

View File

@ -309,6 +309,9 @@ pub enum AbilityKind<T> {
},
}
#[derive(Clone, Debug, Serialize, Deserialize, Copy, Eq, PartialEq)]
pub struct ContextualIndex(pub usize);
impl<T> AbilityKind<T> {
pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> AbilityKind<U> {
match self {
@ -346,7 +349,7 @@ impl<T> AbilityKind<T> {
&self,
skillset: Option<&SkillSet>,
contexts: &[AbilityContext],
) -> Option<(&T, Option<usize>)> {
) -> Option<(&T, Option<ContextualIndex>)> {
let unlocked = |s: Option<Skill>, a| {
// If there is a skill requirement and the skillset does not contain the
// required skill, return None
@ -369,7 +372,7 @@ impl<T> AbilityKind<T> {
req_contexts
.iter()
.all(|req| req.fulfilled_by(contexts))
.then_some((a, Some(i)))
.then_some((a, Some(ContextualIndex(i))))
}),
}
}
@ -420,9 +423,7 @@ impl AbilityContext {
fn fulfilled_by(&self, contexts: &[AbilityContext]) -> bool {
match self {
basic_context @ Self::Stance(_) | basic_context @ Self::DualWieldingSameKind => {
contexts.contains(basic_context)
},
Self::Stance(_) | Self::DualWieldingSameKind => contexts.contains(self),
Self::Combo(required) => contexts
.iter()
.filter_map(|context| {
@ -486,7 +487,7 @@ impl<T> AbilitySet<T> {
&self,
skillset: Option<&SkillSet>,
contexts: &[AbilityContext],
) -> Option<(&T, Option<usize>)> {
) -> Option<(&T, Option<ContextualIndex>)> {
self.primary.ability(skillset, contexts)
}
@ -494,7 +495,7 @@ impl<T> AbilitySet<T> {
&self,
skillset: Option<&SkillSet>,
contexts: &[AbilityContext],
) -> Option<(&T, Option<usize>)> {
) -> Option<(&T, Option<ContextualIndex>)> {
self.secondary.ability(skillset, contexts)
}
@ -503,7 +504,7 @@ impl<T> AbilitySet<T> {
index: usize,
skillset: Option<&SkillSet>,
contexts: &[AbilityContext],
) -> Option<(&T, Option<usize>)> {
) -> Option<(&T, Option<ContextualIndex>)> {
self.abilities
.get(index)
.and_then(|a| a.ability(skillset, contexts))

View File

@ -155,12 +155,9 @@ impl CharacterBehavior for Data {
let crit_data = get_crit_data(data, self.static_data.ability_info);
let tool_stats = get_tool_stats(data, self.static_data.ability_info);
let additional_combo = if self.static_data.additional_combo != 0 {
let increment = 1.0 / self.static_data.additional_combo as f32;
(self.charge_amount / increment + 0.5).floor() as i32
} else {
0
};
let additional_combo =
(self.charge_amount * self.static_data.additional_combo as f32 + 0.5)
.floor() as i32;
data.updater.insert(
data.entity,