util fn for aoe targets
This commit is contained in:
parent
24f3cb206a
commit
d002e3c58b
@ -177,6 +177,16 @@ impl Game {
|
||||
.collect::<Vec<Cryp>>()
|
||||
}
|
||||
|
||||
pub fn cryp_aoe_targets(&self, cryp_id: Uuid) -> Vec<Uuid> {
|
||||
self.teams.iter()
|
||||
.find(|t| t.cryps.iter().any(|c| c.id == cryp_id))
|
||||
.unwrap()
|
||||
.cryps
|
||||
.iter()
|
||||
.map(|c| c.id)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn update_cryp(&mut self, cryp: &mut Cryp) -> &mut Game {
|
||||
match self.teams.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == cryp.id)) {
|
||||
Some(team) => {
|
||||
|
||||
@ -34,26 +34,17 @@ impl Cast {
|
||||
pub fn finalise(&mut self, game: &mut Game) -> &mut Cast {
|
||||
let mut results = vec![];
|
||||
let mut source = game.cryp_by_id(self.source_cryp_id).unwrap().clone();
|
||||
self.resolution.speed = source.skill_speed(self.skill);
|
||||
|
||||
let targets = match source.skill_is_aoe(self.skill) {
|
||||
true => game.teams.iter()
|
||||
.find(|t| t.cryps.iter().any(|c| c.id == self.target_cryp_id))
|
||||
.unwrap()
|
||||
.cryps
|
||||
.iter()
|
||||
.map(|c| c.id)
|
||||
.collect(),
|
||||
true => game.cryp_aoe_targets(self.target_cryp_id),
|
||||
false => vec![self.target_cryp_id],
|
||||
};
|
||||
|
||||
for target_id in targets {
|
||||
// let mut source = game.cryp_by_id(self.source_cryp_id).unwrap();
|
||||
let mut target = game.cryp_by_id(target_id).unwrap();
|
||||
|
||||
results.append(&mut self.skill.resolve(&mut source, target));
|
||||
|
||||
// self.update_cryp(&mut source);
|
||||
// self.update_cryp(&mut target);
|
||||
}
|
||||
|
||||
self.resolution.results = results;
|
||||
@ -791,7 +782,7 @@ fn triage(cryp: &mut Cryp, target: &mut Cryp, mut results: Vec<ResolutionResult>
|
||||
duration: Effect::Triage.duration(),
|
||||
tick: Some(Cast::new_tick(cryp, target, Skill::TriageTick)),
|
||||
};
|
||||
target.add_effect(Skill::Triage, effect);
|
||||
results.push(target.add_effect(Skill::Triage, effect));
|
||||
return triage_tick(cryp, target, results);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user