nuff of that

This commit is contained in:
ntr
2019-12-11 18:04:42 +10:00
parent d3a8690510
commit 804d3397c7
3 changed files with 24 additions and 35 deletions
-2
View File
@@ -893,8 +893,6 @@ impl Construct {
pub fn effect_add(&mut self, effect: ConstructEffect) -> Vec<Event> {
if self.is_ko() { return vec![Event::TargetKo { construct: self.id }] }
if self.affected(Effect::Banish) { panic!("banish immunity not fixt yet") }
if let Some(p) = self.effects.iter().position(|ce| ce.effect == effect.effect) {
// duplicate effect
// replace existing
+24 -30
View File
@@ -134,15 +134,6 @@ impl Game {
.unwrap()
}
fn copy_constructs(&self) -> Vec<Construct> {
self.players.clone()
.into_iter()
.flat_map(
|t| t.constructs
.into_iter())
.collect::<Vec<Construct>>()
}
pub fn update_construct(&mut self, construct: &mut Construct) -> &mut Game {
match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == construct.id)) {
Some(player) => {
@@ -426,17 +417,19 @@ impl Game {
}
// find their statuses with ticks
let mut ticks = self.copy_constructs()
let mut ticks = self.players
.iter()
.flat_map(
|c| c.effects
.iter()
.cloned()
.filter_map(|e| e.meta)
.filter_map(move |m| match m {
EffectMeta::CastTick { source, target, skill } => Some(Cast::new(source, c.account, target, skill)),
_ => None,
})
.flat_map(|p| p.constructs.iter()
.flat_map(
|c| c.effects
.iter()
.cloned()
.filter_map(|e| e.meta)
.filter_map(move |m| match m {
EffectMeta::CastTick { source, target, skill } => Some(Cast::new(source, c.account, target, skill)),
_ => None,
})
)
).collect::<Vec<Cast>>();
// add them to the stack
@@ -736,18 +729,19 @@ impl Game {
})
.collect::<Vec<Uuid>>();
for mut construct in self.copy_constructs() {
if construct.is_ko() {
continue;
for player in self.players.iter_mut() {
for construct in player.constructs.iter_mut() {
if construct.is_ko() {
continue;
}
if !used_cooldown.contains(&construct.id) {
construct.reduce_cooldowns();
};
// always reduce durations
construct.reduce_effect_durations();
}
if !used_cooldown.contains(&construct.id) {
construct.reduce_cooldowns();
};
// always reduce durations
construct.reduce_effect_durations();
self.update_construct(&mut construct);
}
self