@@ 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)
+ ),
+ });
}