DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

f2af0141369d5ca4bb44f3f24d0b8402e1ac7e90 — skye 1 year, 7 months ago 2d2ef65
feat(client): something to browse in browse
3 files changed, 65 insertions(+), 8 deletions(-)

M client/src/api/game/mod.rs
M client/src/api/user/mod.rs
M client/src/plugins/menu/ui/browse.rs
M client/src/api/game/mod.rs => client/src/api/game/mod.rs +7 -2
@@ 38,7 38,7 @@ pub enum Command {
    ShuffleDiscardToDeck { seed: u32 },
}

#[derive(Deserialize)]
#[derive(Deserialize, Clone)]
pub struct Action {
    pub id: String,
    pub created_at: String,


@@ 49,7 49,7 @@ pub struct Action {
    pub command: Command,
}

#[derive(Deserialize)]
#[derive(Deserialize, Clone)]
pub struct Game {
    pub id: String,
    pub created_at: String,


@@ 63,3 63,8 @@ pub struct Game {
    pub turn: u8,
    pub actions: Option<Vec<Action>>,
}

pub const GAMESTATE_FORMING: u8 = 0;
pub const GAMESTATE_INPROGRESS: u8 = 1;
pub const GAMESTATE_FINISHED: u8 = 2;
pub const GAMESTATE_CANCELLED: u8 = 3;

M client/src/api/user/mod.rs => client/src/api/user/mod.rs +1 -1
@@ 14,7 14,7 @@ pub use login::*;
mod register;
pub use register::*;

#[derive(Deserialize)]
#[derive(Deserialize, Clone)]
pub struct User {
    pub id: String,
    pub created_at: String,

M client/src/plugins/menu/ui/browse.rs => client/src/plugins/menu/ui/browse.rs +57 -5
@@ 9,10 9,10 @@
use bevy::prelude::*;
use bevy_egui::egui;

use crate::plugins::{
use crate::{plugins::{
    GameCreateCallEvent, BrowseState, 
    GameFormingCallEvent, GameMyGamesCallEvent
};
}, api::game::{GAMESTATE_INPROGRESS, GAMESTATE_FINISHED}};

use super::{MenuData, MenuUIState};



@@ 73,9 73,61 @@ pub fn view(
        });
    ui.vertical_centered(|ui| {
        egui::ScrollArea::vertical().show(ui, |ui| match data.browse_state {
            BrowseState::Forming => {}
            BrowseState::InProgress => {}
            BrowseState::Finished => {}
            BrowseState::Forming => {
                for game in &data.forming_games {
                    egui::Frame::none()
                        .fill(egui::Color32::BLACK)
                        .rounding(4.)
                        .outer_margin(4.)
                        .inner_margin(4.)
                        .show(ui, |ui| {
                            ui.horizontal(|ui| {
                                ui.label(format!(
                                        "Host: {}",
                                        game.host.as_ref().unwrap().username
                                    ));
                            });
                        });
                }
            }
            BrowseState::InProgress => {
                let mut games = data.my_games.clone();
                games.retain(|g| g.state == GAMESTATE_INPROGRESS); 
                for game in &games {
                    egui::Frame::none()
                        .fill(egui::Color32::BLACK)
                        .rounding(4.)
                        .outer_margin(4.)
                        .inner_margin(4.)
                        .show(ui, |ui| {
                            ui.horizontal(|ui| {
                                ui.label(format!(
                                        "Host: {}",
                                        game.host.as_ref().unwrap().username
                                    ));
                            });
                        });
                }
            }
            BrowseState::Finished => {
                let mut games = data.my_games.clone();
                games.retain(|g| g.state == GAMESTATE_FINISHED);
                for game in &games {
                    egui::Frame::none()
                        .fill(egui::Color32::BLACK)
                        .rounding(4.)
                        .outer_margin(4.)
                        .inner_margin(4.)
                        .show(ui, |ui| {
                            ui.horizontal(|ui| {
                                ui.label(format!(
                                        "Host: {}",
                                        game.host.as_ref().unwrap().username
                                    ));
                            });
                        });
                }
            }
        }
        );
    });