DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

f2502dc7416b0f1c7cb282fc0a4bc24d603b6564 — Jonni Liljamo 1 year, 7 months ago b764b21
feat(client): update hardcoded game init
1 files changed, 17 insertions(+), 3 deletions(-)

M client/src/plugins/game/ui/mod.rs
M client/src/plugins/game/ui/mod.rs => client/src/plugins/game/ui/mod.rs +17 -3
@@ 9,7 9,7 @@
use bevy::prelude::*;
use bevy_egui::{egui, EguiContexts};

use crate::{plugins::{GameDetailsCallEvent, GameActionCreateCallEvent}, Global, api::game::{Action, Command, Game}, game_status::Card};
use crate::{plugins::{GameDetailsCallEvent, GameActionCreateCallEvent}, Global, api::game::{Action, Command, Game}, game_status::{Card, PlayerState}};

use super::GameData;



@@ 46,7 46,7 @@ pub fn ui(
            if status.actions.is_empty() && game.host_id == global.user.as_ref().unwrap().id {
                if ui.button("Init Game").clicked() {
                    // NOTE/FIXME: hardcoded game init
                    hardcoded_piles(&game, &mut create_action_ev_w);
                    hardcoded_init(&game, &mut create_action_ev_w);
                }
            }



@@ 96,10 96,11 @@ pub fn ui(
        });
}

fn hardcoded_piles(
fn hardcoded_init(
    game: &Game,
    create_action_ev_w: &mut EventWriter<GameActionCreateCallEvent>,
) {
    // first, piles
    create_action_ev_w.send(GameActionCreateCallEvent {
        action: Action::new(
                    &game.id,


@@ 172,4 173,17 @@ fn hardcoded_piles(
                    fastrand::u64(u64::MIN..=u64::MAX)
                    ),
    });

    // second, set a player to the action phase, to start the game
    create_action_ev_w.send(GameActionCreateCallEvent {
        action: Action::new(
                    &game.id,
                    &game.host_id,
                    &game.host_id,
                    &Command::ChangePlayerState {
                        state: PlayerState::ActionPhase,
                    },
                    fastrand::u64(u64::MIN..=u64::MAX)
                    ),
    });
}