artifacts/models/
npc_item.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 NpcItem {
7    /// The code of the NPC. This is the NPC's unique identifier (ID).
8    #[serde(rename = "code")]
9    pub code: String,
10    /// Code of the NPC that sells/buys the item.
11    #[serde(rename = "npc")]
12    pub npc: String,
13    /// Currency used to buy/sell the item. If it's not gold, it's the item code.
14    #[serde(rename = "currency")]
15    pub currency: String,
16    /// Price to buy the item.
17    #[serde(rename = "buy_price", skip_serializing_if = "Option::is_none")]
18    pub buy_price: Option<i32>,
19    /// Price to sell the item.
20    #[serde(rename = "sell_price", skip_serializing_if = "Option::is_none")]
21    pub sell_price: Option<i32>,
22}
23
24impl NpcItem {
25    pub fn new(code: String, npc: String, currency: String) -> NpcItem {
26        NpcItem {
27            code,
28            npc,
29            currency,
30            buy_price: None,
31            sell_price: None,
32        }
33    }
34}