68 lines
1.7 KiB
Rust
68 lines
1.7 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use chrono::{DateTime, Duration, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::artifacts::{Track, archive::Archive};
|
|
|
|
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, Clone, Serialize, Deserialize)]
|
|
pub struct Scene {
|
|
direction: StageDirection,
|
|
pub tokens_consumed: usize,
|
|
pub current_playlist: Vec<Track>,
|
|
pub artifact_count: usize,
|
|
pub artifact_stats: (usize, usize, usize),
|
|
pub computer_task_list: HashMap<String, bool>
|
|
}
|
|
|
|
impl Scene {
|
|
pub fn new(tokens_consumed: usize, direction: StageDirection, archive: &Archive, current_playlist: Vec<Track>, computer_task_list: HashMap<String, bool>) -> Self {
|
|
Self {
|
|
tokens_consumed,
|
|
direction,
|
|
current_playlist,
|
|
artifact_count: archive.len(),
|
|
artifact_stats: archive.stats(),
|
|
computer_task_list
|
|
}
|
|
}
|
|
|
|
pub fn direction(&self) -> &StageDirection {
|
|
&self.direction
|
|
}
|
|
|
|
pub fn playlist(&self) -> &Vec<Track> {
|
|
&self.current_playlist
|
|
}
|
|
} |