1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use crate::bad_json::deserialize_bad_location_as_none;
use crate::ErrorResponse;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize)]
pub(crate) struct MoveItemRequest<'a, T> {
pub(crate) data: &'a [T],
pub(crate) tm: u64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct RagfairResponseData {
pub(crate) items: serde_json::Value,
#[serde(rename = "badRequest")]
pub(crate) errors: Vec<ErrorResponse>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InventoryUpdate {
pub new: Option<Vec<Item>>,
pub change: Option<Vec<Item>>,
pub del: Option<Vec<DeletedItem>>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DeletedItem {
#[serde(rename = "_id")]
pub id: String,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Item {
#[serde(rename = "_id")]
pub id: String,
#[serde(rename = "_tpl")]
pub schema_id: String,
pub parent_id: Option<String>,
pub slot_id: Option<String>,
pub upd: Option<Upd>,
#[serde(default, deserialize_with = "deserialize_bad_location_as_none")]
pub location: Option<Location>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Location {
pub x: u64,
pub y: u64,
pub r: u64,
pub is_searched: Option<bool>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct Upd {
pub stack_objects_count: Option<u64>,
pub spawned_in_session: Option<bool>,
pub med_kit: Option<UpdMedkit>,
pub repairable: Option<UpdRepairable>,
pub light: Option<UpdLight>,
pub unlimited_count: Option<bool>,
pub buy_restriction_max: Option<u64>,
pub buy_restriction_current: Option<u64>,
pub key: Option<UpdKey>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct UpdMedkit {
pub hp_resource: f64,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct UpdRepairable {
pub max_durability: Option<f64>,
pub durability: f64,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct UpdLight {
pub is_active: bool,
pub selected_mode: u64,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct UpdKey {
pub number_of_usages: u64,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
pub struct BarterItem {
pub id: String,
pub count: f64,
}