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    #[serde(rename = "buy_price", deserialize_with = "Option::deserialize")]
17    pub buy_price: Option<i32>,
18    #[serde(rename = "sell_price", deserialize_with = "Option::deserialize")]
19    pub sell_price: Option<i32>,
20}
21
22impl NpcItem {
23    pub fn new(
24        code: String,
25        npc: String,
26        currency: String,
27        buy_price: Option<i32>,
28        sell_price: Option<i32>,
29    ) -> NpcItem {
30        NpcItem {
31            code,
32            npc,
33            currency,
34            buy_price,
35            sell_price,
36        }
37    }
38}