2019-09-25 15:52:58 +00:00
|
|
|
use crate::comp;
|
2020-07-06 14:23:08 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2019-09-25 15:52:58 +00:00
|
|
|
|
|
|
|
/// An effect that may be applied to an entity
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
pub enum Effect {
|
2019-10-17 20:59:36 +00:00
|
|
|
Health(comp::HealthChange),
|
2019-09-25 15:52:58 +00:00
|
|
|
Xp(i64),
|
|
|
|
}
|
2019-10-09 19:28:05 +00:00
|
|
|
|
|
|
|
impl Effect {
|
|
|
|
pub fn info(&self) -> String {
|
|
|
|
match self {
|
2019-10-17 20:59:36 +00:00
|
|
|
Effect::Health(c) => format!("{:+} health", c.amount),
|
2019-10-09 19:28:05 +00:00
|
|
|
Effect::Xp(n) => format!("{:+} exp", n),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|