Skip to main content

artifacts/models/
npc_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 NpcSchema {
7    /// Name of the NPC.
8    #[serde(rename = "name")]
9    pub name: String,
10    /// The code of the NPC. This is the NPC's unique identifier (ID).
11    #[serde(rename = "code")]
12    pub code: String,
13    /// Description of the NPC.
14    #[serde(rename = "description")]
15    pub description: String,
16    /// Type of the NPC.
17    #[serde(rename = "type")]
18    pub r#type: models::NpcType,
19    /// Items sold/bought by the NPC.
20    #[serde(rename = "items", skip_serializing_if = "Option::is_none")]
21    pub items: Option<Vec<models::SimpleNpcItem>>,
22}
23
24impl NpcSchema {
25    pub fn new(
26        name: String,
27        code: String,
28        description: String,
29        r#type: models::NpcType,
30    ) -> NpcSchema {
31        NpcSchema {
32            name,
33            code,
34            description,
35            r#type,
36            items: None,
37        }
38    }
39}