78 lines
2.0 KiB
Rust
78 lines
2.0 KiB
Rust
use chrono::{DateTime, Duration, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{artifacts::{Track, archive::Archive}, prediction::{GeneratedResponses, PossibleResponse}, scene::conversation::ConversationEntry};
|
|
|
|
pub mod conversation;
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
pub struct StageDirection {
|
|
pub playlist: String,
|
|
#[serde(skip)]
|
|
#[serde(default="StageDirection::default_end_time")]
|
|
pub end_time: DateTime<Utc>,
|
|
pub narrative: String,
|
|
}
|
|
|
|
impl StageDirection {
|
|
pub fn time_remaining(&self) -> Duration {
|
|
self.end_time.signed_duration_since(Utc::now())
|
|
}
|
|
|
|
fn default_end_time() -> DateTime<Utc> {
|
|
Utc::now() + Duration::hours(2)
|
|
}
|
|
}
|
|
|
|
impl Default for StageDirection {
|
|
fn default() -> Self {
|
|
Self {
|
|
playlist: Default::default(),
|
|
end_time: Self::default_end_time(),
|
|
narrative: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
|
pub struct Scenery {
|
|
pub artifacts: Archive,
|
|
pub current_playlist: Vec<Track>
|
|
}
|
|
|
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
|
pub struct Scene {
|
|
reply_options: GeneratedResponses,
|
|
conversation: Vec<ConversationEntry>,
|
|
direction: StageDirection,
|
|
pub tokens_consumed: usize,
|
|
scenery: Scenery
|
|
}
|
|
|
|
impl Scene {
|
|
pub fn new(reply_options: GeneratedResponses, conversation: Vec<ConversationEntry>, scenery: Scenery, tokens_consumed: usize, direction: StageDirection) -> Self {
|
|
Self {
|
|
reply_options,
|
|
conversation,
|
|
scenery,
|
|
tokens_consumed,
|
|
direction
|
|
}
|
|
}
|
|
|
|
pub fn direction(&self) -> &StageDirection {
|
|
&self.direction
|
|
}
|
|
|
|
pub fn scenery(&self) -> &Scenery {
|
|
&self.scenery
|
|
}
|
|
|
|
pub fn conversation(&self) -> &Vec<ConversationEntry> {
|
|
&self.conversation
|
|
}
|
|
|
|
pub fn reply_options(&self) -> &Vec<PossibleResponse> {
|
|
&self.reply_options.responses
|
|
}
|
|
} |