DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

814931c4f3e64ff4060977b49237dd90197df394 — Jonni Liljamo 1 year, 10 months ago 032987c
feat(sdbclient): adhere to new create game API
M sdbclient/src/api/game/create.rs => sdbclient/src/api/game/create.rs +2 -7
@@ 9,18 9,13 @@
use reqwest;
use serde::{Deserialize, Serialize};

use super::APIErrorWrapper;

#[derive(Debug, Serialize, Deserialize)]
pub struct ResultCreateGame {
    pub id: String,
}
use super::{APIErrorWrapper, types::Game};

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResponseCreateGame {
    Error(APIErrorWrapper),
    Valid(ResultCreateGame),
    Valid(Game),
}

pub fn create(api_address: String, token: String) -> ResponseCreateGame {

M sdbclient/src/plugins/menu/play/creategamecall.rs => sdbclient/src/plugins/menu/play/creategamecall.rs +1 -1
@@ 68,7 68,7 @@ pub(super) fn handle(
        rtdmenu.waiting_for_create_game_call = false;
        match create_game_call_response.game {
            ResponseCreateGame::Valid(res) => {
                rtdmenu.cur_game_id = res.id.clone();
                rtdmenu.cur_game = Some(res.clone());
                rtdmenu.play_menu_ui_state = PlayMenuUIState::InLobbyHost;

                console.send(PrintConsoleLine::new(

M sdbclient/src/plugins/menu/play/joingamecall.rs => sdbclient/src/plugins/menu/play/joingamecall.rs +2 -2
@@ 39,7 39,7 @@ pub(super) fn start(
    for _event in events.iter() {
        let api_address = cfg_dev.api_server.clone();
        let token = cfg_user.user_token.clone();
        let game_id = rtdmenu.cur_game_id.clone();
        let game_id = rtdmenu.cur_game.as_ref().unwrap().id.clone();

        let thread_pool = AsyncComputeTaskPool::get();
        let task = thread_pool.spawn(async move {


@@ 72,7 72,7 @@ pub(super) fn handle(
                rtdmenu.play_menu_ui_state = PlayMenuUIState::InLobbyGuest;

                console.send(PrintConsoleLine::new(
                    format!("Joined game with id: '{}'", rtdmenu.cur_game_id).into(),
                    format!("Joined game with id: '{}'", rtdmenu.cur_game.as_ref().unwrap().id).into(),
                ));
            }
            ResponseJoinGame::Error(error) => {

M sdbclient/src/plugins/menu/play/ui.rs => sdbclient/src/plugins/menu/play/ui.rs +3 -1
@@ 115,16 115,18 @@ pub(super) fn show(
                                                                    if game.guest_id == cfg_user.id {
                                                                        ui.add_enabled(false, egui::Button::new("Joined"));
                                                                        if ui.button("Inspect").clicked() {
                                                                            rtdmenu.cur_game = Some(game.clone());
                                                                            rtdmenu.play_menu_ui_state = PlayMenuUIState::InLobbyGuest;
                                                                        }
                                                                    } else if game.host_id == cfg_user.id {
                                                                        ui.add_enabled(false, egui::Button::new("Host"));
                                                                        if ui.button("Inspect").clicked() {
                                                                            rtdmenu.cur_game = Some(game.clone());
                                                                            rtdmenu.play_menu_ui_state = PlayMenuUIState::InLobbyHost;
                                                                        }
                                                                    } else {
                                                                        if ui.button("Join").clicked() {
                                                                            rtdmenu.cur_game_id = game.id.clone();
                                                                            rtdmenu.cur_game = Some(game.clone());
                                                                            joingame_ev_w.send(JoinGameEvent);
                                                                        }
                                                                    }

M sdbclient/src/runtime/menu/mod.rs => sdbclient/src/runtime/menu/mod.rs +3 -3
@@ 15,8 15,8 @@ use crate::api::game::types::Game;
pub(crate) struct RTDMenu {
    pub play_menu_ui_state: PlayMenuUIState,
    pub waiting_for_create_game_call: bool,
    /// Current game ID, for showing lobby data etc
    pub cur_game_id: String,
    /// Current game
    pub cur_game: Option<Game>,
    /// List of all forming games
    pub all_forming_games: Vec<Game>,
    pub waiting_for_all_forming_call: bool,


@@ 28,7 28,7 @@ impl Default for RTDMenu {
        Self {
            play_menu_ui_state: PlayMenuUIState::Main,
            waiting_for_create_game_call: false,
            cur_game_id: String::from(""),
            cur_game: None,
            all_forming_games: vec![],
            waiting_for_all_forming_call: false,
            waiting_for_join_game_call: false,