diff --git a/core/src/game.rs b/core/src/game.rs index 89cbf3f2..84086eb4 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -487,7 +487,7 @@ impl Game { // ]; // } - let targets = match cast.skill.aoe() { + let casts = match cast.skill.aoe() { true => self.players.iter() .find(|t| t.constructs.iter().any(|c| c.id == cast.target)) .unwrap() @@ -500,47 +500,7 @@ impl Game { // check for reflect - return targets; - } - - fn calculate_amount(&mut self, values: &Vec, events: &Vec) -> usize { - values.iter() - .fold(0, |total, value| { - total + match value { - Value::Stat { construct, stat, mult } => - self.construct_by_id(*construct).unwrap().stat(*stat).pct(*mult), - - Value::Fixed { value } => *value, - - Value::Cooldowns { construct, mult } => unimplemented!(), - - Value::Effects { construct, mult } => - self.construct_by_id(*construct).unwrap().effects.len().pct(*mult), - - Value::ColourSkills { construct, colour, mult } => unimplemented!(), - - Value::DamageTaken { construct, colour, mult } => - events.iter().fold(0, |dmg, e| match e { - Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } => - match *construct == *event_construct && *colour == *event_colour { - true => dmg + amount.pct(*mult), - false => dmg, - } - _ => dmg, - }), - - Value::Removals { construct, mult } => - events.iter().fold(0, |dmg, e| match e { - Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } => - match *construct == *event_construct { - true => dmg + amount.pct(*mult), - false => dmg, - } - _ => dmg, - }), - // Skills { construct: Uuid, colour: Colour }, - } - }) + return casts; } fn execute(&mut self, cast: Cast) -> &mut Game { @@ -641,6 +601,46 @@ impl Game { self } + fn calculate_amount(&mut self, values: &Vec, events: &Vec) -> usize { + values.iter() + .fold(0, |total, value| { + total + match value { + Value::Stat { construct, stat, mult } => + self.construct_by_id(*construct).unwrap().stat(*stat).pct(*mult), + + Value::Fixed { value } => *value, + + Value::Cooldowns { construct, mult } => unimplemented!(), + + Value::Effects { construct, mult } => + self.construct_by_id(*construct).unwrap().effects.len().pct(*mult), + + Value::ColourSkills { construct, colour, mult } => unimplemented!(), + + Value::DamageTaken { construct, colour, mult } => + events.iter().fold(0, |dmg, e| match e { + Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } => + match *construct == *event_construct && *colour == *event_colour { + true => dmg + amount.pct(*mult), + false => dmg, + } + _ => dmg, + }), + + Value::Removals { construct, mult } => + events.iter().fold(0, |dmg, e| match e { + Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } => + match *construct == *event_construct { + true => dmg + amount.pct(*mult), + false => dmg, + } + _ => dmg, + }), + // Skills { construct: Uuid, colour: Colour }, + } + }) + } + fn cast(&mut self, cast: Cast) -> Vec { vec![Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }] }