foxhole_api/
response_types.rs

1//! Response types for all war api endpoints.
2//!
3//! For more detailed information on the contents of each response see the
4//! [Foxhole War API](https://github.com/clapfoot/warapi) definition.
5
6use serde;
7use serde::Deserialize;
8use serde_repr::Deserialize_repr;
9
10/// Response for the `worldconquest/war` endpoint.
11///
12/// This response contains information about the status of the war for a given shard.
13#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
14#[serde(rename_all = "camelCase")]
15pub struct WarDataResponse {
16    pub war_id: String,
17    pub war_number: u32,
18    pub winner: TeamId,
19    pub conquest_start_time: u64,
20    pub conquest_end_time: Option<u64>,
21    pub resistance_start_time: Option<u64>,
22    pub required_victory_towns: u8,
23}
24
25/// Response for the `worldconquest/warReport/{map}` endpoint.
26///
27/// This response contains information about the current state of the war for a given map.
28#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
29#[serde(rename_all = "camelCase")]
30pub struct WarReportResponse {
31    pub total_enlistments: u32,
32    pub colonial_casualties: u32,
33    pub warden_casualties: u32,
34    pub day_of_war: u32,
35}
36
37/// Response for the `worldconquest/maps` endpoint.
38///
39/// Contains a list of all maps present on the shard.
40#[derive(Debug, Clone, PartialEq, Eq)]
41pub struct MapNameResponse {
42    pub maps: Vec<String>,
43}
44
45/// Response for the /worldconquest/maps/{map}/dynamic|static endpoints.
46///
47/// Contains information about a requested map hex. This includes static objects, as well as objects
48/// that can change dynamically. This does not include player built fortifications.
49#[derive(Debug, Deserialize, Clone, PartialEq)]
50#[serde(rename_all = "camelCase")]
51pub struct MapDataResponse {
52    pub region_id: u16,
53    pub scorched_victory_towns: u16,
54    pub map_items: Vec<MapItem>,
55    pub map_text_items: Vec<MapTextItem>,
56    pub last_updated: u64,
57    pub version: u16,
58}
59
60/// Contains information about a single item present on a map hex.
61///
62/// Includes the owner of the item, its position, as well as what type of item it is.
63#[derive(Debug, Deserialize, Clone, PartialEq)]
64#[serde(rename_all = "camelCase")]
65pub struct MapItem {
66    pub team_id: TeamId,
67    pub icon_type: IconType,
68    pub x: f32,
69    pub y: f32,
70    pub flags: u16,
71}
72
73/// Contains information about a map label.
74///
75/// Includes the text, position, and type of a label.
76#[derive(Debug, Deserialize, Clone, PartialEq)]
77#[serde(rename_all = "camelCase")]
78pub struct MapTextItem {
79    pub text: String,
80    pub x: f32,
81    pub y: f32,
82    pub map_marker_type: MapMarkerType,
83}
84
85/// The type of icon for a map item.
86///
87/// This includes a mapping of the icon type to the underlying number used by the API.
88#[derive(Deserialize_repr, PartialEq, Debug, Clone)]
89#[repr(u16)]
90pub enum IconType {
91    StaticBase = 5,
92    StaticBase2 = 6,
93    StaticBase3 = 7,
94    ForwardBase1 = 8,
95    ForwardBase2 = 9,
96    ForwardBase3 = 10,
97    Hospital = 11,
98    VehicleFactory = 12,
99    Armory = 13,
100    SupplyStation = 14,
101    Workshop = 15,
102    ManufacturingPlant = 16,
103    Refinery = 17,
104    Shipyard = 18,
105    TechCenter = 19,
106    SalvageField = 20,
107    ComponentField = 21,
108    FuelField = 22,
109    SulfurField = 23,
110    WorldMapTent = 24,
111    TravelTent = 25,
112    TrainingArea = 26,
113    SpecialBase = 27,
114    ObservationTower = 28,
115    Fort = 29,
116    TroopShip = 30,
117    SulfurMine = 32,
118    StorageFacility = 33,
119    Factory = 34,
120    GarrisonStation = 35,
121    AmmoFactory = 36,
122    RocketSite = 37,
123    SalvageMine = 38,
124    ConstructionYard = 39,
125    ComponentMine = 40,
126    OilWell = 41,
127    RelicBase1 = 45,
128    RelicBase2 = 46,
129    RelicBase3 = 47,
130    MassProductionFactory = 51,
131    Seaport = 52,
132    CoastalGun = 53,
133    SoulFactory = 54,
134    TownBase1 = 56,
135    TownBase2 = 57,
136    TownBase3 = 58,
137    StormCannon = 59,
138    IntelCenter = 60,
139    CoalField = 61,
140    OilField = 62,
141    RocketTarget = 70,
142    RocketGroundZero = 71,
143    RocketSiteWithRocket = 72,
144    FacilityMineOilRig = 75,
145}
146
147/// Team id for a map item.
148#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
149#[serde(rename_all = "UPPERCASE")]
150pub enum TeamId {
151    None,
152    Wardens,
153    Colonials,
154}
155
156/// Indicates whether or not a map marker is major or minor.
157#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
158pub enum MapMarkerType {
159    Major,
160    Minor,
161}