damage received returns last amount instead of total
This commit is contained in:
parent
4f9385e352
commit
ebc4b703a6
@ -632,11 +632,11 @@ impl Game {
|
|||||||
Value::ColourSkills { construct, colour } =>
|
Value::ColourSkills { construct, colour } =>
|
||||||
self.construct(construct).stat(Stat::Skills(colour)),
|
self.construct(construct).stat(Stat::Skills(colour)),
|
||||||
|
|
||||||
Value::DamageReceived { construct, colour } =>
|
Value::DamageReceived { construct } =>
|
||||||
self.events.iter().fold(0, |dmg, e| match e {
|
self.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: _, display: _ } =>
|
||||||
match construct == *event_construct && colour == *event_colour {
|
match construct == *event_construct {
|
||||||
true => dmg + amount,
|
true => amount + mitigation,
|
||||||
false => dmg,
|
false => dmg,
|
||||||
}
|
}
|
||||||
_ => dmg,
|
_ => dmg,
|
||||||
@ -856,7 +856,7 @@ pub enum Value {
|
|||||||
ColourSkills { construct: Uuid, colour: Colour },
|
ColourSkills { construct: Uuid, colour: Colour },
|
||||||
Effects { construct: Uuid },
|
Effects { construct: Uuid },
|
||||||
Removals { construct: Uuid },
|
Removals { construct: Uuid },
|
||||||
DamageReceived { construct: Uuid, colour: Colour },
|
DamageReceived { construct: Uuid },
|
||||||
TickDamage { construct: Uuid, effect: Effect },
|
TickDamage { construct: Uuid, effect: Effect },
|
||||||
// Affected { construct: Uuid, effect: Effect }, // not an int :(
|
// Affected { construct: Uuid, effect: Effect }, // not an int :(
|
||||||
}
|
}
|
||||||
@ -1295,10 +1295,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #[cfg(test)]
|
|
||||||
// mod tests {
|
|
||||||
// use skill::*;
|
|
||||||
|
|
||||||
// #[test]
|
// #[test]
|
||||||
// fn attack_actions_test() {
|
// fn attack_actions_test() {
|
||||||
// let cast = Cast::new(Uuid::new_v4(), Uuid::new_v4(), Uuid::new_v4(), Skill::Attack);
|
// let cast = Cast::new(Uuid::new_v4(), Uuid::new_v4(), Uuid::new_v4(), Skill::Attack);
|
||||||
@ -1478,48 +1474,6 @@ mod tests {
|
|||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// fn siphon_test() {
|
|
||||||
// let mut x = Construct::new()
|
|
||||||
// .named(&"muji".to_string());
|
|
||||||
|
|
||||||
// let mut y = Construct::new()
|
|
||||||
// .named(&"camel".to_string());
|
|
||||||
|
|
||||||
// x.blue_power.force(256);
|
|
||||||
// x.green_power.force(220);
|
|
||||||
// x.green_life.force(1024);
|
|
||||||
// y.blue_life.force(0);
|
|
||||||
// x.green_life.reduce(512);
|
|
||||||
|
|
||||||
// cast_actions(Skill::Siphon, &mut x, &mut y, vec![]);
|
|
||||||
|
|
||||||
// assert!(y.affected(Effect::Siphon));
|
|
||||||
// assert!(x.green_life() == (512 + 256.pct(Skill::SiphonTick.multiplier()) + 220.pct(Skill::SiphonTick.multiplier())));
|
|
||||||
|
|
||||||
// let Event { source: _, target: _, event, stages: _ } = resolutions.remove(0);
|
|
||||||
// match event {
|
|
||||||
// Event::Effect { effect, skill: _, duration: _, construct_effects: _ } => assert_eq!(effect, Effect::Siphon),
|
|
||||||
// _ => panic!("not siphon"),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let Event { source: _, target: _, event, stages: _ } = resolutions.remove(0);
|
|
||||||
// match event {
|
|
||||||
// Event::Damage { amount, skill: _, mitigation: _, colour: _} => assert_eq!(amount, 256.pct(Skill::SiphonTick.multiplier())
|
|
||||||
// + 220.pct(Skill::SiphonTick.multiplier())),
|
|
||||||
// _ => panic!("not damage siphon"),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let Event { source: _, target, event, stages: _ } = resolutions.remove(0);
|
|
||||||
// match event {
|
|
||||||
// Event::Heal { amount, skill: _, overhealing: _ } => {
|
|
||||||
// assert_eq!(amount, 256.pct(Skill::SiphonTick.multiplier()) + 220.pct(Skill::SiphonTick.multiplier()));
|
|
||||||
// assert_eq!(target.id, x.id);
|
|
||||||
// },
|
|
||||||
// _ => panic!("not healing"),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[test]
|
// #[test]
|
||||||
// fn triage_test() {
|
// fn triage_test() {
|
||||||
// let mut x = Construct::new()
|
// let mut x = Construct::new()
|
||||||
@ -2192,7 +2146,7 @@ mod tests {
|
|||||||
}).count() == 2);
|
}).count() == 2);
|
||||||
|
|
||||||
|
|
||||||
let _siphon_dmg = resolutions.iter().find_map(|r| match r.skill {
|
let siphon_dmg = resolutions.iter().find_map(|r| match r.skill {
|
||||||
Skill::Siphon => {
|
Skill::Siphon => {
|
||||||
match r.event {
|
match r.event {
|
||||||
Event::Damage { construct: _, colour: _, amount, mitigation: _, display: _ } => Some(amount),
|
Event::Damage { construct: _, colour: _, amount, mitigation: _, display: _ } => Some(amount),
|
||||||
@ -2202,24 +2156,12 @@ mod tests {
|
|||||||
_ => None
|
_ => None
|
||||||
}).expect("no siphon dmg");
|
}).expect("no siphon dmg");
|
||||||
|
|
||||||
// let hybrid_dmg = resolutions.iter().find_map(|r| match r.skill {
|
assert!(resolutions.iter().any(|r| match r.event {
|
||||||
// Skill::HybridBlast => {
|
Event::Healing { construct, colour, amount, overhealing, display: _ } => {
|
||||||
// match r.event {
|
construct == source && (amount + overhealing) == siphon_dmg && colour == Colour::Green
|
||||||
// Event::Damage { construct: _, colour: _, amount, mitigation: _, display: _ } => Some(amount),
|
},
|
||||||
// _ => None,
|
_ => false,
|
||||||
// }
|
}));
|
||||||
// },
|
|
||||||
// _ => None
|
|
||||||
// }).expect("no hybrid dmg");
|
|
||||||
|
|
||||||
// assert!(resolutions.iter().any(|r| match r.event {
|
|
||||||
// Event::Healing { construct, colour, amount, overhealing, display: _ } => {
|
|
||||||
// construct == source && (amount + overhealing) == siphon_dmg && colour == Colour::Green
|
|
||||||
// // this works
|
|
||||||
// // construct == source && (amount + overhealing) == (siphon_dmg + hybrid_dmg) && colour == Colour::Green
|
|
||||||
// },
|
|
||||||
// _ => false,
|
|
||||||
// }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -2360,13 +2302,13 @@ mod tests {
|
|||||||
let resolutions = &game.resolutions[last];
|
let resolutions = &game.resolutions[last];
|
||||||
|
|
||||||
assert!(resolutions.iter().any(|r| match r.event {
|
assert!(resolutions.iter().any(|r| match r.event {
|
||||||
Event::Damage { construct, colour, amount, mitigation: _, display: _ } => {
|
Event::Damage { construct, colour, amount, mitigation, display: _ } => {
|
||||||
assert!(construct == target && amount > 0 && colour == Colour::Blue && r.skill == Skill::Blast);
|
assert!(construct == target && amount > 0 && colour == Colour::Blue && r.skill == Skill::Blast);
|
||||||
resolutions.iter().any(|r| match r.event {
|
resolutions.iter().any(|r| match r.event {
|
||||||
Event::Meta { construct, effect, meta } =>
|
Event::Meta { construct, effect, meta } =>
|
||||||
construct == target && effect == Effect::Absorption && {
|
construct == target && effect == Effect::Absorption && {
|
||||||
match meta {
|
match meta {
|
||||||
EffectMeta::AddedDamage(added_dmg) => added_dmg == amount,
|
EffectMeta::AddedDamage(added_dmg) => added_dmg == amount + mitigation,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1002,7 +1002,7 @@ fn siphon(cast: Cast, game: &mut Game, values: Siphon) {
|
|||||||
Action::Heal {
|
Action::Heal {
|
||||||
construct: cast.source,
|
construct: cast.source,
|
||||||
colour: Colour::Green,
|
colour: Colour::Green,
|
||||||
amount: game.value(Value::DamageReceived { construct: cast.target, colour: Colour::Blue }).pct(100),
|
amount: game.value(Value::DamageReceived { construct: cast.target }).pct(100),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1032,7 +1032,7 @@ fn siphon_tick(cast: Cast, game: &mut Game) {
|
|||||||
Action::Heal {
|
Action::Heal {
|
||||||
construct: cast.source,
|
construct: cast.source,
|
||||||
colour: Colour::Green,
|
colour: Colour::Green,
|
||||||
amount: game.value(Value::DamageReceived { construct: cast.target, colour: Colour::Blue }).pct(100),
|
amount: game.value(Value::DamageReceived { construct: cast.target }).pct(100),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1073,7 +1073,7 @@ fn slay(cast: Cast, game: &mut Game, values: Slay) {
|
|||||||
Action::Heal {
|
Action::Heal {
|
||||||
construct: cast.source,
|
construct: cast.source,
|
||||||
colour: Colour::Green,
|
colour: Colour::Green,
|
||||||
amount: game.value(Value::DamageReceived { construct: cast.target, colour: Colour::Red }).pct(values.self_heal_multi()),
|
amount: game.value(Value::DamageReceived { construct: cast.target }).pct(values.self_heal_multi()),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1318,7 +1318,7 @@ fn absorption(cast: Cast, game: &mut Game, values: Absorption) {
|
|||||||
Action::SetEffectMeta {
|
Action::SetEffectMeta {
|
||||||
construct: cast.target,
|
construct: cast.target,
|
||||||
effect: Effect::Absorption,
|
effect: Effect::Absorption,
|
||||||
amount: game.value(Value::DamageReceived { construct: cast.source, colour: Colour::Blue }).pct(100),
|
amount: game.value(Value::DamageReceived { construct: cast.source }).pct(100),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user