geogamer_data 0.1.3

Data format description exchanged between geogamer server and client
Documentation
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::player;

pub type Id = Uuid;

/// GET /api/games
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ListGamesResponse {
    pub games: Vec<Game>,
    pub is_before: bool,
    pub is_after: bool,
    pub total_games: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Game {
    pub id: Id,
    pub state: GameState,
    pub players: HashMap<player::Id, player::Player>,
    pub rounds: Vec<Round>,
    pub scores: HashMap<player::Id, i32>,
}

/// Message broadcasted from server to clients
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum GameServerEvent {
    State(GameState), //< Current game state
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum GameState {
    Starting(u32),                        //< current countdown before game starts
    Ongoing(usize, usize, Option<Round>), //< round index, total number of rounds, current round
    Ending,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Round {
    pub r#type: RoundType,
    pub image_url: String,
    pub map_url: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RoundType {
    ImageFlat,
    ImageFlatAndMap,
    Image360,
    Image360AndMap,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum GameClientEvent {}