Skip to main content

ed_journals/modules/logs/content/log_event_content/
engineer_progress_event.rs

1//! Includes information about engineer progress.
2
3use crate::civilization::Engineer;
4use serde::{Deserialize, Serialize};
5
6/// Includes information about engineer progress.
7#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
8#[serde(rename_all = "PascalCase", untagged)]
9pub enum EngineerProgressEvent {
10    /// Fired during startup and includes current engineer progress.
11    Startup(EngineerProgressStartup),
12
13    /// Fired when the player progresses with an engineer.
14    Update(EngineerProgressUpdate),
15}
16
17/// Fired during startup and includes current engineer progress.
18#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
19#[serde(rename_all = "PascalCase")]
20pub struct EngineerProgressStartup {
21    /// List of current engineer progress.
22    pub engineers: Vec<EngineerProgressStartupEntry>,
23}
24
25/// Entry for a single engineer and the progress.
26// TODO the data for this struct is so inconsistent, it could use some work.
27#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
28#[serde(rename_all = "PascalCase")]
29pub struct EngineerProgressStartupEntry {
30    /// The name of the engineer.
31    pub engineer: Option<String>,
32
33    /// The id of the engineer.
34    #[serde(rename = "EngineerID")]
35    pub engineer_id: Option<Engineer>,
36
37    // TODO somehow this is optional even when the [rank] field is present? Why Frontier?!
38    /// The current progress unlock status.
39    pub progress: Option<EngineerProgressStartupProgress>,
40
41    /// The currently unlocked rank or highest possible 'tier' for the engineer.
42    pub rank: Option<u8>,
43
44    /// The current progress towards the next rank.
45    pub rank_progress: Option<f32>,
46}
47
48/// The status for a given engineer.
49#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
50pub enum EngineerProgressStartupProgress {
51    /// The engineer has been unlocked and the player can apply upgrades at this engineer.
52    Unlocked,
53
54    /// The player has been invited to the engineer, but still needs to complete their unlock task.
55    Invited,
56
57    /// The engineer is known, but the player has not unlocked the engineer or has been invited.
58    Known,
59}
60
61/// Fired when the player progresses with an engineer.
62#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
63#[serde(rename_all = "PascalCase")]
64pub struct EngineerProgressUpdate {
65    /// The name of the engineer.
66    pub engineer: String,
67
68    /// The id of the engineer.
69    #[serde(rename = "EngineerID")]
70    pub engineer_id: Engineer,
71
72    // TODO somehow this is optional even when the [rank] field is present? Why Frontier?!
73    /// The current progress unlock status.
74    pub progress: Option<EngineerProgressStartupProgress>,
75
76    /// The currently unlocked rank or highest possible 'tier' for the engineer.
77    pub rank: Option<u8>,
78
79    /// The current progress towards the next rank.
80    pub rank_progress: Option<f32>,
81}