From af03d37404ece15f917b208e0159621f9cc30f8c Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 7 May 2019 22:39:51 +1000 Subject: [PATCH] specs based on cryp colours --- server/src/cryp.rs | 20 ++++++++-------- server/src/spec.rs | 58 +++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/server/src/cryp.rs b/server/src/cryp.rs index 647dbc64..5a84b965 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -123,7 +123,7 @@ impl CrypStat { // self.recalculate(specs) // } - pub fn recalculate(&mut self, specs: &Vec, player_colours: &Colours) -> &mut CrypStat { + pub fn recalculate(&mut self, specs: &Vec, cryp_colours: &Colours, player_colours: &Colours) -> &mut CrypStat { let specs = specs .iter() .filter(|s| s.affects().contains(&self.stat)) @@ -132,7 +132,7 @@ impl CrypStat { // applied with fold because it can be zeroed or multiplied // 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.max = value; @@ -267,14 +267,14 @@ impl Cryp { pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Cryp { self.specs.sort_unstable(); - self.red_damage.recalculate(&self.specs, player_colours); - self.red_life.recalculate(&self.specs, player_colours); - self.blue_damage.recalculate(&self.specs, player_colours); - self.blue_life.recalculate(&self.specs, player_colours); - self.evasion.recalculate(&self.specs, player_colours); - self.speed.recalculate(&self.specs, player_colours); - self.green_damage.recalculate(&self.specs, player_colours); - self.green_life.recalculate(&self.specs, player_colours); + self.red_damage.recalculate(&self.specs, &self.colours, player_colours); + self.red_life.recalculate(&self.specs, &self.colours, player_colours); + self.blue_damage.recalculate(&self.specs, &self.colours, player_colours); + self.blue_life.recalculate(&self.specs, &self.colours, player_colours); + self.evasion.recalculate(&self.specs, &self.colours, player_colours); + self.speed.recalculate(&self.specs, &self.colours, player_colours); + self.green_damage.recalculate(&self.specs, &self.colours, player_colours); + self.green_life.recalculate(&self.specs, &self.colours, player_colours); self } diff --git a/server/src/spec.rs b/server/src/spec.rs index 2275c405..d1406908 100644 --- a/server/src/spec.rs +++ b/server/src/spec.rs @@ -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 { // Upgrades to Damage Spec Spec::Damage => modified + base.pct(5), @@ -149,50 +150,49 @@ impl Spec { if player_colours.blue >= 10 && player_colours.red >= 10 { pct += 20 }; base.pct(pct) }, - // Upgrades to HP Spec Spec::Life => modified + base.pct(5), Spec::GreenLifeI => modified + { - let mut mult: u64 = 15; - if player_colours.green >= 5 { mult += 25 }; - if player_colours.green >= 10 { mult += 50 }; - if player_colours.green >= 20 { mult += 75 }; - mult * player_colours.green as u64 + let mut mult: u64 = 25; + if player_colours.green >= 5 { mult += 15 }; + if player_colours.green >= 10 { mult += 30 }; + if player_colours.green >= 20 { mult += 45 }; + mult * cryp_colour_total }, Spec::RedLifeI => modified + { - let mut mult: u64 = 15; - if player_colours.red >= 5 { mult += 25 }; - if player_colours.red >= 10 { mult += 50 }; - if player_colours.red >= 20 { mult += 75 }; - mult * player_colours.red as u64 + let mut mult: u64 = 25; + if player_colours.red >= 5 { mult += 15 }; + if player_colours.red >= 10 { mult += 30 }; + if player_colours.red >= 20 { mult += 45 }; + mult * cryp_colour_total }, Spec::BlueLifeI => modified + { - let mut mult: u64 = 15; - if player_colours.blue >= 5 { mult += 25 }; - if player_colours.blue >= 10 { mult += 50 }; - if player_colours.blue >= 20 { mult += 75 }; - mult * player_colours.blue as u64 + let mut mult: u64 = 25; + if player_colours.blue >= 5 { mult += 15 }; + if player_colours.blue >= 10 { mult += 30 }; + if player_colours.blue >= 20 { mult += 45 }; + mult * cryp_colour_total }, 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 >= 5 && player_colours.red >= 5 { mult += 25 }; - if player_colours.green >= 10 && player_colours.red >= 10 { mult += 50 }; - mult * (player_colours.green + player_colours.red) as u64 + if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 }; + if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 }; + mult * cryp_colour_total }, 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 >= 5 && player_colours.red >= 5 { mult += 25 }; - if player_colours.green >= 10 && player_colours.red >= 10 { mult += 50 }; - mult * (player_colours.green + player_colours.red) as u64 + if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 }; + if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 }; + mult * cryp_colour_total }, 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 >= 5 && player_colours.red >= 5 { mult += 25 }; - if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 50 }; - mult * (player_colours.blue + player_colours.red) as u64 + if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 20 }; + if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 40 }; + mult * cryp_colour_total }, } }