Merge branch 'core' of ssh://git.mnml.gg:40022/~/mnml into core
This commit is contained in:
commit
2eaf0dc6ee
113
core/src/game.rs
113
core/src/game.rs
@ -497,7 +497,7 @@ impl Game {
|
||||
return targets;
|
||||
}
|
||||
|
||||
fn calculate_amount(&mut self, values: &Vec<Value>, resolutions: &Vec<Resolution>) -> usize {
|
||||
fn calculate_amount(&mut self, values: &Vec<Value>, events: &Vec<Event>) -> usize {
|
||||
values.iter()
|
||||
.fold(0, |total, value| {
|
||||
total + match value {
|
||||
@ -514,9 +514,9 @@ impl Game {
|
||||
Value::ColourSkills { construct, colour, mult } => unimplemented!(),
|
||||
|
||||
Value::DamageTaken { construct, colour, mult } =>
|
||||
resolutions.iter().fold(0, |dmg, res| match res.event {
|
||||
events.iter().fold(0, |dmg, e| match e {
|
||||
Event::Damage { construct: event_construct, amount, mitigation:_, colour: event_colour, display: _ } =>
|
||||
match *construct == event_construct && *colour == event_colour {
|
||||
match *construct == *event_construct && *colour == *event_colour {
|
||||
true => dmg + amount,
|
||||
false => dmg,
|
||||
}
|
||||
@ -532,20 +532,20 @@ impl Game {
|
||||
// calculate values first?
|
||||
// for result damage value need to pass &Resolutions and .find()
|
||||
|
||||
let mut resolved = vec![];
|
||||
let mut event_list = vec![];
|
||||
|
||||
for action in cast.actions() {
|
||||
let events = match action {
|
||||
let mut events = match action {
|
||||
Action::Cast => self.cast(cast),
|
||||
Action::Hit => self.hit(cast),
|
||||
|
||||
Action::Damage { construct, values, colour } => {
|
||||
let amount = self.calculate_amount(&values, &resolved);
|
||||
let amount = self.calculate_amount(&values, &event_list);
|
||||
self.damage(construct, amount, colour)
|
||||
},
|
||||
|
||||
Action::Heal { construct, values, colour } => {
|
||||
let amount = self.calculate_amount(&values, &resolved);
|
||||
let amount = self.calculate_amount(&values, &event_list);
|
||||
self.heal(construct, amount, colour)
|
||||
},
|
||||
|
||||
@ -553,52 +553,17 @@ impl Game {
|
||||
Action::Remove { construct, effect } => self.effect_remove(construct, effect),
|
||||
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
||||
};
|
||||
|
||||
let mut resolutions = events.into_iter()
|
||||
.map(|event| Resolution::new(cast, event))
|
||||
.collect::<Vec<Resolution>>();
|
||||
|
||||
resolved.append(&mut resolutions);
|
||||
event_list.append(&mut events);
|
||||
}
|
||||
|
||||
{
|
||||
let mut r_iter = resolved.iter_mut().peekable();
|
||||
while let Some(r) = r_iter.next() {
|
||||
let set_full_delay = match r.event {
|
||||
Event::Cast { construct: _, player: _, direction: _} => {
|
||||
match r_iter.peek() {
|
||||
Some(next_r) => {
|
||||
match next_r.event {
|
||||
Event::Cast { construct: _, player: _, direction: _} => true,
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
None => true,
|
||||
}
|
||||
},
|
||||
let mut resolutions = vec![];
|
||||
let mut iter = event_list.into_iter().peekable();
|
||||
|
||||
Event::Hit { construct: _, player: _, direction: _} => {
|
||||
match r_iter.peek() {
|
||||
Some(next_r) => {
|
||||
match next_r.event {
|
||||
Event::Cast { construct: _, player: _, direction: _} |
|
||||
Event::Hit { construct: _, player: _, direction: _} => true,
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
None => true,
|
||||
}
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if set_full_delay {
|
||||
r.set_full_delay();
|
||||
}
|
||||
}
|
||||
while let Some(event) = iter.next() {
|
||||
resolutions.push(Resolution::new(cast, event, iter.peek()));
|
||||
}
|
||||
|
||||
self.resolutions.last_mut().unwrap().append(&mut resolved);
|
||||
self.resolutions.last_mut().unwrap().append(&mut resolutions);
|
||||
|
||||
self
|
||||
}
|
||||
@ -916,7 +881,7 @@ pub struct Resolution {
|
||||
}
|
||||
|
||||
impl Resolution {
|
||||
pub fn new(cast: Cast, event: Event) -> Resolution {
|
||||
pub fn new(cast: Cast, event: Event, next_event: Option<&Event>) -> Resolution {
|
||||
|
||||
// maybe map events construct_ids
|
||||
let focus = match event {
|
||||
@ -924,7 +889,8 @@ impl Resolution {
|
||||
_ => vec![cast.source, cast.target],
|
||||
};
|
||||
|
||||
let delay = event.delay();
|
||||
let delay = event.delay(next_event);
|
||||
|
||||
Resolution {
|
||||
skill: cast.skill,
|
||||
delay,
|
||||
@ -932,11 +898,6 @@ impl Resolution {
|
||||
event,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_full_delay(&mut self) -> &mut Resolution {
|
||||
self.delay = self.event.set_full_delay();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub type Disable = Vec<Effect>;
|
||||
@ -964,27 +925,39 @@ pub enum Event {
|
||||
}
|
||||
|
||||
impl Event {
|
||||
fn delay(&self) -> i64 {
|
||||
let target_delay = 500; // Add delay if theres source animation
|
||||
let combat_text_delay = 900; // Time for target animation
|
||||
let combat_text_duration = 1300; // Time for all post skill
|
||||
fn delay(&self, next_event: Option<&Event>) -> i64 {
|
||||
let source_overlapping = 500;
|
||||
let target_overlapping = 900;
|
||||
|
||||
match self {
|
||||
Event::Cast { construct: _, direction: _, player: _ } => target_delay,
|
||||
Event::Hit { construct: _, direction: _, player: _ } |
|
||||
Event::HitAoe { construct: _ } => combat_text_delay,
|
||||
_ => combat_text_duration,
|
||||
}
|
||||
}
|
||||
fn set_full_delay(&self) -> i64 {
|
||||
let source_duration = 1000;
|
||||
let target_duration = 1500;
|
||||
let combat_text_duration = 1300;
|
||||
|
||||
match self {
|
||||
Event::Cast { construct: _, direction: _, player: _ } => source_duration,
|
||||
match self {
|
||||
Event::Cast { construct: _, direction: _, player: _ } => {
|
||||
match next_event {
|
||||
Some(e) => {
|
||||
match e {
|
||||
Event::Cast { construct: _, direction: _, player: _ } => source_duration,
|
||||
_ => source_overlapping,
|
||||
}
|
||||
},
|
||||
None => source_duration
|
||||
}
|
||||
},
|
||||
Event::Hit { construct: _, direction: _, player: _ } |
|
||||
Event::HitAoe { construct: _ } => target_duration,
|
||||
Event::HitAoe { construct: _ } => {
|
||||
match next_event {
|
||||
Some(e) => {
|
||||
match e {
|
||||
Event::Cast { construct: _, direction: _, player: _ } |
|
||||
Event::Hit { construct: _, direction: _, player: _ } => target_duration,
|
||||
_ => target_overlapping,
|
||||
}
|
||||
}
|
||||
None => target_duration,
|
||||
}
|
||||
},
|
||||
_ => combat_text_duration,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user