use serde::{Deserialize, Serialize};
use super::types::Emotion;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MoodTrigger {
pub name: String,
pub responses: Vec<(Emotion, f32)>,
}
impl MoodTrigger {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
responses: Vec::new(),
}
}
pub fn respond(mut self, emotion: Emotion, intensity: f32) -> Self {
self.responses.push((emotion, intensity));
self
}
}
pub fn trigger_praised() -> MoodTrigger {
MoodTrigger::new("praised")
.respond(Emotion::Joy, 0.4)
.respond(Emotion::Dominance, 0.2)
.respond(Emotion::Trust, 0.1)
}
pub fn trigger_criticized() -> MoodTrigger {
MoodTrigger::new("criticized")
.respond(Emotion::Joy, -0.3)
.respond(Emotion::Dominance, -0.2)
.respond(Emotion::Frustration, 0.3)
}
pub fn trigger_surprised() -> MoodTrigger {
MoodTrigger::new("surprised")
.respond(Emotion::Arousal, 0.5)
.respond(Emotion::Interest, 0.3)
}
pub fn trigger_threatened() -> MoodTrigger {
MoodTrigger::new("threatened")
.respond(Emotion::Arousal, 0.4)
.respond(Emotion::Trust, -0.4)
.respond(Emotion::Dominance, -0.3)
.respond(Emotion::Frustration, 0.2)
}