fix logs for immunity and make bots target smarter

This commit is contained in:
ntr 2018-12-13 14:25:50 +11:00
parent 5b0bcd5e3e
commit 40caa6ab37

View File

@ -303,15 +303,26 @@ impl Game {
let mobs = self.team_by_id(mob_team_id).clone(); let mobs = self.team_by_id(mob_team_id).clone();
// TODO attack multiple players based on some criteria // TODO attack multiple players based on some criteria
for incoming_skill_id in self.stack.clone().iter() for (i, incoming_skill_id) in self.stack.clone().iter()
.filter(|s| s.target_cryp_id.is_none() && s.target_team_id == mob_team_id) .filter(|s| s.target_cryp_id.is_none() && s.target_team_id == mob_team_id)
.map(|s| s.id) { .enumerate()
let target_id = match mobs.cryps.iter().find(|c| { .map(|(i, s)| (i, s.id)) {
self.cryp_targetable(mob_team_id, c.id).is_ok()}) // let target_id = match mobs.cryps.iter().find(|c| {
{ // self.cryp_targetable(mob_team_id, c.id).is_ok()})
Some(c) => c.id, // {
None => panic!("could not find a targetable pve cryp"), // Some(c) => c.id,
}; // None => panic!("could not find a targetable pve cryp"),
// };
let targets = mobs.cryps
.iter()
.filter(|c| self.cryp_targetable(mob_team_id, c.id).is_ok())
.collect::<Vec<&Cryp>>();
if targets.len() == 0 {
panic!("could not find a targetable pve cryp");
}
let target_id = targets[i % targets.len()].id;
self.add_target(mob_team_id, target_id, incoming_skill_id).unwrap(); self.add_target(mob_team_id, target_id, incoming_skill_id).unwrap();
} }
} }
@ -418,17 +429,29 @@ impl Game {
for result in cast.resolution.results.iter() { for result in cast.resolution.results.iter() {
match result { match result {
ResolutionResult::Damage { amount, category: _, immunity: _ } => { ResolutionResult::Damage { amount, category: _, immunity } => {
self.log.push(format!("{:} {:?} {:} {:}", source.name, cast.skill, target.name, amount)); match immunity.immune {
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
false => self.log.push(format!("{:} {:?} {:} {:}", source.name, cast.skill, target.name, amount)),
}
}, },
ResolutionResult::Healing { amount, category: _, immunity: _ } => { ResolutionResult::Healing { amount, category: _, immunity } => {
self.log.push(format!("{:} {:?} {:} {:}", source.name, cast.skill, target.name, amount)); match immunity.immune {
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
false => self.log.push(format!("{:} {:?} {:} {:}", source.name, cast.skill, target.name, amount)),
}
}, },
ResolutionResult::Effect { effect, duration, immunity: _ } => { ResolutionResult::Effect { effect, duration, immunity } => {
self.log.push(format!("{:} {:?} {:} {:?} {:}T", source.name, cast.skill, target.name, effect, duration)); match immunity.immune {
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
false => self.log.push(format!("{:} {:?} {:} {:?} {:}T", source.name, cast.skill, target.name, effect, duration)),
}
}, },
ResolutionResult::Removal { effect, immunity: _ } => { ResolutionResult::Removal { effect, immunity } => {
self.log.push(format!("{:?} removed {:} {:?}", source.name, target.name, effect)); match immunity.immune {
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
false => self.log.push(format!("{:?} removed {:} {:?}", source.name, target.name, effect)),
}
}, },
} }
} }