testlib/jsonb/
game_progress.rs

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
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::dto::game_progress_response::GameProgressResponse;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct GameProgress {
    pub question_id: Uuid,
    pub answers: Vec<String>,
    pub player1_status: bool,
    pub player2_status: bool,
    pub answerer_id: Uuid,
}

impl GameProgress {
    pub fn to_response(&self, game_id: Uuid) -> GameProgressResponse {
        GameProgressResponse {
            id: self.question_id.clone(),
            game_id: game_id.clone(),
            player1_status: self.player1_status.clone(),
            player2_status: self.player2_status.clone(),
            answerer_id: self.answerer_id.clone(),
        }
    }
}