purge
This commit is contained in:
parent
2eaf0dc6ee
commit
3fafad8504
@ -1,3 +1,5 @@
|
|||||||
|
use std::iter;
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
|
||||||
@ -886,6 +888,21 @@ impl Construct {
|
|||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_all(&mut self) -> Vec<Event> {
|
||||||
|
let mut removals = vec![];
|
||||||
|
if self.is_ko() { return removals }
|
||||||
|
|
||||||
|
while let Some(ce) = self.effects.pop() {
|
||||||
|
removals.push(Event::Removal {
|
||||||
|
construct: self.id,
|
||||||
|
effect: ce.effect,
|
||||||
|
display: EventConstruct::new(self),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return removals;
|
||||||
|
}
|
||||||
|
|
||||||
// pub fn evade(&self, skill: Skill) -> Option<Event> {
|
// pub fn evade(&self, skill: Skill) -> Option<Event> {
|
||||||
// if self.evasion.value == 0 {
|
// if self.evasion.value == 0 {
|
||||||
// return None;
|
// return None;
|
||||||
|
|||||||
@ -517,7 +517,7 @@ impl Game {
|
|||||||
events.iter().fold(0, |dmg, e| match e {
|
events.iter().fold(0, |dmg, e| match e {
|
||||||
Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } =>
|
Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } =>
|
||||||
match *construct == *event_construct && *colour == *event_colour {
|
match *construct == *event_construct && *colour == *event_colour {
|
||||||
true => dmg + amount,
|
true => dmg + amount.pct(*mult),
|
||||||
false => dmg,
|
false => dmg,
|
||||||
}
|
}
|
||||||
_ => dmg,
|
_ => dmg,
|
||||||
@ -529,9 +529,6 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve(&mut self, cast: Cast) -> &mut Game {
|
fn resolve(&mut self, cast: Cast) -> &mut Game {
|
||||||
// calculate values first?
|
|
||||||
// for result damage value need to pass &Resolutions and .find()
|
|
||||||
|
|
||||||
let mut event_list = vec![];
|
let mut event_list = vec![];
|
||||||
|
|
||||||
for action in cast.actions() {
|
for action in cast.actions() {
|
||||||
@ -551,6 +548,7 @@ impl Game {
|
|||||||
|
|
||||||
Action::Effect { construct, effect } => self.effect(construct, effect),
|
Action::Effect { construct, effect } => self.effect(construct, effect),
|
||||||
Action::Remove { construct, effect } => self.effect_remove(construct, effect),
|
Action::Remove { construct, effect } => self.effect_remove(construct, effect),
|
||||||
|
Action::RemoveAll { construct } => self.remove_all(construct),
|
||||||
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
||||||
};
|
};
|
||||||
event_list.append(&mut events);
|
event_list.append(&mut events);
|
||||||
@ -659,6 +657,11 @@ impl Game {
|
|||||||
self.construct_by_id(construct).unwrap().effect_remove(effect)
|
self.construct_by_id(construct).unwrap().effect_remove(effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// could be remove by colour etc
|
||||||
|
fn remove_all(&mut self, construct: Uuid) -> Vec<Event> {
|
||||||
|
self.construct_by_id(construct).unwrap().remove_all()
|
||||||
|
}
|
||||||
|
|
||||||
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> Vec<Event> {
|
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> Vec<Event> {
|
||||||
self.construct_by_id(construct).unwrap().increase_cooldowns(turns)
|
self.construct_by_id(construct).unwrap().increase_cooldowns(turns)
|
||||||
}
|
}
|
||||||
@ -868,6 +871,7 @@ pub enum Action {
|
|||||||
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||||
Effect { construct: Uuid, effect: ConstructEffect },
|
Effect { construct: Uuid, effect: ConstructEffect },
|
||||||
Remove { construct: Uuid, effect: Effect },
|
Remove { construct: Uuid, effect: Effect },
|
||||||
|
RemoveAll { construct: Uuid },
|
||||||
IncreaseCooldowns { construct: Uuid, turns: usize },
|
IncreaseCooldowns { construct: Uuid, turns: usize },
|
||||||
// Recharge { skill: Skill, red: usize, blue: usize },
|
// Recharge { skill: Skill, red: usize, blue: usize },
|
||||||
}
|
}
|
||||||
|
|||||||
@ -551,6 +551,34 @@ impl Cast {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
Skill::Purge => vec![
|
||||||
|
Action::Purge {
|
||||||
|
construct: self.target,
|
||||||
|
},
|
||||||
|
Action::Effect {
|
||||||
|
construct: self.target,
|
||||||
|
effect: ConstructEffect { effect: Effect::Purge, duration: 2, meta: None, tick: None }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Skill::PurgePlus => vec![
|
||||||
|
Action::Purge {
|
||||||
|
construct: self.target,
|
||||||
|
},
|
||||||
|
Action::Effect {
|
||||||
|
construct: self.target,
|
||||||
|
effect: ConstructEffect { effect: Effect::Purge, duration: 3, meta: None, tick: None }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Skill::PurgePlusPlus => vec![
|
||||||
|
Action::Purge {
|
||||||
|
construct: self.target,
|
||||||
|
},
|
||||||
|
Action::Effect {
|
||||||
|
construct: self.target,
|
||||||
|
effect: ConstructEffect { effect: Effect::Purge, duration: 4, meta: None, tick: None }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
Skill::Recharge |
|
Skill::Recharge |
|
||||||
Skill::RechargePlus |
|
Skill::RechargePlus |
|
||||||
Skill::RechargePlusPlus => vec![
|
Skill::RechargePlusPlus => vec![
|
||||||
@ -692,6 +720,23 @@ impl Cast {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
Skill::Silence |
|
||||||
|
Skill::SilencePlus |
|
||||||
|
Skill::SilencePlusPlus => vec![
|
||||||
|
Action::Effect {
|
||||||
|
construct: self.target,
|
||||||
|
effect: ConstructEffect { effect: Effect::Silence, duration: 2, meta: None, tick: None },
|
||||||
|
},
|
||||||
|
Action::Damage {
|
||||||
|
construct: self.target,
|
||||||
|
colour: Colour::Red,
|
||||||
|
values: vec![
|
||||||
|
Value::Stat { construct: self.source, stat: Stat::RedPower, mult: self.skill.multiplier() },
|
||||||
|
Value::ColourSkills { construct: self.target, colour: Colour::Blue, mult: self.skill.multiplier() },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
Skill::Strike |
|
Skill::Strike |
|
||||||
Skill::StrikePlus |
|
Skill::StrikePlus |
|
||||||
Skill::StrikePlusPlus => vec![
|
Skill::StrikePlusPlus => vec![
|
||||||
@ -755,47 +800,6 @@ impl Cast {
|
|||||||
|
|
||||||
fn end() {}
|
fn end() {}
|
||||||
|
|
||||||
// fn link(source: &mut Construct, target: &mut Construct, skill: Skill) {
|
|
||||||
// game.event(Event::new(source, target).event(target.effect_remove(skill, skill.effect()[0])));
|
|
||||||
|
|
||||||
// let amount = source.blue_power().pct(skill.multiplier().saturating_mul(target.effects.len() as usize));
|
|
||||||
// target.deal_blue_damage(skill, amount)
|
|
||||||
// .into_iter()
|
|
||||||
// .for_each(|e| game.event(Event::new(source, target).event(e).stages(EventStages::PostOnly)));
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn silence(source: &mut Construct, target: &mut Construct, skill: Skill) {
|
|
||||||
// game.event(Event::new(source, target).event(target.effect_remove(skill, skill.effect()[0])));
|
|
||||||
|
|
||||||
// let s_multi = target.skills
|
|
||||||
// .iter()
|
|
||||||
// .fold(100, |acc, cs| match cs.skill.colours().contains(&Colour::Blue) {
|
|
||||||
// true => acc + 45,
|
|
||||||
// false => acc,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// let amount = source.blue_power().pct(skill.multiplier()).pct(s_multi);
|
|
||||||
// target.deal_blue_damage(skill, amount)
|
|
||||||
// .into_iter()
|
|
||||||
// .for_each(|e| game.event(Event::new(source, target).event(e).stages(EventStages::PostOnly)));
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn purge(source: &mut Construct, target: &mut Construct, skill: Skill) {
|
|
||||||
// game.event(Event::new(source, target).event(Event::Skill { skill }).stages(EventStages::StartEnd));
|
|
||||||
// if target.effects.len() > 0 {
|
|
||||||
// target.effects.clear();
|
|
||||||
// game.event(Event::new(source, target)
|
|
||||||
// .event(Event::Remove { skill, effect: None, construct_effects: target.effects.clone() })
|
|
||||||
// .stages(EventStages::PostOnly));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let effect = skill.effect()[0];
|
|
||||||
// game.event(Event::new(source, target).event(target.effect_remove(skill, effect)).stages(EventStages::PostOnly));
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn purify(source: &mut Construct, target: &mut Construct, skill: Skill) {
|
// fn purify(source: &mut Construct, target: &mut Construct, skill: Skill) {
|
||||||
// game.event(Event::new(source, target).event(Event::Skill { skill }).stages(EventStages::StartEnd));
|
// game.event(Event::new(source, target).event(Event::Skill { skill }).stages(EventStages::StartEnd));
|
||||||
// if target.effects.len() > 0 {
|
// if target.effects.len() > 0 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user