targetko events
This commit is contained in:
parent
157bca6658
commit
a00a3683cb
@ -533,6 +533,8 @@ impl Construct {
|
||||
}
|
||||
|
||||
pub fn damage(&mut self, amount: usize, colour: Colour) -> Vec<Event> {
|
||||
if self.is_ko() { return vec![Event::TargetKo { construct: self.id }] }
|
||||
|
||||
match colour {
|
||||
Colour::Red => self.deal_red_damage(amount),
|
||||
Colour::Blue => self.deal_blue_damage(amount),
|
||||
@ -543,7 +545,6 @@ impl Construct {
|
||||
fn deal_red_damage(&mut self, amount: usize) -> Vec<Event> {
|
||||
let mut events = vec![];
|
||||
|
||||
if self.is_ko() { return events; }
|
||||
let construct = self.id;
|
||||
|
||||
let modified_amount = self.modified_amount(amount, Stat::RedDamageReceived);
|
||||
@ -599,8 +600,6 @@ impl Construct {
|
||||
let red_healing = self.red_life.value - current_red_life;
|
||||
let overhealing = recharge - red_healing;
|
||||
|
||||
println!("{:?} {:?} {:?} {:?}", recharge, green_healing, red_healing, self.red_life);
|
||||
|
||||
if green_healing > 0 {
|
||||
events.push(
|
||||
Event::Healing {
|
||||
@ -630,8 +629,6 @@ impl Construct {
|
||||
|
||||
fn deal_blue_damage(&mut self, amount: usize) -> Vec<Event> {
|
||||
let mut events = vec![];
|
||||
|
||||
if self.is_ko() { return events; }
|
||||
let construct = self.id;
|
||||
|
||||
let modified_amount = self.modified_amount(amount, Stat::BlueDamageReceived);
|
||||
@ -712,7 +709,6 @@ impl Construct {
|
||||
|
||||
fn red_healing(&mut self, amount: usize) -> Vec<Event> {
|
||||
let mut events = vec![];
|
||||
if self.is_ko() { return events; }
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::RedHealingReceived))
|
||||
@ -762,7 +758,6 @@ impl Construct {
|
||||
|
||||
fn green_healing(&mut self, amount: usize) -> Vec<Event> {
|
||||
let mut events = vec![];
|
||||
if self.is_ko() { return events; }
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::GreenHealingReceived))
|
||||
@ -813,7 +808,6 @@ impl Construct {
|
||||
|
||||
fn blue_healing(&mut self, amount: usize) -> Vec<Event> {
|
||||
let mut events = vec![];
|
||||
if self.is_ko() { return events; }
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::BlueHealingReceived))
|
||||
@ -862,7 +856,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
pub fn effect_add(&mut self, effect: ConstructEffect) -> Vec<Event> {
|
||||
if self.is_ko() { return vec![] }
|
||||
if self.is_ko() { return vec![Event::TargetKo { construct: self.id }] }
|
||||
|
||||
if self.affected(Effect::Banish) { panic!("banish immunity not fixt yet") }
|
||||
|
||||
@ -889,7 +883,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
pub fn effect_remove(&mut self, effect: Effect) -> Vec<Event> {
|
||||
if self.is_ko() { return vec![] }
|
||||
if self.is_ko() { return vec![Event::TargetKo { construct: self.id }] }
|
||||
|
||||
if let Some(p) = self.effects.iter().position(|ce| ce.effect == effect) {
|
||||
self.effects.remove(p);
|
||||
@ -905,7 +899,7 @@ impl Construct {
|
||||
|
||||
pub fn remove_all(&mut self) -> Vec<Event> {
|
||||
let mut removals = vec![];
|
||||
if self.is_ko() { return removals }
|
||||
if self.is_ko() { return vec![Event::TargetKo { construct: self.id }] }
|
||||
|
||||
while let Some(ce) = self.effects.pop() {
|
||||
removals.push(Event::Removal {
|
||||
@ -919,7 +913,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
pub fn damage_trigger_casts(&mut self, cast: &Cast, event: &Event) -> Vec<Cast> {
|
||||
if self.is_ko() { return vec![] }
|
||||
if self.is_ko() { return vec![] }
|
||||
|
||||
match event {
|
||||
Event::Damage { construct, colour, amount, mitigation, display: _ } => {
|
||||
|
||||
@ -423,8 +423,8 @@ impl Game {
|
||||
|c| c.effects
|
||||
.iter()
|
||||
.cloned()
|
||||
.filter_map(|e| e.tick))
|
||||
.collect::<Vec<Cast>>();
|
||||
.filter_map(|e| e.tick)
|
||||
).collect::<Vec<Cast>>();
|
||||
|
||||
// add them to the stack
|
||||
self.stack.append(&mut ticks);
|
||||
@ -902,6 +902,7 @@ pub enum Event {
|
||||
Inversion { construct: Uuid },
|
||||
Reflection { construct: Uuid },
|
||||
Ko { construct: Uuid },
|
||||
TargetKo { construct: Uuid },
|
||||
|
||||
CooldownIncrease { construct: Uuid, turns: usize },
|
||||
CooldownDecrease { construct: Uuid, turns: usize },
|
||||
@ -1636,8 +1637,6 @@ mod tests {
|
||||
let target = game.players[1].constructs[0].id;
|
||||
game.add_skill(player_id, source, target, Skill::Attack).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
println!("{:?}", game);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1648,8 +1647,6 @@ mod tests {
|
||||
let target = game.players[1].constructs[0].id;
|
||||
|
||||
game.resolve(Cast::new(source, player_id, target, Skill::Bash));
|
||||
|
||||
println!("{:?}", game.resolutions);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1713,19 +1710,20 @@ mod tests {
|
||||
|
||||
game.resolve(Cast::new(source, player_id, target, Skill::Siphon));
|
||||
|
||||
// assert!(resolutions.iter().any(|r| match r.event {
|
||||
// Event::Damage { construct, colour, amount, mitigation: _, display: _ } =>
|
||||
// construct == target && amount > 0 && colour == Colour::Blue,
|
||||
// _ => false,
|
||||
// }));
|
||||
|
||||
// assert!(resolutions.iter().any(|r| match r.event {
|
||||
// Event::Healing { construct, colour, amount, overhealing: _ } =>
|
||||
// construct == source && amount > 0 && colour == Colour::Green,
|
||||
// _ => false,
|
||||
// }));
|
||||
game = game.resolve_phase_start();
|
||||
let last = game.resolutions.len() - 1;
|
||||
let resolutions = &game.resolutions[last];
|
||||
|
||||
assert!(resolutions.iter().any(|r| match r.event {
|
||||
Event::Damage { construct, colour, amount, mitigation: _, display: _ } =>
|
||||
construct == target && amount > 0 && colour == Colour::Blue,
|
||||
_ => false,
|
||||
}));
|
||||
|
||||
assert!(resolutions.iter().any(|r| match r.event {
|
||||
Event::Healing { construct, colour, amount, overhealing: _ } =>
|
||||
construct == source && amount > 0 && colour == Colour::Green,
|
||||
_ => false,
|
||||
}));
|
||||
println!("{:#?}", resolutions);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user