rework damage calculation between resolutions

This commit is contained in:
Mashy
2019-05-31 11:52:30 +10:00
parent ea04192897
commit 23e9870d8f
5 changed files with 105 additions and 131 deletions
+19 -12
View File
@@ -388,6 +388,9 @@ pub type Immunity = Vec<Effect>;
pub struct LogConstruct {
pub id: Uuid,
pub name: String,
pub red: u64,
pub green: u64,
pub blue: u64,
}
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
@@ -400,8 +403,20 @@ pub struct Resolution {
impl Resolution {
fn new(source: &Construct, target: &Construct) -> Resolution {
Resolution {
source: LogConstruct { id: source.id, name: source.name.clone() },
target: LogConstruct { id: target.id, name: target.name.clone() },
source: LogConstruct {
id: source.id,
name: source.name.clone(),
red: source.red_life(),
green: source.green_life(),
blue: source.blue_life(),
},
target: LogConstruct {
id: target.id,
name: target.name.clone(),
red: target.red_life(),
green: target.green_life(),
blue: target.blue_life(),
},
event: Event::Incomplete,
}
}
@@ -1427,14 +1442,6 @@ impl Skill {
}
}
fn touch(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
target.deal_red_damage(skill, 0)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn attack(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_power().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
@@ -1453,7 +1460,7 @@ fn strike(source: &mut Construct, target: &mut Construct, mut results: Resolutio
return results;
}
fn injure(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
/*fn injure(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_power().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
.into_iter()
@@ -1464,7 +1471,7 @@ fn injure(source: &mut Construct, target: &mut Construct, mut results: Resolutio
return results;
}
*/
fn stun(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));