add skills to events
This commit is contained in:
parent
2b22b85acb
commit
9cee9f4bfb
@ -22,6 +22,8 @@ ensure all skills impl
|
|||||||
Skill::Slay -> red attack with bonus somethingorother for blue / maim no healing
|
Skill::Slay -> red attack with bonus somethingorother for blue / maim no healing
|
||||||
Hatred -> damage received converted into bonus dmg
|
Hatred -> damage received converted into bonus dmg
|
||||||
|
|
||||||
|
change inversion to several events
|
||||||
|
|
||||||
make parry semi-aggressive
|
make parry semi-aggressive
|
||||||
constants
|
constants
|
||||||
change to ownership pattern
|
change to ownership pattern
|
||||||
|
|||||||
@ -439,8 +439,10 @@ impl Cryp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn recharge(&mut self) -> Event {
|
pub fn recharge(&mut self) -> Event {
|
||||||
if let Some(immunity) = self.immune(Skill::Recharge) {
|
let skill = Skill::Recharge;
|
||||||
|
if let Some(immunity) = self.immune(skill) {
|
||||||
return Event::Immunity {
|
return Event::Immunity {
|
||||||
|
skill,
|
||||||
immunity,
|
immunity,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -451,13 +453,14 @@ impl Cryp {
|
|||||||
let blue = self.blue_shield.max.saturating_sub(self.blue_shield.value);
|
let blue = self.blue_shield.max.saturating_sub(self.blue_shield.value);
|
||||||
self.blue_shield.value = self.blue_shield.max;
|
self.blue_shield.value = self.blue_shield.max;
|
||||||
|
|
||||||
Event::Recharge { red, blue }
|
Event::Recharge { red, blue, skill }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> Event {
|
pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> Event {
|
||||||
if let Some(immunity) = self.immune(skill) {
|
if let Some(immunity) = self.immune(skill) {
|
||||||
return Event::Immunity {
|
return Event::Immunity {
|
||||||
immunity,
|
immunity,
|
||||||
|
skill,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,6 +483,7 @@ impl Cryp {
|
|||||||
let overhealing = modified_healing - healing;
|
let overhealing = modified_healing - healing;
|
||||||
|
|
||||||
return Event::Healing {
|
return Event::Healing {
|
||||||
|
skill,
|
||||||
amount: healing,
|
amount: healing,
|
||||||
overhealing,
|
overhealing,
|
||||||
};
|
};
|
||||||
@ -491,6 +495,7 @@ impl Cryp {
|
|||||||
let delta = current_hp - self.hp();
|
let delta = current_hp - self.hp();
|
||||||
|
|
||||||
return Event::Inversion {
|
return Event::Inversion {
|
||||||
|
skill,
|
||||||
damage: delta,
|
damage: delta,
|
||||||
healing: 0,
|
healing: 0,
|
||||||
recharge: 0,
|
recharge: 0,
|
||||||
@ -503,6 +508,7 @@ impl Cryp {
|
|||||||
pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> Event {
|
pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> Event {
|
||||||
if let Some(immunity) = self.immune(skill) {
|
if let Some(immunity) = self.immune(skill) {
|
||||||
return Event::Immunity {
|
return Event::Immunity {
|
||||||
|
skill,
|
||||||
immunity,
|
immunity,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -534,6 +540,7 @@ impl Cryp {
|
|||||||
let delta = current_hp - self.hp();
|
let delta = current_hp - self.hp();
|
||||||
|
|
||||||
return Event::Damage {
|
return Event::Damage {
|
||||||
|
skill,
|
||||||
amount: delta,
|
amount: delta,
|
||||||
mitigation,
|
mitigation,
|
||||||
category: Category::RedDamage,
|
category: Category::RedDamage,
|
||||||
@ -554,6 +561,7 @@ impl Cryp {
|
|||||||
damage: 0,
|
damage: 0,
|
||||||
healing,
|
healing,
|
||||||
recharge,
|
recharge,
|
||||||
|
skill,
|
||||||
category: Category::RedDamage,
|
category: Category::RedDamage,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -563,6 +571,7 @@ impl Cryp {
|
|||||||
pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> Event {
|
pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> Event {
|
||||||
if let Some(immunity) = self.immune(skill) {
|
if let Some(immunity) = self.immune(skill) {
|
||||||
return Event::Immunity {
|
return Event::Immunity {
|
||||||
|
skill,
|
||||||
immunity,
|
immunity,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -587,6 +596,7 @@ impl Cryp {
|
|||||||
let delta = current_hp - self.hp();
|
let delta = current_hp - self.hp();
|
||||||
|
|
||||||
return Event::Damage {
|
return Event::Damage {
|
||||||
|
skill,
|
||||||
amount: delta,
|
amount: delta,
|
||||||
mitigation,
|
mitigation,
|
||||||
category: Category::BlueDamage,
|
category: Category::BlueDamage,
|
||||||
@ -604,6 +614,7 @@ impl Cryp {
|
|||||||
let recharge = self.blue_shield.value - current_shield;
|
let recharge = self.blue_shield.value - current_shield;
|
||||||
|
|
||||||
return Event::Inversion {
|
return Event::Inversion {
|
||||||
|
skill,
|
||||||
damage: 0,
|
damage: 0,
|
||||||
healing,
|
healing,
|
||||||
recharge,
|
recharge,
|
||||||
@ -616,6 +627,7 @@ impl Cryp {
|
|||||||
pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> Event {
|
pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> Event {
|
||||||
if let Some(immunity) = self.immune(skill) {
|
if let Some(immunity) = self.immune(skill) {
|
||||||
return Event::Immunity {
|
return Event::Immunity {
|
||||||
|
skill,
|
||||||
immunity,
|
immunity,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -624,6 +636,7 @@ impl Cryp {
|
|||||||
let result = Event::Effect {
|
let result = Event::Effect {
|
||||||
effect: effect.effect,
|
effect: effect.effect,
|
||||||
duration: effect.effect.duration(),
|
duration: effect.effect.duration(),
|
||||||
|
skill,
|
||||||
};
|
};
|
||||||
|
|
||||||
// println!("{:?} {:?} adding effect", self.name, effect.effect);
|
// println!("{:?} {:?} adding effect", self.name, effect.effect);
|
||||||
|
|||||||
@ -435,7 +435,7 @@ impl Game {
|
|||||||
resolutions.reverse();
|
resolutions.reverse();
|
||||||
while let Some(resolution) = resolutions.pop() {
|
while let Some(resolution) = resolutions.pop() {
|
||||||
// fixme for mash
|
// fixme for mash
|
||||||
self.log_resolution(cast.speed, cast.skill, &resolution);
|
self.log_resolution(cast.speed, &resolution);
|
||||||
// the results go into the resolutions
|
// the results go into the resolutions
|
||||||
self.resolved.push(resolution);
|
self.resolved.push(resolution);
|
||||||
}
|
}
|
||||||
@ -490,33 +490,33 @@ impl Game {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log_resolution(&mut self, speed: u64, skill: Skill, resolution: &Resolution) -> &mut Game {
|
fn log_resolution(&mut self, speed: u64, resolution: &Resolution) -> &mut Game {
|
||||||
let Resolution { source, target, event } = resolution;
|
let Resolution { source, target, event } = resolution;
|
||||||
match event {
|
match event {
|
||||||
Event::Ko =>
|
Event::Ko =>
|
||||||
self.log.push(format!("{:} KO!", target.name)),
|
self.log.push(format!("{:} KO!", target.name)),
|
||||||
|
|
||||||
Event::Disable { disable } =>
|
Event::Disable { skill, disable } =>
|
||||||
self.log.push(format!("{:} {:?} {:} disabled {:?}",
|
self.log.push(format!("{:} {:?} {:} disabled {:?}",
|
||||||
source.name, skill, target.name, disable)),
|
source.name, skill, target.name, disable)),
|
||||||
|
|
||||||
Event::Immunity { immunity } =>
|
Event::Immunity { skill, immunity } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
||||||
speed, source.name, skill, target.name, immunity)),
|
speed, source.name, skill, target.name, immunity)),
|
||||||
|
|
||||||
Event::TargetKo =>
|
Event::TargetKo { skill } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} - target is KO",
|
self.log.push(format!("[{:}] {:} {:?} {:} - target is KO",
|
||||||
speed, source.name, skill, target.name)),
|
speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Damage { amount, mitigation, category: _ } =>
|
Event::Damage { skill, amount, mitigation, category: _ } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:} mitigated)",
|
self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:} mitigated)",
|
||||||
speed, source.name, skill, target.name, amount, mitigation)),
|
speed, source.name, skill, target.name, amount, mitigation)),
|
||||||
|
|
||||||
Event::Healing { amount, overhealing } =>
|
Event::Healing { skill, amount, overhealing } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)",
|
self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)",
|
||||||
speed, source.name, skill, target.name, amount, overhealing)),
|
speed, source.name, skill, target.name, amount, overhealing)),
|
||||||
|
|
||||||
Event::Inversion { healing, damage, recharge, category: _ } => {
|
Event::Inversion { skill, healing, damage, recharge, category: _ } => {
|
||||||
match *healing > 0 {
|
match *healing > 0 {
|
||||||
true => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:} ({:} recharge)",
|
true => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:} ({:} recharge)",
|
||||||
speed, source.name, skill, target.name, healing, recharge)),
|
speed, source.name, skill, target.name, healing, recharge)),
|
||||||
@ -525,7 +525,7 @@ impl Game {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Event::Effect { effect, duration } =>
|
Event::Effect { skill, effect, duration } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
||||||
speed, source.name, skill, target.name, effect, duration)),
|
speed, source.name, skill, target.name, effect, duration)),
|
||||||
|
|
||||||
@ -533,11 +533,11 @@ impl Game {
|
|||||||
self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
||||||
speed, source.name, target.name, effect)),
|
speed, source.name, target.name, effect)),
|
||||||
|
|
||||||
Event::Recharge { red, blue } =>
|
Event::Recharge { skill, red, blue } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:}R {:}B",
|
self.log.push(format!("[{:}] {:} {:?} {:} {:}R {:}B",
|
||||||
speed, source.name, skill, target.name, red, blue)),
|
speed, source.name, skill, target.name, red, blue)),
|
||||||
|
|
||||||
Event::Evasion { skill: _, evasion_rating } =>
|
Event::Evasion { skill, evasion_rating } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} evaded ({:}%)",
|
self.log.push(format!("[{:}] {:} {:?} {:} evaded ({:}%)",
|
||||||
speed, source.name, skill, target.name, evasion_rating)),
|
speed, source.name, skill, target.name, evasion_rating)),
|
||||||
|
|
||||||
@ -1150,7 +1150,7 @@ mod tests {
|
|||||||
let Resolution { source, target: _, event } = r;
|
let Resolution { source, target: _, event } = r;
|
||||||
match source.id == x_cryp.id {
|
match source.id == x_cryp.id {
|
||||||
true => match event {
|
true => match event {
|
||||||
Event::Effect { effect, duration } => {
|
Event::Effect { effect, duration, skill: _ } => {
|
||||||
assert!(*effect == Effect::Ruin);
|
assert!(*effect == Effect::Ruin);
|
||||||
assert!(*duration == 1);
|
assert!(*duration == 1);
|
||||||
true
|
true
|
||||||
|
|||||||
@ -72,16 +72,16 @@ impl Resolution {
|
|||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
TargetKo,
|
Disable { skill: Skill, disable: Disable },
|
||||||
Disable { disable: Disable },
|
Immunity { skill: Skill, immunity: Immunity },
|
||||||
Immunity { immunity: Immunity },
|
Damage { skill: Skill, amount: u64, mitigation: u64, category: Category },
|
||||||
Damage { amount: u64, mitigation: u64, category: Category },
|
Healing { skill: Skill, amount: u64, overhealing: u64 },
|
||||||
Healing { amount: u64, overhealing: u64 },
|
Recharge { skill: Skill, red: u64, blue: u64 },
|
||||||
Recharge { red: u64, blue: u64 },
|
Inversion { skill: Skill, healing: u64, damage: u64, recharge: u64, category: Category },
|
||||||
Inversion { healing: u64, damage: u64, recharge: u64, category: Category },
|
Effect { skill: Skill, effect: Effect, duration: u8 },
|
||||||
Effect { effect: Effect, duration: u8 },
|
Removal { effect: Effect },
|
||||||
Removal { effect: Effect },
|
Evasion { skill: Skill, evasion_rating: u64 },
|
||||||
Evasion { skill: Skill, evasion_rating: u64 },
|
TargetKo { skill: Skill },
|
||||||
Ko,
|
Ko,
|
||||||
|
|
||||||
Incomplete,
|
Incomplete,
|
||||||
@ -616,12 +616,12 @@ impl Skill {
|
|||||||
let mut results = vec![];
|
let mut results = vec![];
|
||||||
|
|
||||||
if let Some(disable) = source.disabled(*self) {
|
if let Some(disable) = source.disabled(*self) {
|
||||||
results.push(Resolution::new(source, target).event(Event::Disable { disable }));
|
results.push(Resolution::new(source, target).event(Event::Disable { disable, skill: *self }));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.is_ko() {
|
if target.is_ko() {
|
||||||
results.push(Resolution::new(source, target).event(Event::TargetKo));
|
results.push(Resolution::new(source, target).event(Event::TargetKo { skill: *self }));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,7 +700,7 @@ impl Skill {
|
|||||||
results = match target.affected(Effect::Corrupt) {
|
results = match target.affected(Effect::Corrupt) {
|
||||||
true => match results.iter().any(|r|
|
true => match results.iter().any(|r|
|
||||||
match r.event {
|
match r.event {
|
||||||
Event::Damage { amount: _, mitigation: _, category: _ } => true,
|
Event::Damage { amount: _, mitigation: _, category: _, skill: _ } => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}) {
|
}) {
|
||||||
true => corruption(target, source, results),
|
true => corruption(target, source, results),
|
||||||
@ -976,7 +976,7 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -
|
|||||||
results.push(Resolution::new(source, target).event(siphon_damage.clone()));
|
results.push(Resolution::new(source, target).event(siphon_damage.clone()));
|
||||||
|
|
||||||
match siphon_damage {
|
match siphon_damage {
|
||||||
Event::Damage { amount, mitigation: _, category: _, } => {
|
Event::Damage { amount, mitigation: _, category: _, skill: _ } => {
|
||||||
results.push(Resolution::new(source, source).event(source.deal_green_damage(Skill::Heal, amount)));
|
results.push(Resolution::new(source, source).event(source.deal_green_damage(Skill::Heal, amount)));
|
||||||
},
|
},
|
||||||
_ => panic!("siphon tick damage not dealt {:?}", siphon_damage),
|
_ => panic!("siphon tick damage not dealt {:?}", siphon_damage),
|
||||||
@ -1087,7 +1087,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||||
match event {
|
match event {
|
||||||
Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 50),
|
Event::Damage { amount, mitigation: _, category: _, skill: _ } => assert_eq!(amount, 50),
|
||||||
_ => panic!("not damage"),
|
_ => panic!("not damage"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1110,7 +1110,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||||
match event {
|
match event {
|
||||||
Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 1023),
|
Event::Damage { amount, mitigation: _, category: _, skill: _ } => assert_eq!(amount, 1023),
|
||||||
_ => panic!("not damage"),
|
_ => panic!("not damage"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1141,7 +1141,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||||
match event {
|
match event {
|
||||||
Event::Inversion { damage: _, healing: _, recharge, category: _ } => assert_eq!(recharge, 64),
|
Event::Inversion { damage: _, healing: _, recharge, category: _, skill: _ } => assert_eq!(recharge, 64),
|
||||||
_ => panic!("not inversion"),
|
_ => panic!("not inversion"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1163,7 +1163,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||||
match event {
|
match event {
|
||||||
Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 256),
|
Event::Damage { amount, mitigation: _, category: _, skill: _ } => assert_eq!(amount, 256),
|
||||||
_ => panic!("not damage"),
|
_ => panic!("not damage"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1226,7 +1226,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||||
match event {
|
match event {
|
||||||
Event::Recharge { red, blue } => {
|
Event::Recharge { red, blue, skill: _ } => {
|
||||||
assert!(red == 5);
|
assert!(red == 5);
|
||||||
assert!(blue == 5);
|
assert!(blue == 5);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user