fix tests, add speed to resolutions
This commit is contained in:
parent
c3cfe436bc
commit
e988cc62c1
@ -10,12 +10,9 @@ strangle
|
|||||||
|
|
||||||
|
|
||||||
## NOW
|
## NOW
|
||||||
* mobs heal own team
|
* add speed to log
|
||||||
* clean up categories
|
* clean up categories
|
||||||
|
|
||||||
* cryp speed
|
|
||||||
* modifies skill base speed
|
|
||||||
|
|
||||||
## SOON
|
## SOON
|
||||||
* aoe skills
|
* aoe skills
|
||||||
|
|
||||||
|
|||||||
@ -371,6 +371,10 @@ impl Cryp {
|
|||||||
return modified_spell_dmg;
|
return modified_spell_dmg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn skill_speed(&self, s: Skill) -> u64 {
|
||||||
|
self.speed().saturating_mul(s.speed() as u64)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn speed(&self) -> u64 {
|
pub fn speed(&self) -> u64 {
|
||||||
let speed_mods = self.effects.iter()
|
let speed_mods = self.effects.iter()
|
||||||
.filter(|e| e.effect.modifications().contains(&Stat::Speed))
|
.filter(|e| e.effect.modifications().contains(&Stat::Speed))
|
||||||
|
|||||||
@ -349,26 +349,26 @@ impl Game {
|
|||||||
match result {
|
match result {
|
||||||
ResolutionResult::Damage { amount, category: _, immunity } => {
|
ResolutionResult::Damage { amount, category: _, immunity } => {
|
||||||
match immunity.immune {
|
match immunity.immune {
|
||||||
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
|
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||||
false => self.log.push(format!("{:} {:?} {:} {:}", source.name, cast.skill, target.name, amount)),
|
false => self.log.push(format!("[{:}] {:} {:?} {:} {:}", cast.resolution.speed, source.name, cast.skill, target.name, amount)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ResolutionResult::Healing { amount, overhealing, category: _, immunity } => {
|
ResolutionResult::Healing { amount, overhealing, category: _, immunity } => {
|
||||||
match immunity.immune {
|
match immunity.immune {
|
||||||
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
|
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||||
false => self.log.push(format!("{:} {:?} {:} {:} ({:}OH)", source.name, cast.skill, target.name, amount, overhealing)),
|
false => self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)", cast.resolution.speed, source.name, cast.skill, target.name, amount, overhealing)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ResolutionResult::Effect { effect, duration, immunity } => {
|
ResolutionResult::Effect { effect, duration, immunity } => {
|
||||||
match immunity.immune {
|
match immunity.immune {
|
||||||
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
|
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||||
false => self.log.push(format!("{:} {:?} {:} {:?} {:}T", source.name, cast.skill, target.name, effect, duration)),
|
false => self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T", cast.resolution.speed, source.name, cast.skill, target.name, effect, duration)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ResolutionResult::Removal { effect, immunity } => {
|
ResolutionResult::Removal { effect, immunity } => {
|
||||||
match immunity.immune {
|
match immunity.immune {
|
||||||
true => self.log.push(format!("{:} {:?} {:} immune {:?}", source.name, cast.skill, target.name, immunity.effects)),
|
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||||
false => self.log.push(format!("{:?} removed {:} {:?}", source.name, target.name, effect)),
|
false => self.log.push(format!("[{:}] {:?} removed {:} {:?}", cast.resolution.speed, source.name, target.name, effect)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ impl Game {
|
|||||||
let mut sorted = self.stack.clone();
|
let mut sorted = self.stack.clone();
|
||||||
sorted.sort_unstable_by_key(|s| -> u64 {
|
sorted.sort_unstable_by_key(|s| -> u64 {
|
||||||
let caster = self.cryp_by_id(s.source_cryp_id).unwrap();
|
let caster = self.cryp_by_id(s.source_cryp_id).unwrap();
|
||||||
caster.speed().saturating_mul(s.skill.speed() as u64)
|
caster.skill_speed(s.skill)
|
||||||
});
|
});
|
||||||
|
|
||||||
self.stack = sorted;
|
self.stack = sorted;
|
||||||
@ -821,6 +821,7 @@ mod tests {
|
|||||||
.learn(Skill::TestParry)
|
.learn(Skill::TestParry)
|
||||||
.learn(Skill::TestDrain)
|
.learn(Skill::TestDrain)
|
||||||
.learn(Skill::Empower)
|
.learn(Skill::Empower)
|
||||||
|
.learn(Skill::Stun)
|
||||||
.learn(Skill::Block)
|
.learn(Skill::Block)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
@ -834,6 +835,7 @@ mod tests {
|
|||||||
.learn(Skill::TestParry)
|
.learn(Skill::TestParry)
|
||||||
.learn(Skill::TestDrain)
|
.learn(Skill::TestDrain)
|
||||||
.learn(Skill::Empower)
|
.learn(Skill::Empower)
|
||||||
|
.learn(Skill::Stun)
|
||||||
.learn(Skill::Block)
|
.learn(Skill::Block)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
@ -1000,6 +1002,13 @@ mod tests {
|
|||||||
let x_cryp = x_team.cryps[0].clone();
|
let x_cryp = x_team.cryps[0].clone();
|
||||||
let y_cryp = y_team.cryps[0].clone();
|
let y_cryp = y_team.cryps[0].clone();
|
||||||
|
|
||||||
|
// should auto progress back to skill phase
|
||||||
|
assert!(game.phase == Phase::Skill);
|
||||||
|
|
||||||
|
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
||||||
|
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Stun).is_some());
|
||||||
|
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
||||||
|
|
||||||
let _x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestTouch).unwrap();
|
let _x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestTouch).unwrap();
|
||||||
game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
|
game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
|
||||||
|
|
||||||
@ -1007,21 +1016,17 @@ mod tests {
|
|||||||
|
|
||||||
// should auto progress back to skill phase
|
// should auto progress back to skill phase
|
||||||
assert!(game.phase == Phase::Skill);
|
assert!(game.phase == Phase::Skill);
|
||||||
|
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Stun).is_none());
|
||||||
// after 1 turn block should be off cooldown
|
|
||||||
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
|
||||||
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Empower).is_some());
|
|
||||||
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
|
||||||
|
|
||||||
// second round
|
// second round
|
||||||
// now we block and it should go back on cd
|
// now we block and it should go back on cd
|
||||||
let _x_block_id = game.add_skill(x_team.id, x_cryp.id, None, Skill::Block).unwrap();
|
let _x_block_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::Stun).unwrap();
|
||||||
let _y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
|
let _y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
|
||||||
|
|
||||||
game.resolve_phase_start();
|
game.resolve_phase_start();
|
||||||
|
|
||||||
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Stun).is_some());
|
||||||
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Empower).is_none());
|
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@ -76,12 +76,13 @@ pub enum ResolutionResult {
|
|||||||
pub struct Resolution {
|
pub struct Resolution {
|
||||||
pub skill: Skill,
|
pub skill: Skill,
|
||||||
pub disable: Disable,
|
pub disable: Disable,
|
||||||
|
pub speed: u64,
|
||||||
pub results: Vec<ResolutionResult>,
|
pub results: Vec<ResolutionResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Resolution {
|
impl Resolution {
|
||||||
fn new(skill: Skill) -> Resolution {
|
fn new(skill: Skill) -> Resolution {
|
||||||
Resolution { skill, results: vec![], disable: Disable::new() }
|
Resolution { skill, results: vec![], disable: Disable::new(), speed: 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +403,7 @@ impl Skill {
|
|||||||
|
|
||||||
// Strangle
|
// Strangle
|
||||||
|
|
||||||
Skill::Stun => None,
|
Skill::Stun => Some(1),
|
||||||
Skill::Evade => None,
|
Skill::Evade => None,
|
||||||
Skill::Evasion => None, // additional layer of dmg avoidance
|
Skill::Evasion => None, // additional layer of dmg avoidance
|
||||||
|
|
||||||
@ -423,8 +424,8 @@ impl Skill {
|
|||||||
Skill::TriageTick => None,
|
Skill::TriageTick => None,
|
||||||
Skill::Throw => Some(1), // no dmg stun, adds vulnerable
|
Skill::Throw => Some(1), // no dmg stun, adds vulnerable
|
||||||
Skill::Charm => Some(1),
|
Skill::Charm => Some(1),
|
||||||
Skill::Calm => Some(1),
|
Skill::Calm => None,
|
||||||
Skill::Rez => Some(4),
|
Skill::Rez => Some(2),
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
// Destruction
|
// Destruction
|
||||||
@ -433,7 +434,7 @@ impl Skill {
|
|||||||
Skill::Amplify => Some(1),
|
Skill::Amplify => Some(1),
|
||||||
Skill::Decay => None, // dot
|
Skill::Decay => None, // dot
|
||||||
Skill::DecayTick => None,
|
Skill::DecayTick => None,
|
||||||
Skill::Drain => Some(2),
|
Skill::Drain => Some(1),
|
||||||
Skill::DrainTick => None,
|
Skill::DrainTick => None,
|
||||||
Skill::Curse => Some(1),
|
Skill::Curse => Some(1),
|
||||||
Skill::Plague => Some(1), // aoe dot
|
Skill::Plague => Some(1), // aoe dot
|
||||||
@ -656,7 +657,9 @@ impl Skill {
|
|||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
let _base: u64 = rng.gen();
|
let _base: u64 = rng.gen();
|
||||||
|
|
||||||
let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self) };
|
let speed = target.skill_speed(*self);
|
||||||
|
|
||||||
|
let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self), speed };
|
||||||
|
|
||||||
if target.is_ko() {
|
if target.is_ko() {
|
||||||
return resolution;
|
return resolution;
|
||||||
@ -739,7 +742,7 @@ impl Skill {
|
|||||||
// -----------------
|
// -----------------
|
||||||
// Test
|
// Test
|
||||||
// -----------------
|
// -----------------
|
||||||
Skill::TestTouch => Resolution { skill: Skill::TestTouch, results: vec![], disable: Disable::new() },
|
Skill::TestTouch => Resolution { skill: Skill::TestTouch, results: vec![], disable: Disable::new(), speed: 0 },
|
||||||
Skill::TestStun => stun(cryp, target, resolution),
|
Skill::TestStun => stun(cryp, target, resolution),
|
||||||
Skill::TestBlock => block(cryp, target, resolution),
|
Skill::TestBlock => block(cryp, target, resolution),
|
||||||
Skill::TestParry => parry(cryp, target, resolution),
|
Skill::TestParry => parry(cryp, target, resolution),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user