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
use serde::{Deserialize, Serialize};
use super::location::Location;
#[derive(Serialize, Deserialize, Debug)]
pub struct Map {
pub id: String,
pub name: String,
pub description: String,
pub world_id: String,
pub width: u32,
pub height: u32,
pub map: Vec<Vec<String>>,
pub locations: Vec<Location>,
}
impl Map {
pub fn new(
id: String,
name: String,
description: String,
world_id: String,
width: u32,
height: u32,
) -> Self {
Self {
id,
name,
description,
world_id,
width,
height,
map: vec![vec!["".to_string(); width as usize]; height as usize],
locations: Vec::new(),
}
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct MapCoordinates {
pub map_id: String,
pub x: u32,
pub y: u32,
}
impl MapCoordinates {
pub fn new(map_id: String, x: u32, y: u32) -> Self {
Self { map_id, x, y }
}
}