cooldowns done as a reaction
This commit is contained in:
parent
a052e515ed
commit
3e3e4040d3
@ -2,6 +2,5 @@
|
||||
check silence skill multiplier
|
||||
game ready not auto starting resolve phase
|
||||
|
||||
infinite counter loop
|
||||
cooldowns set after cast
|
||||
cooldowns reduced after 1 complete cast
|
||||
|
||||
@ -435,9 +435,13 @@ impl Construct {
|
||||
}
|
||||
|
||||
pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Construct {
|
||||
let i = self.skills.iter().position(|s| s.skill == skill).unwrap();
|
||||
self.skills.remove(i);
|
||||
self.skills.push(ConstructSkill::new(skill));
|
||||
// tests force resolve some skills
|
||||
// which cause the game to attempt to put them on cd
|
||||
// even though the construct doesn't know the skill
|
||||
if let Some(i) = self.skills.iter().position(|s| s.skill == skill) {
|
||||
self.skills.remove(i);
|
||||
self.skills.push(ConstructSkill::new(skill));
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@ -579,7 +579,10 @@ impl Game {
|
||||
let casts = match event {
|
||||
Event::Damage { construct, colour: _, amount: _, mitigation: _, display: _ } =>
|
||||
self.construct_by_id(construct).unwrap().damage_trigger_casts(&cast, &event),
|
||||
// Event::Cast {} => set_cooldown()
|
||||
Event::Cast { construct, skill, player: _, target: _, direction: _ } => {
|
||||
self.construct_by_id(construct).unwrap().skill_set_cd(skill);
|
||||
vec![]
|
||||
}
|
||||
Event::Ko { construct } =>
|
||||
self.construct_by_id(construct).unwrap().on_ko(&cast, &event),
|
||||
_ => vec![],
|
||||
@ -719,25 +722,26 @@ impl Game {
|
||||
|
||||
fn progress_durations(&mut self) -> &mut Game {
|
||||
let last = self.resolutions.len() - 1;
|
||||
|
||||
let casters = self.resolutions[last].iter()
|
||||
.filter_map(|r| match r.event {
|
||||
Event::Cast { construct: caster, player: _, direction: _, skill, target: _ } =>
|
||||
match skill.base_cd().is_some() {
|
||||
true => Some(caster),
|
||||
false => None,
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<Uuid>>();
|
||||
|
||||
for player in self.players.iter_mut() {
|
||||
for construct in player.constructs.iter_mut() {
|
||||
if construct.is_ko() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let cooldown = self.resolutions[last].iter()
|
||||
.find_map(|r| match r.event {
|
||||
Event::Cast { construct: caster, player: _, direction: _, skill, target: _ } =>
|
||||
match caster == construct.id && skill.base_cd().is_some() {
|
||||
true => Some(r.skill),
|
||||
false => None,
|
||||
},
|
||||
_ => None,
|
||||
});
|
||||
|
||||
if let Some(skill) = cooldown {
|
||||
construct.skill_set_cd(skill);
|
||||
} else {
|
||||
// cooldowns are set at the end of a resolution
|
||||
if !casters.contains(&construct.id) {
|
||||
construct.reduce_cooldowns();
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user