Now ChangeTargetHealth effect is generalised to ChangeTargetParameter that can also change raddamage (and in the future could cover other things). Also fixes a long-standing lmap bug - only show exits where both ends are in the zone of the current room, rather than just requiring one of the rooms to be in the zone.
112 lines
3.3 KiB
Rust
112 lines
3.3 KiB
Rust
use super::item::Item;
|
|
use ansi_markup::parse_ansi_markup;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(PartialEq, Eq, PartialOrd, Clone, Serialize, Deserialize, Debug, Ord)]
|
|
pub enum EffectType {
|
|
Ephemeral, // i.e. no enduring impact to show in status.
|
|
Bandages,
|
|
RadDetox,
|
|
Bleed,
|
|
Stunned,
|
|
CurrentRoom,
|
|
}
|
|
|
|
pub struct EffectSet {
|
|
pub effect_type: EffectType,
|
|
pub effects: Vec<Effect>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
|
|
pub enum EffectParameter {
|
|
Health,
|
|
Raddamage,
|
|
}
|
|
|
|
pub enum Effect {
|
|
// messagef takes player, causative item, target as the 3 parameters. Returns message.
|
|
BroadcastMessage {
|
|
delay_secs: u64,
|
|
messagef: Box<dyn Fn(&Item, &Item, &Item) -> String + Sync + Send>,
|
|
},
|
|
DirectMessage {
|
|
delay_secs: u64,
|
|
messagef: Box<dyn Fn(&Item, &Item, &Item) -> String + Sync + Send>,
|
|
},
|
|
// skill_multiplier is always positive - sign flipped for crit fails.
|
|
ChangeTargetParameter {
|
|
delay_secs: u64,
|
|
base_effect: i64,
|
|
skill_multiplier: f64,
|
|
max_effect: i64,
|
|
parameter: EffectParameter,
|
|
message: Box<dyn Fn(&Item) -> String + Sync + Send>,
|
|
},
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum SimpleEffect {
|
|
BroadcastMessage {
|
|
delay_secs: u64,
|
|
message: String,
|
|
},
|
|
DirectMessage {
|
|
delay_secs: u64,
|
|
message: String,
|
|
},
|
|
// skill_multiplier is always positive - sign flipped for crit fails.
|
|
ChangeTargetParameter {
|
|
delay_secs: u64,
|
|
base_effect: i64,
|
|
skill_multiplier: f64,
|
|
max_effect: i64,
|
|
parameter: EffectParameter,
|
|
message: String,
|
|
},
|
|
}
|
|
|
|
impl From<&SimpleEffect> for Effect {
|
|
fn from(simple: &SimpleEffect) -> Effect {
|
|
match simple {
|
|
SimpleEffect::BroadcastMessage {
|
|
delay_secs,
|
|
message,
|
|
} => {
|
|
let messagem = parse_ansi_markup(message).unwrap() + "\n";
|
|
Effect::BroadcastMessage {
|
|
delay_secs: *delay_secs,
|
|
messagef: Box::new(move |_, _, _| messagem.clone()),
|
|
}
|
|
}
|
|
SimpleEffect::DirectMessage {
|
|
delay_secs,
|
|
message,
|
|
} => {
|
|
let messagem = parse_ansi_markup(message).unwrap() + "\n";
|
|
Effect::DirectMessage {
|
|
delay_secs: *delay_secs,
|
|
messagef: Box::new(move |_, _, _| messagem.clone()),
|
|
}
|
|
}
|
|
SimpleEffect::ChangeTargetParameter {
|
|
delay_secs,
|
|
base_effect,
|
|
skill_multiplier,
|
|
max_effect,
|
|
parameter,
|
|
message,
|
|
} => {
|
|
let messagem = parse_ansi_markup(message).unwrap() + "\n";
|
|
Effect::ChangeTargetParameter {
|
|
delay_secs: *delay_secs,
|
|
base_effect: *base_effect,
|
|
skill_multiplier: *skill_multiplier,
|
|
max_effect: *max_effect,
|
|
parameter: parameter.clone(),
|
|
message: Box::new(move |_| messagem.clone()),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|