From da57abd1f2e44ce458da4721915781a56863b186 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 7 Jan 2019 15:21:36 +1100 Subject: [PATCH] fix resolve order bug --- server/src/game.rs | 10 +++---- server/src/skill.rs | 64 ++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/server/src/game.rs b/server/src/game.rs index 0ef38a91..f367b565 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -411,16 +411,16 @@ impl Game { self.stack_sort_speed(); // update the stack with the resolved skills - self.stack = self.stack.clone().iter_mut().map(|skill| { + for mut skill in self.stack.clone() { // println!("{:} resolving ", skill); let mut source = self.cryp_by_id(skill.source_cryp_id).unwrap().clone(); let mut target = self.cryp_by_id(skill.target_cryp_id).unwrap().clone(); skill.set_resolution(&mut source, &mut target); - self.log_resolution(&mut source, &mut target, skill); + self.log_resolution(&mut source, &mut target, &skill); - self.resolved.push(skill.clone()); + self.resolved.push(skill); if target.is_ko() && !target.ko_logged { self.log.push(format!("{:} KO", target.name)); @@ -441,9 +441,9 @@ impl Game { // resort the stack after each cast because // the cryp speed may have changed // self.stack_sort_speed(); + }; - return skill.clone(); - }).collect::>(); + // println!("{:#?}", self.resolved); // now Resolve has all been assigned // handle cooldowns and statuses diff --git a/server/src/skill.rs b/server/src/skill.rs index 9bcd9246..23c99d4f 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -653,13 +653,13 @@ impl Skill { } } - pub fn resolve(&self, cryp: &mut Cryp, target: &mut Cryp) -> Resolution { + pub fn resolve(&self, source: &mut Cryp, target: &mut Cryp) -> Resolution { let mut rng = thread_rng(); let _base: u64 = rng.gen(); - let speed = target.skill_speed(*self); + let speed = source.skill_speed(*self); - let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self), speed }; + let resolution = Resolution { skill: *self, results: vec![], disable: source.disabled(*self), speed }; if target.is_ko() { return resolution; @@ -670,20 +670,20 @@ impl Skill { } match self { - Skill::Attack => attack(cryp, target, resolution), + Skill::Attack => attack(source, target, resolution), // ----------------- // Nature // ----------------- - Skill::Block => block(cryp, target, resolution), - Skill::Parry => parry(cryp, target, resolution), - Skill::Evade => evade(cryp, target, resolution), - Skill::Snare => snare(cryp, target, resolution), // TODO prevent physical moves + Skill::Block => block(source, target, resolution), + Skill::Parry => parry(source, target, resolution), + Skill::Evade => evade(source, target, resolution), + Skill::Snare => snare(source, target, resolution), // TODO prevent physical moves Skill::Paralyse => panic!("nyi"), // no physical moves Skill::Strangle => panic!("nyi"), // no physical moves - Skill::Stun => stun(cryp, target, resolution), - Skill::Evasion => evade(cryp, target, resolution), // additional layer of dmg avoidance + Skill::Stun => stun(source, target, resolution), + Skill::Evasion => evade(source, target, resolution), // additional layer of dmg avoidance // ----------------- // Technology @@ -697,10 +697,10 @@ impl Skill { // ----------------- // Preservation // ----------------- - Skill::Heal => heal(cryp, target, resolution), - Skill::Triage => triage(cryp, target, resolution), // hot - Skill::TriageTick => triage_tick(cryp, target, resolution), // hot - Skill::Throw => throw(cryp, target, resolution), // no dmg stun, adds vulnerable + Skill::Heal => heal(source, target, resolution), + Skill::Triage => triage(source, target, resolution), // hot + Skill::TriageTick => triage_tick(source, target, resolution), // hot + Skill::Throw => throw(source, target, resolution), // no dmg stun, adds vulnerable Skill::Charm => panic!("nyi"), // target casts random spell on teammate Skill::Calm => panic!("nyi"), // physical fear, taunt removal Skill::Rez => panic!("nyi"), @@ -708,13 +708,13 @@ impl Skill { // ----------------- // Destruction // ----------------- - Skill::Blast => blast(cryp, target, resolution), - Skill::Amplify => amplify(cryp, target, resolution), // increase magic dmg - Skill::Decay => decay(cryp, target, resolution), // dot - Skill::DecayTick => decay_tick(cryp, target, resolution), // dot - Skill::Drain => drain(cryp, target, resolution), - Skill::DrainTick => drain_tick(cryp, target, resolution), // hot - Skill::Curse => curse(cryp, target, resolution), + Skill::Blast => blast(source, target, resolution), + Skill::Amplify => amplify(source, target, resolution), // increase magic dmg + Skill::Decay => decay(source, target, resolution), // dot + Skill::DecayTick => decay_tick(source, target, resolution), // dot + Skill::Drain => drain(source, target, resolution), + Skill::DrainTick => drain_tick(source, target, resolution), // hot + Skill::Curse => curse(source, target, resolution), Skill::Plague => panic!("nyi"), // dot that spreads every turn Skill::Ruin => panic!("nyi"), // aoe version of blast @@ -722,19 +722,19 @@ impl Skill { // Purity // ----------------- // Skill::Precision => panic!("nyi"), - Skill::Empower => empower(cryp, target, resolution), // increased phys dmg + Skill::Empower => empower(source, target, resolution), // increased phys dmg Skill::Slay => panic!("nyi"), // phys dmg mult by target magic dmg - Skill::Shield => shield(cryp, target, resolution), // target is immune to magic dmg and fx - Skill::Silence => silence(cryp, target, resolution), // target cannot cast spells + Skill::Shield => shield(source, target, resolution), // target is immune to magic dmg and fx + Skill::Silence => silence(source, target, resolution), // target cannot cast spells Skill::Inquiry => panic!("nyi"), // - Skill::Purify => purify(cryp, target, resolution), // dispel all debuffs - Skill::Purge => purge(cryp, target, resolution), // dispel all buffs + Skill::Purify => purify(source, target, resolution), // dispel all debuffs + Skill::Purge => purge(source, target, resolution), // dispel all buffs // ----------------- // Chaos // ----------------- - Skill::Banish => banish(cryp, target, resolution), // TODO prevent all actions - Skill::Hex => hex(cryp, target, resolution), // todo prevent casting + Skill::Banish => banish(source, target, resolution), // TODO prevent all actions + Skill::Hex => hex(source, target, resolution), // todo prevent casting Skill::Fear => panic!("nyi"), // cast random spell on self Skill::Taunt => panic!("nyi"), // target forced to attack Skill::Pause => panic!("nyi"), // speed slow @@ -743,10 +743,10 @@ impl Skill { // Test // ----------------- Skill::TestTouch => Resolution { skill: Skill::TestTouch, results: vec![], disable: Disable::new(), speed: 0 }, - Skill::TestStun => stun(cryp, target, resolution), - Skill::TestBlock => block(cryp, target, resolution), - Skill::TestParry => parry(cryp, target, resolution), - Skill::TestDrain => drain(cryp, target, resolution), + Skill::TestStun => stun(source, target, resolution), + Skill::TestBlock => block(source, target, resolution), + Skill::TestParry => parry(source, target, resolution), + Skill::TestDrain => drain(source, target, resolution), } }