Skip to content

Commit

Permalink
fix: move all default DamageModifierResponse values to use Default::d…
Browse files Browse the repository at this point in the history
…efault instead (#107)

* fix: move all default DamageModifierResponse values to use Default::default instead

This is in preparation for Melee damage handling

* Add non_exhausive to DamageModifierResponse as it will have fields added in the near future

This should be removed once we expect no more fields to be added to the struct.
https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute
This prevents clippy from flagging the use of default on fully-specified struct values.
  • Loading branch information
FlaminSarge authored Apr 23, 2024
1 parent ea5e43f commit 719ccc4
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/perks/exotic_armor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn exotic_armor() {
DamageModifierResponse {
impact_dmg_scale: modifier,
explosive_dmg_scale: modifier,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down
41 changes: 23 additions & 18 deletions src/perks/exotic_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_buff,
explosive_dmg_scale: damage_buff,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -137,7 +137,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_buff,
explosive_dmg_scale: damage_buff,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -178,8 +178,7 @@ pub fn exotic_perks() {
};
DamageModifierResponse {
crit_scale: crit_mult,
explosive_dmg_scale: 1.0,
impact_dmg_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -274,7 +273,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 + (val as f64) * 0.1,
explosive_dmg_scale: 1.0 + (val as f64) * 0.1,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -289,7 +288,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_buff,
explosive_dmg_scale: damage_buff,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -304,7 +303,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_buff,
explosive_dmg_scale: damage_buff,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -411,6 +410,7 @@ pub fn exotic_perks() {
explosive_dmg_scale: 1.48,
impact_dmg_scale: 1.48,
crit_scale,
..Default::default()
}
}),
);
Expand All @@ -427,7 +427,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: dmg_mult,
explosive_dmg_scale: dmg_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -441,7 +441,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: dmg_mult,
explosive_dmg_scale: dmg_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -457,7 +457,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 + damage_mult,
explosive_dmg_scale: 1.0 + damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -493,6 +493,7 @@ pub fn exotic_perks() {
impact_dmg_scale: damage_mult,
explosive_dmg_scale: damage_mult,
crit_scale: crit_mult,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -549,7 +550,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_mult,
explosive_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -684,6 +685,7 @@ pub fn exotic_perks() {
explosive_dmg_scale: damage_mult,
impact_dmg_scale: damage_mult,
crit_scale: crit_mult,
..Default::default()
}
}),
);
Expand All @@ -702,6 +704,7 @@ pub fn exotic_perks() {
explosive_dmg_scale: damage_mult,
impact_dmg_scale: damage_mult,
crit_scale: crit_mult,
..Default::default()
}
}),
);
Expand All @@ -723,7 +726,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
explosive_dmg_scale: damage_mult,
impact_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -740,7 +743,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
explosive_dmg_scale: damage_mult,
impact_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -753,7 +756,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
explosive_dmg_scale: 1.0 + damage_mult,
impact_dmg_scale: 1.0 + damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -773,7 +776,7 @@ pub fn exotic_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 + damage_mult,
explosive_dmg_scale: 1.0 + damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -822,10 +825,12 @@ pub fn exotic_perks() {
add_dmr(
Perks::FullStop,
Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse {
if _input.pvp {
return DamageModifierResponse::default()
}
DamageModifierResponse {
explosive_dmg_scale: 1.0,
impact_dmg_scale: 1.0,
crit_scale: if !_input.pvp { 2.9 } else { 1.0 },
crit_scale: 2.9,
..Default::default()
}
}),
);
Expand Down
1 change: 1 addition & 0 deletions src/perks/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ impl<'a> CalculationInput<'a> {
}
}

#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct DamageModifierResponse {
pub impact_dmg_scale: f64,
Expand Down
1 change: 1 addition & 0 deletions src/perks/meta_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub fn meta_perks() {
crit_scale,
impact_dmg_scale: dmg_scale,
explosive_dmg_scale: dmg_scale,
..Default::default()
}
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/perks/origin_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn origin_perks() {
DamageModifierResponse {
impact_dmg_scale: buff,
explosive_dmg_scale: buff,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -177,7 +177,7 @@ pub fn origin_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_mult,
explosive_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down
16 changes: 7 additions & 9 deletions src/perks/other_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub fn other_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_mult,
explosive_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -384,7 +384,7 @@ pub fn other_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_mult,
explosive_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -400,7 +400,7 @@ pub fn other_perks() {
DamageModifierResponse {
impact_dmg_scale: damage_mult,
explosive_dmg_scale: damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -410,8 +410,7 @@ pub fn other_perks() {
Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse {
DamageModifierResponse {
impact_dmg_scale: 1.125,
explosive_dmg_scale: 1.0,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -422,7 +421,7 @@ pub fn other_perks() {
DamageModifierResponse {
impact_dmg_scale: 0.75,
explosive_dmg_scale: 0.75,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -434,9 +433,8 @@ pub fn other_perks() {
&& _input.calc_data.base_crit_mult < 1.15
{
DamageModifierResponse {
impact_dmg_scale: 1.0,
explosive_dmg_scale: 1.0,
crit_scale: 0.92,
..Default::default()
}
} else {
DamageModifierResponse::default()
Expand Down Expand Up @@ -482,7 +480,7 @@ pub fn other_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.02,
explosive_dmg_scale: 1.02,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down
23 changes: 10 additions & 13 deletions src/perks/year_1_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn year_1_perks() {
DamageModifierResponse {
impact_dmg_scale: out_dmg_scale,
explosive_dmg_scale: out_dmg_scale,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -137,9 +137,8 @@ pub fn year_1_perks() {
crit_mult *= 0.95;
}
return DamageModifierResponse {
impact_dmg_scale: 1.0,
explosive_dmg_scale: 1.0,
crit_scale: crit_mult,
..Default::default()
};
};
DamageModifierResponse::default()
Expand Down Expand Up @@ -168,9 +167,8 @@ pub fn year_1_perks() {
DamageModifierResponse::default()
} else {
DamageModifierResponse {
impact_dmg_scale: 1.0,
explosive_dmg_scale: 1.3,
crit_scale: 1.0,
..Default::default()
}
}
}),
Expand All @@ -197,9 +195,8 @@ pub fn year_1_perks() {
} else {
// let damage_mult = ((1.0 / _input.calc_data.base_crit_mult) * 0.15) + 1.0;
DamageModifierResponse {
impact_dmg_scale: 1.0,
explosive_dmg_scale: 1.3,
crit_scale: 1.0,
..Default::default()
}
}
}),
Expand Down Expand Up @@ -389,8 +386,7 @@ pub fn year_1_perks() {
Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse {
DamageModifierResponse {
impact_dmg_scale: 1.1,
explosive_dmg_scale: 1.0,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -599,7 +595,7 @@ pub fn year_1_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 + damage_mult,
explosive_dmg_scale: 1.0 + damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -615,7 +611,7 @@ pub fn year_1_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 + damage_mult,
explosive_dmg_scale: 1.0 + damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand All @@ -631,7 +627,7 @@ pub fn year_1_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 - damage_mult,
explosive_dmg_scale: 1.0 - damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -716,7 +712,7 @@ pub fn year_1_perks() {
DamageModifierResponse {
impact_dmg_scale: 1.0 + damage_mult,
explosive_dmg_scale: 1.0 + damage_mult,
crit_scale: 1.0,
..Default::default()
}
}),
);
Expand Down Expand Up @@ -855,6 +851,7 @@ pub fn year_1_perks() {
impact_dmg_scale: precision_body / lightweight_body,
explosive_dmg_scale: precision_body / lightweight_body,
crit_scale: precision_crit / lightweight_crit,
..Default::default()
}
}),
);
Expand Down
Loading

0 comments on commit 719ccc4

Please sign in to comment.