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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
use crate::create_new::CreateNew;
use crate::fillable::{Fillable, Filler};
use crate::positions::{Coordinate, Rectangle};
use crate::SchemaExample;
use df_st_derive::{Fillable, Filler, HashAndPartialEqById};
use juniper::GraphQLObject;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(
Serialize,
Deserialize,
Clone,
Debug,
HashAndPartialEqById,
Fillable,
Filler,
Default,
JsonSchema,
GraphQLObject,
)]
pub struct Site {
pub id: i32,
#[serde(rename = "type")]
pub type_: Option<String>,
pub name: Option<String>,
pub coord: Option<Coordinate>,
pub rectangle: Option<Rectangle>,
pub structures: Vec<Structure>,
pub site_properties: Vec<SiteProperty>,
pub civ_id: Option<i32>,
pub cur_owner_id: Option<i32>,
}
#[derive(
Serialize, Deserialize, Clone, Debug, Fillable, Filler, Default, JsonSchema, GraphQLObject,
)]
pub struct Structure {
pub site_id: i32,
pub local_id: i32,
#[serde(rename = "type")]
pub type_: Option<String>,
pub subtype: Option<String>,
pub name: Option<String>,
pub name2: Option<String>,
pub entity_id: Option<i32>,
pub worship_hfid: Option<i32>,
pub copied_artifact_id: Vec<i32>,
pub deity_type: Option<i32>,
pub deity_id: Option<i32>,
pub religion_id: Option<i32>,
pub dungeon_type: Option<i32>,
pub inhabitant: Vec<i32>,
}
#[derive(
Serialize, Deserialize, Clone, Debug, Fillable, Filler, Default, JsonSchema, GraphQLObject,
)]
pub struct SiteProperty {
pub site_id: i32,
pub local_id: i32,
#[serde(alias = "type")]
pub type_: Option<String>,
pub structure_id: Option<i32>,
pub owner_hfid: Option<i32>,
}
impl PartialEq for Structure {
fn eq(&self, other: &Self) -> bool {
self.site_id == other.site_id && self.local_id == other.local_id
}
}
impl std::hash::Hash for Structure {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.site_id.hash(state);
self.local_id.hash(state);
}
}
impl PartialEq for SiteProperty {
fn eq(&self, other: &Self) -> bool {
self.site_id == other.site_id && self.local_id == other.local_id
}
}
impl std::hash::Hash for SiteProperty {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.site_id.hash(state);
self.local_id.hash(state);
}
}
impl Site {
pub fn new() -> Self {
Self::default()
}
}
impl CreateNew for Site {
fn new_by_id(id: i32) -> Self {
Self {
id,
..Default::default()
}
}
}
impl SchemaExample for Site {
fn example() -> Self {
Self::default()
}
}
impl Structure {
pub fn new() -> Self {
Self::default()
}
}
impl SchemaExample for Structure {
fn example() -> Self {
Self::default()
}
}
impl SiteProperty {
pub fn new() -> Self {
Self::default()
}
}
impl SchemaExample for SiteProperty {
fn example() -> Self {
Self::default()
}
}