Merge branch 'core' of ssh://git.mnml.gg:40022/~/mnml into core
This commit is contained in:
commit
b1cb2cec37
@ -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> {
|
||||
self.players.clone()
|
||||
.into_iter()
|
||||
@ -470,16 +480,16 @@ impl Game {
|
||||
fn resolve(&mut self, cast: Cast) -> &mut Game {
|
||||
// Send custom intial cast / hit aoe actions
|
||||
if cast.skill.aoe() {
|
||||
let actions = match cast.skill.cast_animation() {
|
||||
/*let actions = match cast.skill.cast_animation() {
|
||||
true => vec![Action::Cast, Action::HitAoe],
|
||||
false => vec![Action::HitAoe]
|
||||
};
|
||||
self.execute(cast, actions);
|
||||
self.execute(cast, actions);*/
|
||||
}
|
||||
|
||||
let casts = self.modify_cast(cast);
|
||||
for cast in casts {
|
||||
self.execute(cast, cast.actions());
|
||||
self.execute(cast);
|
||||
}
|
||||
|
||||
self
|
||||
@ -494,13 +504,6 @@ impl Game {
|
||||
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() {
|
||||
true => self.players.iter()
|
||||
.find(|t| t.constructs.iter().any(|c| c.id == cast.target))
|
||||
@ -517,13 +520,35 @@ impl Game {
|
||||
return casts;
|
||||
}
|
||||
|
||||
fn execute(&mut self, cast: Cast, actions: Vec<Action>) -> &mut Game {
|
||||
fn execute(&mut self, cast: Cast) -> &mut Game {
|
||||
// this list is used to calculate values
|
||||
// that are dependent on the result of previous events
|
||||
// such as healing based on damage done etc
|
||||
let mut event_list = vec![];
|
||||
|
||||
for action in actions {
|
||||
if let Some(effects) = self.construct(cast.source).disabled(cast.skill) {
|
||||
self.add_resolution(&cast, &Event::Disable { construct: cast.source, effects });
|
||||
return self;
|
||||
}
|
||||
|
||||
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() {
|
||||
let events = match action {
|
||||
Action::Cast => self.cast(cast),
|
||||
Action::Hit => self.hit(cast),
|
||||
@ -539,19 +564,17 @@ impl Game {
|
||||
self.heal(construct, amount, colour)
|
||||
},
|
||||
|
||||
Action::Effect { construct, effect } => self.effect(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::Effect { construct, effect } => self.effect(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),
|
||||
};
|
||||
|
||||
for event in events {
|
||||
// this event is now considered to have happened
|
||||
// for chronological ordering it is added to the resolution list
|
||||
// before extra processing on it begins
|
||||
let last = self.resolutions.len() - 1;
|
||||
self.resolutions[last].push(Resolution::new(cast, event.clone()));
|
||||
|
||||
self.add_resolution(&cast, &event);
|
||||
event_list.push(event);
|
||||
self.event_reactions(&cast, &event_list[event_list.len() - 1]);
|
||||
}
|
||||
@ -560,6 +583,12 @@ impl Game {
|
||||
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 {
|
||||
let casts = match event {
|
||||
Event::Damage { construct, colour, amount, mitigation, display: _ } =>
|
||||
@ -920,11 +949,14 @@ pub enum Event {
|
||||
Healing { construct: Uuid, amount: usize, overhealing: usize, colour: Colour, display: EventConstruct },
|
||||
Inversion { construct: Uuid },
|
||||
Reflection { construct: Uuid },
|
||||
Ko { construct: Uuid },
|
||||
Disable { construct: Uuid, effects: Vec<Effect> },
|
||||
|
||||
TargetKo { construct: Uuid },
|
||||
Ko { construct: Uuid },
|
||||
|
||||
CooldownIncrease { construct: Uuid, turns: usize },
|
||||
CooldownDecrease { construct: Uuid, turns: usize },
|
||||
|
||||
Forfeit (),
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user