This commit is contained in:
ntr 2019-12-09 21:13:23 +10:00
parent 006a670027
commit 39957c0380

View File

@ -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<Value>, events: &Vec<Event>) -> 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<Value>, events: &Vec<Event>) -> 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<Event> {
vec![Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }]
}