send cast in event, split up cast and hit
This commit is contained in:
+19
-8
@@ -423,11 +423,11 @@ impl Construct {
|
||||
match skill.cd {
|
||||
Some(cd) => {
|
||||
skill.cd = Some(cd.saturating_add(turns));
|
||||
events.push(EventVariant::CooldownIncrease { turns, skill: skill.skill })
|
||||
events.push(EventVariant::CooldownIncrease { target: self.id, turns })
|
||||
},
|
||||
None => {
|
||||
skill.cd = Some(turns);
|
||||
events.push(EventVariant::CooldownIncrease { turns, skill: skill.skill })
|
||||
events.push(EventVariant::CooldownIncrease { target: self.id, turns })
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -548,7 +548,7 @@ impl Construct {
|
||||
|
||||
pub fn recharge(&mut self, red_amount: usize, blue_amount: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
|
||||
let target = self.id;
|
||||
if self.is_ko() { return events; }
|
||||
|
||||
match self.affected(Effect::Invert) {
|
||||
@@ -565,7 +565,7 @@ impl Construct {
|
||||
let blue = new_blue_life - current_blue_life;
|
||||
|
||||
if red != 0 || blue != 0 {
|
||||
events.push(EventVariant::Recharge { red, blue });
|
||||
events.push(EventVariant::Recharge { target, red, blue });
|
||||
}
|
||||
},
|
||||
true => {
|
||||
@@ -592,6 +592,7 @@ impl Construct {
|
||||
let red_damage_amount = red_current_green_life - self.green_life();
|
||||
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: red_damage_amount,
|
||||
mitigation: red_mitigation,
|
||||
colour: Colour::Red,
|
||||
@@ -621,6 +622,7 @@ impl Construct {
|
||||
let blue_damage_amount = blue_current_green_life - self.green_life();
|
||||
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: blue_damage_amount,
|
||||
mitigation: blue_mitigation,
|
||||
colour: Colour::Blue,
|
||||
@@ -635,6 +637,7 @@ impl Construct {
|
||||
pub fn deal_green_damage(&mut self, amount: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
if self.is_ko() { return events; }
|
||||
let target = self.id;
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::GreenDamageTaken))
|
||||
@@ -654,6 +657,7 @@ impl Construct {
|
||||
let overhealing = modified_power - healing;
|
||||
|
||||
events.push(EventVariant::Healing {
|
||||
target,
|
||||
amount: healing,
|
||||
overhealing,
|
||||
});
|
||||
@@ -667,6 +671,7 @@ impl Construct {
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: delta,
|
||||
mitigation: 0,
|
||||
colour: Colour::Green,
|
||||
@@ -682,6 +687,7 @@ impl Construct {
|
||||
let mut events = vec![];
|
||||
|
||||
if self.is_ko() { return events; }
|
||||
let target = self.id;
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::RedDamageTaken))
|
||||
@@ -710,6 +716,7 @@ impl Construct {
|
||||
|
||||
events.push(
|
||||
EventVariant::Damage {
|
||||
target,
|
||||
amount: delta,
|
||||
mitigation,
|
||||
colour: Colour::Red,
|
||||
@@ -717,7 +724,7 @@ impl Construct {
|
||||
}
|
||||
);
|
||||
if self.is_ko() {
|
||||
events.push(EventVariant::Ko {});
|
||||
events.push(EventVariant::Ko { target });
|
||||
}
|
||||
},
|
||||
true => {
|
||||
@@ -736,6 +743,7 @@ impl Construct {
|
||||
if healing > 0 {
|
||||
events.push(
|
||||
EventVariant::Healing {
|
||||
target,
|
||||
amount: healing,
|
||||
overhealing: overhealing - recharge,
|
||||
}
|
||||
@@ -743,7 +751,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
if recharge > 0 {
|
||||
events.push(EventVariant::Recharge { red: recharge, blue: 0 });
|
||||
events.push(EventVariant::Recharge { target, red: recharge, blue: 0 });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -755,6 +763,7 @@ impl Construct {
|
||||
let mut events = vec![];
|
||||
|
||||
if self.is_ko() { return events; }
|
||||
let target = self.id;
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::BlueDamageTaken))
|
||||
@@ -778,6 +787,7 @@ impl Construct {
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: delta,
|
||||
mitigation,
|
||||
colour: Colour::Blue,
|
||||
@@ -798,11 +808,11 @@ impl Construct {
|
||||
let recharge = self.blue_life.value - current_life;
|
||||
|
||||
if healing > 0 {
|
||||
events.push(EventVariant::Healing { amount: healing, overhealing });
|
||||
events.push(EventVariant::Healing { target, amount: healing, overhealing });
|
||||
}
|
||||
|
||||
if recharge > 0 {
|
||||
events.push(EventVariant::Recharge { red: 0, blue: recharge });
|
||||
events.push(EventVariant::Recharge { target, red: 0, blue: recharge });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -828,6 +838,7 @@ impl Construct {
|
||||
|
||||
// todo modified durations cause of buffs
|
||||
let result = EventVariant::Effect {
|
||||
target: self.id,
|
||||
effect: effect.effect,
|
||||
duration: effect.duration,
|
||||
display: EventConstruct::new(self)
|
||||
|
||||
+4
-4
@@ -41,7 +41,7 @@ pub enum Colour {
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Action {
|
||||
Hit { cast: Cast },
|
||||
HitCast { cast: Cast },
|
||||
Cast { cast: Cast },
|
||||
Damage { cast: Cast, construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Effect { cast: Cast, construct: Uuid, effect: ConstructEffect },
|
||||
IncreaseCooldowns { cast: Cast, construct: Uuid, turns: usize },
|
||||
@@ -507,7 +507,7 @@ impl Game {
|
||||
for action in actions {
|
||||
match action {
|
||||
Action::Hit { cast } => self.hit(cast),
|
||||
Action::HitCast { cast } => self.hit_cast(cast),
|
||||
Action::Cast { cast } => self.cast(cast),
|
||||
Action::Damage { cast, construct, values, colour } => self.damage(cast, construct, values, colour),
|
||||
Action::Effect { cast, construct, effect } => self.effect(cast, construct, effect),
|
||||
Action::IncreaseCooldowns { cast, construct, turns } => self.increase_cooldowns(cast, construct, turns),
|
||||
@@ -517,8 +517,8 @@ impl Game {
|
||||
self
|
||||
}
|
||||
|
||||
fn hit_cast(&mut self, cast: Cast) -> &mut Game {
|
||||
self.event_add(vec![EventVariant::HitCast()], cast);
|
||||
fn cast(&mut self, cast: Cast) -> &mut Game {
|
||||
self.event_add(vec![EventVariant::Cast()], cast);
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
+53
-25
@@ -109,10 +109,13 @@ impl Cast {
|
||||
}
|
||||
|
||||
pub fn actions(&self) -> Vec<Action> {
|
||||
let mut actions = match self.skill.is_tick() {
|
||||
false => vec![Action::HitCast { cast: *self } ],
|
||||
true => vec![Action::Hit { cast: *self } ]
|
||||
};
|
||||
let mut actions = vec![];
|
||||
|
||||
if self.skill.cast_animation() {
|
||||
actions.push(Action::Cast { cast: *self });
|
||||
}
|
||||
|
||||
actions.push(Action::Hit { cast: *self });
|
||||
|
||||
let mut rest = match self.skill {
|
||||
Skill::Amplify => vec![
|
||||
@@ -234,29 +237,23 @@ pub struct Event {
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum EventVariant {
|
||||
Cast (),
|
||||
Hit (),
|
||||
HitCast (),
|
||||
HitAoe (),
|
||||
|
||||
Damage { amount: usize, mitigation: usize, colour: Colour, display: EventConstruct },
|
||||
Effect { effect: Effect, duration: u8, display: EventConstruct },
|
||||
Removal { effect: Option<Effect>, display: EventConstruct },
|
||||
Damage { target: Uuid, amount: usize, mitigation: usize, colour: Colour, display: EventConstruct },
|
||||
Effect { target: Uuid, effect: Effect, duration: u8, display: EventConstruct },
|
||||
Removal { target: Uuid, effect: Option<Effect>, display: EventConstruct },
|
||||
|
||||
Healing { amount: usize, overhealing: usize },
|
||||
Recharge { red: usize, blue: usize },
|
||||
Inversion { skill: Skill },
|
||||
Reflection { skill: Skill },
|
||||
AoeSkill { skill: Skill },
|
||||
Skill { skill: Skill },
|
||||
TargetKo { skill: Skill },
|
||||
// skill not necessary but makes it neater as all events are arrays in js
|
||||
Ko (),
|
||||
Healing { target: Uuid, amount: usize, overhealing: usize },
|
||||
Recharge { target: Uuid, red: usize, blue: usize },
|
||||
Inversion { target: Uuid },
|
||||
Reflection { target: Uuid },
|
||||
Ko { target: Uuid },
|
||||
|
||||
CooldownIncrease { target: Uuid, turns: usize },
|
||||
CooldownDecrease { target: Uuid, turns: usize },
|
||||
Forfeit (),
|
||||
Incomplete (),
|
||||
// not used
|
||||
Evasion { skill: Skill, evasion_rating: usize },
|
||||
|
||||
CooldownIncrease { turns: usize, skill: Skill },
|
||||
CooldownDecrease { turns: usize, skill: Skill },
|
||||
}
|
||||
|
||||
impl EventVariant {
|
||||
@@ -269,7 +266,7 @@ impl EventVariant {
|
||||
|
||||
match self {
|
||||
EventVariant::Hit() => target_duration - combat_text_overlap,
|
||||
EventVariant::HitCast() => target_delay + target_duration - combat_text_overlap,
|
||||
EventVariant::Cast() => target_delay,
|
||||
_ => combat_text_delay,
|
||||
}
|
||||
}
|
||||
@@ -1053,6 +1050,24 @@ impl Skill {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cast_animation(&self) -> bool {
|
||||
match self {
|
||||
Skill::ElectrocuteTick |
|
||||
Skill::ElectrocuteTickPlus |
|
||||
Skill::ElectrocuteTickPlusPlus |
|
||||
Skill::DecayTick |
|
||||
Skill::DecayTickPlus |
|
||||
Skill::DecayTickPlusPlus |
|
||||
Skill::SiphonTick |
|
||||
Skill::SiphonTickPlus |
|
||||
Skill::SiphonTickPlusPlus |
|
||||
Skill::TriageTick |
|
||||
Skill::TriageTickPlus |
|
||||
Skill::TriageTickPlusPlus => false,
|
||||
_ => true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn defensive(&self) -> bool {
|
||||
match self {
|
||||
Skill::Amplify|
|
||||
@@ -1568,7 +1583,20 @@ mod tests {
|
||||
let cast = Cast::new(Uuid::new_v4(), Uuid::new_v4(), Uuid::new_v4(), Skill::Attack);
|
||||
let actions = cast.actions();
|
||||
|
||||
|
||||
match actions[0] {
|
||||
Action::Hit { cast } => {
|
||||
assert_eq!(cast.skill, Skill::Attack);
|
||||
},
|
||||
_ => panic!("{:?}", actions),
|
||||
};
|
||||
|
||||
match actions[1] {
|
||||
Action::Damage { cast: _, construct: _, values: _, colour } => {
|
||||
assert_eq!(colour, Colour::Red);
|
||||
},
|
||||
_ => panic!("{:?}", actions),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// #[test]
|
||||
|
||||
Reference in New Issue
Block a user