Skip to main content

artifacts/models/
simple_npc_item_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 SimpleNpcItemSchema {
7    /// Item code.
8    #[serde(rename = "code")]
9    pub code: String,
10    /// Currency used to buy/sell the item. If it's not gold, it's the item code.
11    #[serde(rename = "currency")]
12    pub currency: String,
13    /// Price to buy the item.
14    #[serde(rename = "buy_price", skip_serializing_if = "Option::is_none")]
15    pub buy_price: Option<i32>,
16    /// Price to sell the item.
17    #[serde(rename = "sell_price", skip_serializing_if = "Option::is_none")]
18    pub sell_price: Option<i32>,
19}
20
21impl SimpleNpcItemSchema {
22    pub fn new(code: String, currency: String) -> SimpleNpcItemSchema {
23        SimpleNpcItemSchema {
24            code,
25            currency,
26            buy_price: None,
27            sell_price: None,
28        }
29    }
30}