Skip to main content

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

1//! Fired when the player contributes to an unlock requirement for an engineer.
2
3use crate::civilization::Engineer;
4use crate::modules::materials::Material;
5use crate::modules::trading::Commodity;
6use serde::{Deserialize, Serialize};
7
8/// Fired when the player contributes to an unlock requirement for an engineer.
9#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
10#[serde(rename_all = "PascalCase")]
11pub struct EngineerContributionEvent {
12    /// The engineer the player contributed to.
13    pub engineer: String,
14
15    /// The ID of the engineer.
16    #[serde(rename = "EngineerID")]
17    pub engineer_id: Engineer,
18
19    /// The kind of contribution the player has made to the engineer.
20    #[serde(rename = "Type", flatten)]
21    pub kind: EngineerContributionEventType,
22}
23
24/// The kind of contribution to an engineer.
25#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
26#[serde(rename_all = "PascalCase", tag = "Type")]
27pub enum EngineerContributionEventType {
28    /// A commodity contribution where the player sourced and delivered a certain commodity.
29    Commodity(EngineerContributionEventCommodityContribution),
30
31    /// A material contribution where the player donated a number of materials.
32    Materials(EngineerContributionEventMaterialContribution),
33
34    /// A bounty contribution where the player has handed in bounties.
35    Bounty(EngineerContributionEventBountyContribution),
36}
37
38/// Contribution where the player sourced and delivered a certain commodity.
39#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
40#[serde(rename_all = "PascalCase")]
41pub struct EngineerContributionEventCommodityContribution {
42    /// The commodity that was delivered.
43    pub commodity: Commodity,
44
45    /// The number of commodities that were delivered at this moment.
46    pub quantity: u16,
47
48    /// The number of commodities that player has delivered to the engineer in total.
49    pub total_quantity: u16,
50}
51
52/// Contribution where the player donated a number of materials.
53#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
54#[serde(rename_all = "PascalCase")]
55pub struct EngineerContributionEventMaterialContribution {
56    /// The material that was donated.
57    pub material: Material,
58
59    /// The number of materials that were donated at this moment.
60    pub quantity: u16,
61
62    /// The number of materials that the player has donated to the engineer in total.
63    pub total_quantity: u16,
64}
65
66/// Contribution where the plater handed in a number of bounties.
67#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
68#[serde(rename_all = "PascalCase")]
69pub struct EngineerContributionEventBountyContribution {
70    /// Number of bounties that were handed in at this moment.
71    pub quantity: u32,
72
73    /// The total number of bounties the player has handed in at this engineer so far.
74    pub total_quantity: u32,
75}