armour init
This commit is contained in:
+27
-3
@@ -50,6 +50,8 @@ pub enum Stat {
|
||||
SpellDamageTaken,
|
||||
Healing,
|
||||
HealingTaken,
|
||||
Armour,
|
||||
SpellShield,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
@@ -91,9 +93,11 @@ pub struct Cryp {
|
||||
pub account: Uuid,
|
||||
pub phys_dmg: CrypStat,
|
||||
pub spell_dmg: CrypStat,
|
||||
pub stamina: CrypStat,
|
||||
pub speed: CrypStat,
|
||||
pub stamina: CrypStat,
|
||||
pub hp: CrypStat,
|
||||
pub armour: CrypStat,
|
||||
pub spell_shield: CrypStat,
|
||||
pub xp: u64,
|
||||
pub lvl: u8,
|
||||
pub skills: Vec<CrypSkill>,
|
||||
@@ -118,6 +122,8 @@ impl Cryp {
|
||||
speed: CrypStat { base: 0, stat: Stat::Speed },
|
||||
stamina: CrypStat { base: 0, stat: Stat::Stamina },
|
||||
hp: CrypStat { base: 0, stat: Stat::Hp },
|
||||
armour: CrypStat { base: 50, stat: Stat::Armour },
|
||||
spell_shield: CrypStat { base: 50, stat: Stat::SpellShield },
|
||||
lvl: 0,
|
||||
xp: 0,
|
||||
skills: vec![],
|
||||
@@ -441,10 +447,21 @@ impl Cryp {
|
||||
|
||||
let modified_phys_dmg = phys_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
|
||||
|
||||
self.hp.reduce(modified_phys_dmg);
|
||||
// calculate amount of damage armour will not absorb
|
||||
// eg 50 armour 25 dmg -> 25 remainder
|
||||
// 50 armour 100 dmg -> 0 remainder
|
||||
let remainder = self.armour.base.saturating_sub(modified_phys_dmg);
|
||||
let mitigation = modified_phys_dmg.saturating_sub(remainder);
|
||||
|
||||
// reduce armour by damage amount
|
||||
self.armour.reduce(modified_phys_dmg);
|
||||
|
||||
// deal remainder to hp
|
||||
self.hp.reduce(remainder);
|
||||
|
||||
return ResolutionResult::Damage {
|
||||
amount: modified_phys_dmg,
|
||||
mitigation,
|
||||
category: Category::PhysDmg,
|
||||
immunity,
|
||||
};
|
||||
@@ -471,7 +488,14 @@ impl Cryp {
|
||||
|
||||
let modified_spell_dmg = spell_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
|
||||
|
||||
self.hp.reduce(modified_spell_dmg);
|
||||
// reduce spell_shield by damage amount
|
||||
self.spell_shield.reduce(modified_spell_dmg);
|
||||
|
||||
// reduce amount by the amount absorbed by spell_shield
|
||||
let remainder = amount.saturating_sub(modified_spell_dmg);
|
||||
|
||||
// deal remainder to hp
|
||||
self.hp.reduce(remainder);
|
||||
|
||||
return ResolutionResult::Damage {
|
||||
amount: modified_spell_dmg,
|
||||
|
||||
+17
-9
@@ -347,28 +347,36 @@ impl Game {
|
||||
|
||||
for result in cast.resolution.results.iter() {
|
||||
match result {
|
||||
ResolutionResult::Damage { amount, category: _, immunity } => {
|
||||
ResolutionResult::Damage { amount, mitigation, category: _, immunity } => {
|
||||
match immunity.immune {
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:} {:?} {:} {:}", cast.resolution.speed, source.name, cast.skill, target.name, amount)),
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:} {:?} {:} {:}",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, amount)),
|
||||
}
|
||||
},
|
||||
ResolutionResult::Healing { amount, overhealing, category: _, immunity } => {
|
||||
match immunity.immune {
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)", cast.resolution.speed, source.name, cast.skill, target.name, amount, overhealing)),
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, amount, overhealing)),
|
||||
}
|
||||
},
|
||||
ResolutionResult::Effect { effect, duration, immunity } => {
|
||||
match immunity.immune {
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T", cast.resolution.speed, source.name, cast.skill, target.name, effect, duration)),
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, effect, duration)),
|
||||
}
|
||||
},
|
||||
ResolutionResult::Removal { effect, immunity } => {
|
||||
match immunity.immune {
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:?} removed {:} {:?}", cast.resolution.speed, source.name, target.name, effect)),
|
||||
true => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
||||
cast.resolution.speed, source.name, cast.skill, target.name, immunity.effects)),
|
||||
false => self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
||||
cast.resolution.speed, source.name, target.name, effect)),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ impl Disable {
|
||||
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub enum ResolutionResult {
|
||||
Damage { amount: u64, category: Category , immunity: Immunity },
|
||||
Damage { amount: u64, mitigation: u64, category: Category , immunity: Immunity },
|
||||
Healing { amount: u64, overhealing: u64, category: Category , immunity: Immunity },
|
||||
Effect { effect: Effect, duration: u8, immunity: Immunity },
|
||||
Removal { effect: Effect, immunity: Immunity },
|
||||
|
||||
Reference in New Issue
Block a user