specs based on cryp colours

This commit is contained in:
Mashy 2019-05-07 22:39:51 +10:00
parent bffba488d8
commit af03d37404
2 changed files with 39 additions and 39 deletions

View File

@ -123,7 +123,7 @@ impl CrypStat {
// self.recalculate(specs) // self.recalculate(specs)
// } // }
pub fn recalculate(&mut self, specs: &Vec<Spec>, player_colours: &Colours) -> &mut CrypStat { pub fn recalculate(&mut self, specs: &Vec<Spec>, cryp_colours: &Colours, player_colours: &Colours) -> &mut CrypStat {
let specs = specs let specs = specs
.iter() .iter()
.filter(|s| s.affects().contains(&self.stat)) .filter(|s| s.affects().contains(&self.stat))
@ -132,7 +132,7 @@ impl CrypStat {
// applied with fold because it can be zeroed or multiplied // applied with fold because it can be zeroed or multiplied
// but still needs access to the base amount // but still needs access to the base amount
let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base, player_colours)); let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base, cryp_colours, player_colours));
self.value = value; self.value = value;
self.max = value; self.max = value;
@ -267,14 +267,14 @@ impl Cryp {
pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Cryp { pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Cryp {
self.specs.sort_unstable(); self.specs.sort_unstable();
self.red_damage.recalculate(&self.specs, player_colours); self.red_damage.recalculate(&self.specs, &self.colours, player_colours);
self.red_life.recalculate(&self.specs, player_colours); self.red_life.recalculate(&self.specs, &self.colours, player_colours);
self.blue_damage.recalculate(&self.specs, player_colours); self.blue_damage.recalculate(&self.specs, &self.colours, player_colours);
self.blue_life.recalculate(&self.specs, player_colours); self.blue_life.recalculate(&self.specs, &self.colours, player_colours);
self.evasion.recalculate(&self.specs, player_colours); self.evasion.recalculate(&self.specs, &self.colours, player_colours);
self.speed.recalculate(&self.specs, player_colours); self.speed.recalculate(&self.specs, &self.colours, player_colours);
self.green_damage.recalculate(&self.specs, player_colours); self.green_damage.recalculate(&self.specs, &self.colours, player_colours);
self.green_life.recalculate(&self.specs, player_colours); self.green_life.recalculate(&self.specs, &self.colours, player_colours);
self self
} }

View File

@ -59,7 +59,8 @@ impl Spec {
} }
} }
pub fn apply(&self, modified: u64, base: u64, player_colours: &Colours) -> u64 { pub fn apply(&self, modified: u64, base: u64, cryp_colours: &Colours, player_colours: &Colours) -> u64 {
let cryp_colour_total: u64 = (cryp_colours.red + cryp_colours.green + cryp_colours.blue) as u64;
match *self { match *self {
// Upgrades to Damage Spec // Upgrades to Damage Spec
Spec::Damage => modified + base.pct(5), Spec::Damage => modified + base.pct(5),
@ -149,50 +150,49 @@ impl Spec {
if player_colours.blue >= 10 && player_colours.red >= 10 { pct += 20 }; if player_colours.blue >= 10 && player_colours.red >= 10 { pct += 20 };
base.pct(pct) base.pct(pct)
}, },
// Upgrades to HP Spec // Upgrades to HP Spec
Spec::Life => modified + base.pct(5), Spec::Life => modified + base.pct(5),
Spec::GreenLifeI => modified + { Spec::GreenLifeI => modified + {
let mut mult: u64 = 15; let mut mult: u64 = 25;
if player_colours.green >= 5 { mult += 25 }; if player_colours.green >= 5 { mult += 15 };
if player_colours.green >= 10 { mult += 50 }; if player_colours.green >= 10 { mult += 30 };
if player_colours.green >= 20 { mult += 75 }; if player_colours.green >= 20 { mult += 45 };
mult * player_colours.green as u64 mult * cryp_colour_total
}, },
Spec::RedLifeI => modified + { Spec::RedLifeI => modified + {
let mut mult: u64 = 15; let mut mult: u64 = 25;
if player_colours.red >= 5 { mult += 25 }; if player_colours.red >= 5 { mult += 15 };
if player_colours.red >= 10 { mult += 50 }; if player_colours.red >= 10 { mult += 30 };
if player_colours.red >= 20 { mult += 75 }; if player_colours.red >= 20 { mult += 45 };
mult * player_colours.red as u64 mult * cryp_colour_total
}, },
Spec::BlueLifeI => modified + { Spec::BlueLifeI => modified + {
let mut mult: u64 = 15; let mut mult: u64 = 25;
if player_colours.blue >= 5 { mult += 25 }; if player_colours.blue >= 5 { mult += 15 };
if player_colours.blue >= 10 { mult += 50 }; if player_colours.blue >= 10 { mult += 30 };
if player_colours.blue >= 20 { mult += 75 }; if player_colours.blue >= 20 { mult += 45 };
mult * player_colours.blue as u64 mult * cryp_colour_total
}, },
Spec::GRLI => modified + { Spec::GRLI => modified + {
let mut mult: u64 = 10; let mut mult: u64 = 15;
if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { mult += 25 }; if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.green >= 10 && player_colours.red >= 10 { mult += 50 }; if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 };
mult * (player_colours.green + player_colours.red) as u64 mult * cryp_colour_total
}, },
Spec::GBLI => modified + { Spec::GBLI => modified + {
let mut mult: u64 = 10; let mut mult: u64 = 15;
if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { mult += 25 }; if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.green >= 10 && player_colours.red >= 10 { mult += 50 }; if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 };
mult * (player_colours.green + player_colours.red) as u64 mult * cryp_colour_total
}, },
Spec::RBLI => modified + { Spec::RBLI => modified + {
let mut mult: u64 = 10; let mut mult: u64 = 15;
if player_colours.blue >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.blue >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 25 }; if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 50 }; if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 40 };
mult * (player_colours.blue + player_colours.red) as u64 mult * cryp_colour_total
}, },
} }
} }