Adds own/disown game logic

This commit is contained in:
2025-07-12 20:00:22 +02:00
parent 3f99b68d62
commit df1e3ff905
13 changed files with 427 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
use std::fmt::Display;
use async_trait::async_trait;
use gamenight_api_client_rs::{apis::default_api::own_post, models::GameId};
use uuid::Uuid;
use super::{Flow, FlowOutcome, FlowResult, GamenightState};
#[derive(Clone)]
pub struct Own {
game_id: Uuid
}
impl Own {
pub fn new(game_id: Uuid) -> Self {
Self {
game_id
}
}
}
#[async_trait]
impl<'a> Flow<'a> for Own {
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
let _ = own_post(&state.api_configuration, Some(GameId{game_id: self.game_id.to_string()})).await?;
clear_screen::clear();
Ok((FlowOutcome::Successful, state))
}
}
impl Display for Own {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Own")
}
}