gw2lib_model/
maps.rs

1use std::collections::BTreeSet;
2
3use serde::{Deserialize, Serialize};
4
5use crate::{
6    maps::continents::{ContinentId, ContinentRectangle, FloorId, MapRectangle, RegionId},
7    BulkEndpoint, Endpoint, EndpointWithId,
8};
9
10pub mod continents;
11
12pub type MapId = u32;
13
14#[derive(Clone, PartialEq, Eq, PartialOrd, Debug, Serialize, Deserialize)]
15#[cfg_attr(test, serde(deny_unknown_fields))]
16pub enum MapType {
17    /// The blue home borderlands in WvW.
18    BlueHome,
19    /// The center map in WvW (Eternal Battlegrounds).
20    Center,
21    /// The Edge of the Mists map in WvW.
22    EdgeOfTheMists,
23    /// The green home borderlands in WvW.
24    GreenHome,
25    /// An instanced map.
26    Instance,
27    /// At present only a WvW map that houses a jumping puzzle (Obsidian
28    /// Sanctum).
29    JumpPuzzle,
30    /// Open world map.
31    Public,
32    /// PvP or activity map.
33    Pvp,
34    /// The red home borderlands in WvW.
35    RedHome,
36    /// The tutorial missions for newly created characters.
37    Tutorial,
38    Unknown,
39}
40
41#[derive(Clone, Debug, Serialize, Deserialize)]
42#[cfg_attr(test, serde(deny_unknown_fields))]
43pub struct Map {
44    /// The map id.
45    pub id: MapId,
46    /// The map name.
47    pub name: String,
48    /// The minimum level on this map.
49    pub min_level: u8,
50    /// The maximum level on this map.
51    pub max_level: u8,
52    /// The default floor of the map.
53    pub default_floor: FloorId,
54    /// The map type.
55    #[serde(rename = "type")]
56    pub _type: MapType,
57    /// The list of available floors for the map.
58    pub floors: BTreeSet<FloorId>,
59    /// The id of the region this map belongs to, if any.
60    pub region_id: Option<RegionId>,
61    /// The name of the region this map belongs to, if any.
62    pub region_name: Option<String>,
63    /// The id of the continent this map belongs to, if any.
64    pub continent_id: Option<ContinentId>,
65    /// The name of the continent this map belongs to, if any.
66    pub continent_name: Option<String>,
67    /// The dimensions of the map.
68    pub map_rect: MapRectangle,
69    /// The dimensions of the map within the continent coordinate system.
70    pub continent_rect: ContinentRectangle,
71}
72
73impl EndpointWithId for Map {
74    type IdType = MapId;
75}
76impl Endpoint for Map {
77    const AUTHENTICATED: bool = false;
78    const LOCALE: bool = true;
79    const URL: &'static str = "v2/maps";
80    const VERSION: &'static str = "2023-04-02T00:00:00.000Z";
81}
82
83impl BulkEndpoint for Map {
84    const ALL: bool = true;
85
86    fn id(&self) -> &Self::IdType {
87        &self.id
88    }
89}