ed_journals/modules/state/models/resolvers/shipyard_state_resolver/
ship_entry.rsuse crate::ship::ShipType;
use chrono::{DateTime, TimeDelta, Utc};
use serde::Serialize;
use std::ops::Add;
#[derive(Debug, Serialize)]
pub struct ShipEntry {
pub ship_type: ShipType,
pub status: ShipStatus,
}
#[derive(Debug, Serialize)]
pub enum ShipStatus {
Unknown,
Active,
Stored(u64),
Transferring(TransferringShipStatus),
}
#[derive(Debug, Serialize)]
pub struct TransferringShipStatus {
pub started_at: DateTime<Utc>,
pub transfer_time: u64,
pub from_market_id: u64,
pub to_market_id: u64,
}
impl TransferringShipStatus {
pub fn completed_at(&self) -> DateTime<Utc> {
self.started_at
.add(TimeDelta::new((self.transfer_time as i64).clamp(0, 10000000), 0).unwrap())
}
pub fn done_transferring(&self, timestamp: &DateTime<Utc>) -> bool {
&self.completed_at() <= timestamp
}
}