This commit is contained in:
ntr 2019-03-22 15:58:24 +11:00
parent 5dab6f621b
commit a65d62c86a
5 changed files with 167 additions and 49 deletions

View File

@ -34,6 +34,13 @@ change to ownership pattern
## SOON ## SOON
* vbox drops chances * vbox drops chances
* 50% spec, 25% colour etc * 50% spec, 25% colour etc
* rework damage and resolutions
deal_damage(colour)
resolutions.push(skill()).flatten()
overkill in logs
immunity resolution type
* confirm cryp without skill ready * confirm cryp without skill ready
* iconography * iconography
* aoe skills * aoe skills

View File

@ -297,6 +297,10 @@ impl Cryp {
self.effects.iter().any(|s| s.effect == Effect::Stun) self.effects.iter().any(|s| s.effect == Effect::Stun)
} }
pub fn is_inverted(&self) -> bool {
self.effects.iter().any(|s| s.effect == Effect::Invert)
}
pub fn available_skills(&self) -> Vec<&CrypSkill> { pub fn available_skills(&self) -> Vec<&CrypSkill> {
self.skills.iter() self.skills.iter()
.filter(|s| s.cd.is_none()) .filter(|s| s.cd.is_none())
@ -456,7 +460,7 @@ impl Cryp {
let immune = immunity.immune; let immune = immunity.immune;
if immune { if immune {
ResolutionResult::Healing { return ResolutionResult::Healing {
amount: 0, amount: 0,
overhealing: 0, overhealing: 0,
immunity: immunity.clone(), immunity: immunity.clone(),
@ -472,6 +476,8 @@ impl Cryp {
let modified_healing = healing_mods.iter().fold(amount, |acc, m| m.apply(acc)); let modified_healing = healing_mods.iter().fold(amount, |acc, m| m.apply(acc));
match self.is_inverted() {
false => {
let current_hp = self.hp(); let current_hp = self.hp();
self.hp.increase(modified_healing); self.hp.increase(modified_healing);
let new_hp = self.hp.value; let new_hp = self.hp.value;
@ -484,6 +490,20 @@ impl Cryp {
overhealing, overhealing,
immunity, immunity,
}; };
},
true => {
// there is no green shield (yet)
self.hp.reduce(modified_healing);
return ResolutionResult::Inversion {
damage: modified_healing,
healing: 0,
recharge: 0,
category: Category::GreenDamage,
immunity,
};
}
}
} }
pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> ResolutionResult { pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> ResolutionResult {
@ -508,6 +528,8 @@ impl Cryp {
let modified_damage = red_damage_mods.iter().fold(amount, |acc, m| m.apply(acc)); let modified_damage = red_damage_mods.iter().fold(amount, |acc, m| m.apply(acc));
match self.is_inverted() {
false => {
// calculate amount of damage red_shield will not absorb // calculate amount of damage red_shield will not absorb
// eg 50 red_shield 25 damage -> 0 remainder 25 mitigation // eg 50 red_shield 25 damage -> 0 remainder 25 mitigation
// 50 red_shield 100 damage -> 50 remainder 50 mitigation // 50 red_shield 100 damage -> 50 remainder 50 mitigation
@ -527,6 +549,27 @@ impl Cryp {
category: Category::RedDamage, category: Category::RedDamage,
immunity, immunity,
}; };
},
true => {
let current_hp = self.hp();
self.hp.increase(modified_damage);
let new_hp = self.hp.value;
let healing = new_hp - current_hp;
let overhealing = modified_damage - healing;
let current_shield = self.red_shield.value;
self.red_shield.increase(overhealing);
let recharge = self.red_shield.value - current_shield;
return ResolutionResult::Inversion {
damage: 0,
healing,
recharge,
immunity,
category: Category::RedDamage,
};
}
}
} }
pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> ResolutionResult { pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> ResolutionResult {
@ -548,8 +591,10 @@ impl Cryp {
.collect::<Vec<Effect>>(); .collect::<Vec<Effect>>();
// println!("{:?}", blue_damage_mods); // println!("{:?}", blue_damage_mods);
let modified_damage = blue_damage_mods.iter().fold(amount, |acc, m| m.apply(acc)); let modified_damage = blue_damage_mods.iter().fold(amount, |acc, m| m.apply(acc));
match self.is_inverted() {
false => {
let remainder = modified_damage.saturating_sub(self.blue_shield.value); let remainder = modified_damage.saturating_sub(self.blue_shield.value);
let mitigation = modified_damage.saturating_sub(remainder); let mitigation = modified_damage.saturating_sub(remainder);
@ -562,6 +607,27 @@ impl Cryp {
category: Category::BlueDamage, category: Category::BlueDamage,
immunity, immunity,
}; };
},
true => {
let current_hp = self.hp();
self.hp.increase(modified_damage);
let new_hp = self.hp.value;
let healing = new_hp - current_hp;
let overhealing = modified_damage - healing;
let current_shield = self.blue_shield.value;
self.blue_shield.increase(overhealing);
let recharge = self.blue_shield.value - current_shield;
return ResolutionResult::Inversion {
damage: 0,
healing,
recharge,
immunity,
category: Category::BlueDamage,
};
}
}
} }
pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> ResolutionResult { pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> ResolutionResult {

View File

@ -382,6 +382,18 @@ impl Game {
cast.resolution.speed, source.name, cast.skill, target.name, amount, overhealing)), cast.resolution.speed, source.name, cast.skill, target.name, amount, overhealing)),
} }
}, },
ResolutionResult::Inversion { healing, damage, recharge, category: _, immunity } => {
match immunity.immune {
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
false => match *healing > 0 {
true => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:} ({:} recharge)",
cast.resolution.speed, source.name, cast.skill, target.name, healing, recharge)),
false => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:}",
cast.resolution.speed, source.name, cast.skill, target.name, damage)),
}
}
},
ResolutionResult::Effect { effect, duration, immunity } => { ResolutionResult::Effect { effect, duration, immunity } => {
match immunity.immune { match immunity.immune {
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",

View File

@ -63,6 +63,7 @@ pub enum ResolutionResult {
Damage { amount: u64, mitigation: u64, category: Category , immunity: Immunity }, Damage { amount: u64, mitigation: u64, category: Category , immunity: Immunity },
Healing { amount: u64, overhealing: u64, immunity: Immunity }, Healing { amount: u64, overhealing: u64, immunity: Immunity },
Recharge { red: u64, blue: u64, immunity: Immunity }, Recharge { red: u64, blue: u64, immunity: Immunity },
Inversion { healing: u64, damage: u64, recharge: u64, category: Category, immunity: Immunity },
Effect { effect: Effect, duration: u8, immunity: Immunity }, Effect { effect: Effect, duration: u8, immunity: Immunity },
Removal { effect: Effect, immunity: Immunity }, Removal { effect: Effect, immunity: Immunity },
Evasion { skill: Skill, evasion_rating: u64 }, Evasion { skill: Skill, evasion_rating: u64 },
@ -305,6 +306,7 @@ pub enum Category {
BlueBuff, BlueBuff,
BlueTick, BlueTick,
Green, Green,
GreenDamage,
GreenBuff, GreenBuff,
Ko, Ko,
} }
@ -959,6 +961,37 @@ mod tests {
}; };
} }
#[test]
fn invert_test() {
let mut x = Cryp::new()
.named(&"muji".to_string());
let mut y = Cryp::new()
.named(&"camel".to_string());
// give red shield but reduce to 0
y.red_shield.force(64);
y.red_shield.reduce(64);
x.red_damage.force(256 + 64);
invert(&mut y.clone(), &mut y, Resolution::new(Skill::Invert));
assert!(y.is_inverted());
// heal should deal green damage
heal(&mut x, &mut y, Resolution::new(Skill::Heal));
assert!(y.hp() == 768);
// attack should heal and recharge red shield
let res = attack(&mut x, &mut y, Resolution::new(Skill::Attack));
assert!(y.hp() == 1024);
match res.results[0] {
ResolutionResult::Inversion { damage: _, healing: _, recharge, category: _, immunity: _ } => assert_eq!(recharge, 64),
_ => panic!("not inversion"),
};
}
#[test] #[test]
fn triage_test() { fn triage_test() {
let mut x = Cryp::new() let mut x = Cryp::new()