all skills have item conversion, tidy spec calcs

This commit is contained in:
Mashy 2019-05-29 11:49:58 +10:00
parent 50440a5452
commit c32154e06e
3 changed files with 64 additions and 32 deletions

View File

@ -877,12 +877,42 @@ impl From<Skill> for Item {
Skill::CorruptII => Item::CorruptII,
Skill::CorruptIII => Item::CorruptIII,
// Convert subskills into parent skills
Skill::CorruptionI => Item::CorruptI,
Skill::CorruptionII => Item::CorruptII,
Skill::CorruptionIII => Item::CorruptIII,
Skill::CorruptionTickI => Item::CorruptI,
Skill::CorruptionTickII => Item::CorruptII,
Skill::CorruptionTickIII => Item::CorruptII,
Skill::DecayTickI => Item::DecayI,
Skill::DecayTickII => Item::DecayII,
Skill::DecayTickIII => Item::DecayIII,
Skill::HatredI => Item::HostilityI,
Skill::HatredII => Item::HostilityII,
Skill::HatredIII => Item::HostilityIII,
Skill::HasteStrike => Item::HasteI,
Skill::ImpureBlast => Item::ImpurityI,
Skill::RiposteI => Item::ParryI,
Skill::RiposteII => Item::ParryII,
Skill::RiposteIII => Item::ParryIII,
Skill::SiphonTickI => Item::SiphonI,
Skill::SiphonTickII => Item::SiphonII,
Skill::SiphonTickIII => Item::SiphonIII,
Skill::StrangleTickI => Item::StrangleI,
Skill::StrangleTickII => Item::StrangleII,
Skill::StrangleTickIII => Item::StrangleIII,
Skill::TriageTickI => Item::TriageI,
Skill::TriageTickII => Item::TriageII,
Skill::TriageTickIII => Item::TriageIII,
Skill::TestAttack => Item::Attack,
Skill::TestHeal => Item::HealI,
Skill::TestTouch => Item::TestTouch,
Skill::TestStun => Item::TestStun,
Skill::TestBlock => Item::TestBlock,
Skill::TestParry => Item::TestParry,
Skill::TestSiphon => Item::TestSiphon,
_ => panic!("{:?} not implemented with item conversion", skill),
}
}
}

View File

@ -275,7 +275,7 @@ pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut
// Not used
Skill::Injure => injure(source, target, resolutions, skill),
// Skill::Injure => injure(source, target, resolutions, skill),
// -----------------
// Test
// -----------------
@ -759,7 +759,7 @@ pub enum Skill {
ImpurityI,
ImpurityII,
ImpurityIII,
Injure,
// Injure,
InvertI,
InvertII,
@ -1096,7 +1096,7 @@ impl Skill {
Skill::TriageIII => vec![ConstructEffect {effect: Effect::Triage, duration: 4,
meta: Some(EffectMeta::Skill(Skill::TriageTickIII)), tick: None}],
//Unused
Skill::Injure => vec![ConstructEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }],
// Skill::Injure => vec![ConstructEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }],
_ => {
panic!("{:?} no skill effect", self);
@ -1223,7 +1223,7 @@ impl Skill {
Skill::TauntI => Some(2),
Skill::TauntII => Some(2),
Skill::TauntIII => Some(2),
Skill::Injure => Some(2),
// Skill::Injure => Some(2),
Skill::CorruptI =>Some(1),
Skill::CorruptII =>Some(1),
@ -2042,7 +2042,7 @@ mod tests {
};
}
#[test]
/* #[test]
fn injure_test() {
let mut x = Construct::new()
.named(&"muji".to_string());
@ -2054,7 +2054,7 @@ mod tests {
assert!(y.immune(Skill::HealI).is_some());
// resolutions = heal(&mut y.clone(), &mut y, resolutions);
}
*/
#[test]
fn invert_test() {
let mut x = Construct::new()

View File

@ -22,6 +22,13 @@ pub struct SpecValues {
pub bonuses: Vec<SpecBonus>,
}
impl SpecValues {
pub fn calc_value (&self, c: &Colours) -> u64 {
self.bonuses.iter().fold(self.base, |acc, s| acc + s.get_bonus(c))
}
}
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
pub enum Spec {
Speed,
@ -31,8 +38,7 @@ pub enum Spec {
SpeedRGI,
SpeedGBI,
SpeedRBI,
// Pure redLife has to come first as it applies the base amount
// that is multiplied
Life,
LifeGGI,
LifeRRI,
@ -278,9 +284,7 @@ impl Spec {
Spec::SpeedRGI |
Spec::SpeedGBI |
Spec::SpeedRBI => modified + {
let spec_values = self.values();
base.pct(spec_values.bonuses.iter()
.fold(spec_values.base, |acc, s| acc + s.get_bonus(player_colours)))
base.pct(self.values().calc_value(player_colours))
},
Spec::Life |
@ -290,9 +294,7 @@ impl Spec {
Spec::LifeRGI |
Spec::LifeGBI |
Spec::LifeRBI => modified + {
let spec_values = self.values();
construct_colour_total * (spec_values.bonuses.iter()
.fold(spec_values.base, |acc, s| acc + s.get_bonus(player_colours)))
construct_colour_total * self.values().calc_value(player_colours)
},
}
}