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
//! Response types for all war api endpoints.
//!
//! For more detailed information on the contents of each response see the
//! [Foxhole War API](https://github.com/clapfoot/warapi) definition.

use serde;
use serde::Deserialize;
use serde_repr::Deserialize_repr;

/// Response for the `worldconquest/war` endpoint.
///
/// This response contains information about the status of the war for a given shard.
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct WarDataResponse {
    pub war_id: String,
    pub war_number: u32,
    pub winner: TeamId,
    pub conquest_start_time: u64,
    pub conquest_end_time: Option<u64>,
    pub resistance_start_time: Option<u64>,
    pub required_victory_towns: u8,
}

/// Response for the `worldconquest/maps` endpoint.
///
/// Contains a list of all maps present on the shard.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MapNameResponse {
    pub maps: Vec<String>,
}

/// Response for the /worldconquest/maps/{map}/dynamic|static endpoints.
///
/// Contains information about a requested map hex. This includes static objects, as well as objects
/// that can change dynamically. This does not include player built fortifications.
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MapDataResponse {
    pub region_id: u16,
    pub scorched_victory_towns: u16,
    pub map_items: Vec<MapItem>,
    pub map_text_items: Vec<MapTextItem>,
    pub last_updated: u64,
    pub version: u16,
}

/// Contains information about a single item present on a map hex.
///
/// Includes the owner of the item, its position, as well as what type of item it is.
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MapItem {
    pub team_id: TeamId,
    pub icon_type: IconType,
    pub x: f32,
    pub y: f32,
    pub flags: u16,
}

/// Contains information about a map label.
///
/// Includes the text, position, and type of a label.
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MapTextItem {
    pub text: String,
    pub x: f32,
    pub y: f32,
    pub map_marker_type: MapMarkerType,
}

/// The type of icon for a map item.
///
/// This includes a mapping of the icon type to the underlying number used by the API.
#[derive(Deserialize_repr, PartialEq, Debug, Clone)]
#[repr(u16)]
pub enum IconType {
    StaticBase = 5,
    StaticBase2 = 6,
    StaticBase3 = 7,
    ForwardBase1 = 8,
    ForwardBase2 = 9,
    ForwardBase3 = 10,
    Hospital = 11,
    VehicleFactory = 12,
    Armory = 13,
    SupplyStation = 14,
    Workshop = 15,
    ManufacturingPlant = 16,
    Refinery = 17,
    Shipyard = 18,
    TechCenter = 19,
    SalvageField = 20,
    ComponentField = 21,
    FuelField = 22,
    SulfurField = 23,
    WorldMapTent = 24,
    TravelTent = 25,
    TrainingArea = 26,
    SpecialBase = 27,
    ObservationTower = 28,
    Fort = 29,
    TroopShip = 30,
    SulfurMine = 32,
    StorageFacility = 33,
    Factory = 34,
    GarrisonStation = 35,
    AmmoFactory = 36,
    RocketSite = 37,
    SalvageMine = 38,
    ConstructionYard = 39,
    ComponentMine = 40,
    OilWell = 41,
    RelicBase1 = 45,
    RelicBase2 = 46,
    RelicBase3 = 47,
    MassProductionFactory = 51,
    Seaport = 52,
    CoastalGun = 53,
    SoulFactory = 54,
    TownBase1 = 56,
    TownBase2 = 57,
    TownBase3 = 58,
}

/// Team id for a map item.
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "UPPERCASE")]
pub enum TeamId {
    None,
    Wardens,
    Colonials,
}

/// Indicates whether or not a map marker is major or minor.
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
pub enum MapMarkerType {
    Major,
    Minor,
}