planetwars.dev/planetwars-rules/src/protocol.rs
2022-09-15 21:59:03 +02:00

52 lines
1.1 KiB
Rust

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Expedition {
pub id: u64,
pub ship_count: u64,
pub origin: String,
pub destination: String,
pub owner: usize,
pub turns_remaining: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Planet {
pub ship_count: u64,
pub x: f64,
pub y: f64,
pub owner: Option<usize>,
pub name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Action {
#[serde(rename = "moves")]
pub commands: Vec<Command>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Command {
pub origin: String,
pub destination: String,
pub ship_count: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct State {
pub planets: Vec<Planet>,
pub expeditions: Vec<Expedition>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GameInfo {
pub players: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CommandError {
NotEnoughShips,
OriginNotOwned,
ZeroShipMove,
OriginDoesNotExist,
DestinationDoesNotExist,
}