Skip to main content

artifacts/models/
event_schema.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5#[cfg_attr(feature = "specta", derive(specta::Type))]
6pub struct EventSchema {
7    /// Name of the event.
8    #[serde(rename = "name")]
9    pub name: String,
10    /// Code of the event.
11    #[serde(rename = "code")]
12    pub code: String,
13    /// Content of the event.
14    #[serde(rename = "content", skip_serializing_if = "Option::is_none")]
15    pub content: Option<Box<models::EventContentSchema>>,
16    /// Map list of the event.
17    #[serde(rename = "maps")]
18    pub maps: Vec<models::EventMapSchema>,
19    /// Duration in minutes.
20    #[serde(rename = "duration")]
21    pub duration: i32,
22    /// Rate spawn of the event. (1/rate every minute)
23    #[serde(rename = "rate")]
24    pub rate: i32,
25    /// Cooldown in minutes before the event can be spawned with gems.
26    #[serde(rename = "cooldown", skip_serializing_if = "Option::is_none")]
27    pub cooldown: Option<i32>,
28    /// Price in gems to spawn the event. Null if not purchasable.
29    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
30    pub price: Option<i32>,
31    /// Transition to add to the map when event is active.
32    #[serde(rename = "transition", skip_serializing_if = "Option::is_none")]
33    pub transition: Option<Box<models::TransitionSchema>>,
34    /// Gems spawn cooldown expiration datetime (null if not on cooldown).
35    #[serde(
36        rename = "cooldown_expiration",
37        skip_serializing_if = "Option::is_none"
38    )]
39    pub cooldown_expiration: Option<String>,
40}
41
42impl EventSchema {
43    pub fn new(
44        name: String,
45        code: String,
46        maps: Vec<models::EventMapSchema>,
47        duration: i32,
48        rate: i32,
49    ) -> EventSchema {
50        EventSchema {
51            name,
52            code,
53            content: None,
54            maps,
55            duration,
56            rate,
57            cooldown: None,
58            price: None,
59            transition: None,
60            cooldown_expiration: None,
61        }
62    }
63}