reflect
This commit is contained in:
parent
1739045f2c
commit
2bb9482bc5
@ -120,6 +120,16 @@ impl Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn construct(&self, id: Uuid) -> &Construct {
|
||||||
|
self.players.iter()
|
||||||
|
.find(|t| t.constructs.iter().any(|c| c.id == id))
|
||||||
|
.unwrap()
|
||||||
|
.constructs
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.id == id)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
fn all_constructs(&self) -> Vec<Construct> {
|
fn all_constructs(&self) -> Vec<Construct> {
|
||||||
self.players.clone()
|
self.players.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -485,13 +495,6 @@ impl Game {
|
|||||||
return vec![Cast { target: t.id, ..cast }];
|
return vec![Cast { target: t.id, ..cast }];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if self.construct[source].multistrike() {
|
|
||||||
// return vec![
|
|
||||||
// Cast { target: t.id, ..cast },
|
|
||||||
// Cast { target: t.id, ..cast },
|
|
||||||
// ];
|
|
||||||
// }
|
|
||||||
|
|
||||||
let casts = match cast.skill.aoe() {
|
let casts = match cast.skill.aoe() {
|
||||||
true => self.players.iter()
|
true => self.players.iter()
|
||||||
.find(|t| t.constructs.iter().any(|c| c.id == cast.target))
|
.find(|t| t.constructs.iter().any(|c| c.id == cast.target))
|
||||||
@ -514,6 +517,23 @@ impl Game {
|
|||||||
// such as healing based on damage done etc
|
// such as healing based on damage done etc
|
||||||
let mut event_list = vec![];
|
let mut event_list = vec![];
|
||||||
|
|
||||||
|
if self.construct(cast.target).is_ko() {
|
||||||
|
self.add_resolution(&cast, &Event::TargetKo { construct: cast.target });
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.construct(cast.target).affected(Effect::Reflect) && cast.skill.colours().contains(&Colour::Blue) && !cast.skill.is_tick() {
|
||||||
|
self.add_resolution(&cast, &Event::Reflection { construct: cast.target });
|
||||||
|
|
||||||
|
// both reflecting, show it and bail
|
||||||
|
if self.construct(cast.source).affected(Effect::Reflect) {
|
||||||
|
self.add_resolution(&cast, &Event::Reflection { construct: cast.source });
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.execute(Cast { target: cast.source, ..cast });
|
||||||
|
}
|
||||||
|
|
||||||
for action in cast.actions() {
|
for action in cast.actions() {
|
||||||
let events = match action {
|
let events = match action {
|
||||||
Action::Cast => self.cast(cast),
|
Action::Cast => self.cast(cast),
|
||||||
@ -529,19 +549,17 @@ impl Game {
|
|||||||
self.heal(construct, amount, colour)
|
self.heal(construct, amount, colour)
|
||||||
},
|
},
|
||||||
|
|
||||||
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::RemoveAll { construct } => self.remove_all(construct),
|
||||||
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
||||||
};
|
};
|
||||||
|
|
||||||
for event in events {
|
for event in events {
|
||||||
// this event is now considered to have happened
|
// this event is now considered to have happened
|
||||||
// for chronological ordering it is added to the resolution list
|
// for chronological ordering it is added to the resolution list
|
||||||
// before extra processing on it begins
|
// before extra processing on it begins
|
||||||
let last = self.resolutions.len() - 1;
|
self.add_resolution(&cast, &event);
|
||||||
self.resolutions[last].push(Resolution::new(cast, event.clone()));
|
|
||||||
|
|
||||||
event_list.push(event);
|
event_list.push(event);
|
||||||
self.event_reactions(&cast, &event_list[event_list.len() - 1]);
|
self.event_reactions(&cast, &event_list[event_list.len() - 1]);
|
||||||
}
|
}
|
||||||
@ -550,6 +568,12 @@ impl Game {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_resolution(&mut self, cast: &Cast, event: &Event) -> &mut Game {
|
||||||
|
let last = self.resolutions.len() - 1;
|
||||||
|
self.resolutions[last].push(Resolution::new(cast.clone(), event.clone()));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn event_reactions(&mut self, cast: &Cast, event: &Event) -> &mut Game {
|
fn event_reactions(&mut self, cast: &Cast, event: &Event) -> &mut Game {
|
||||||
let casts = match event {
|
let casts = match event {
|
||||||
Event::Damage { construct, colour, amount, mitigation, display: _ } =>
|
Event::Damage { construct, colour, amount, mitigation, display: _ } =>
|
||||||
@ -898,11 +922,14 @@ pub enum Event {
|
|||||||
Healing { construct: Uuid, amount: usize, overhealing: usize, colour: Colour, display: EventConstruct },
|
Healing { construct: Uuid, amount: usize, overhealing: usize, colour: Colour, display: EventConstruct },
|
||||||
Inversion { construct: Uuid },
|
Inversion { construct: Uuid },
|
||||||
Reflection { construct: Uuid },
|
Reflection { construct: Uuid },
|
||||||
Ko { construct: Uuid },
|
Disable { construct: Uuid, effects: Vec<Effect> },
|
||||||
|
|
||||||
TargetKo { construct: Uuid },
|
TargetKo { construct: Uuid },
|
||||||
|
Ko { construct: Uuid },
|
||||||
|
|
||||||
CooldownIncrease { construct: Uuid, turns: usize },
|
CooldownIncrease { construct: Uuid, turns: usize },
|
||||||
CooldownDecrease { construct: Uuid, turns: usize },
|
CooldownDecrease { construct: Uuid, turns: usize },
|
||||||
|
|
||||||
Forfeit (),
|
Forfeit (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user