scaffolding for checking set

main
Elijah Voigt 2 years ago
parent 76456bd7eb
commit 92e4bf9653

@ -32,3 +32,23 @@ pub(crate) fn toggle_selected(
commands.entity(e).insert(Selected);
}
}
pub(crate) fn check_set(trigger: Trigger<Pointer<Click>>, query: Query<&Card, With<Selected>>) {
let mut cards = query.iter();
if cards.len() == 3 {
let (a, b, c) = (
cards.next().unwrap(),
cards.next().unwrap(),
cards.next().unwrap(),
);
_is_set((a, b, c));
} else if cards.len() > 3 {
info!("Too many cards!")
} else if cards.len() < 3 {
info!("Not enough cards!")
}
}
fn _is_set((_a, _b, _c): (&Card, &Card, &Card)) -> bool {
todo!()
}

@ -1,5 +1,5 @@
use crate::{deck::*, *};
use bevy::prelude::*;
use bevy::{color::palettes::css::TEAL, prelude::*};
pub struct SetupPlugin;
@ -7,7 +7,13 @@ impl Plugin for SetupPlugin {
fn build(&self, app: &mut App) {
app.add_systems(
OnEnter(GameState::Setup),
(setup::setup_cards, setup::setup_camera, setup::start_play).chain(),
(
setup_cards,
setup_camera,
setup_set_check_button,
start_play,
)
.chain(),
);
}
}
@ -52,6 +58,20 @@ pub(crate) fn setup_camera(mut commands: Commands) {
));
}
#[derive(Component)]
pub(crate) struct CheckSet;
pub(crate) fn setup_set_check_button(mut commands: Commands) {
commands.spawn(Node::default()).with_children(|parent| {
parent
.spawn((Button, CheckSet, BackgroundColor(TEAL.into())))
.with_children(|parent| {
parent.spawn(Text("Set!?".to_string()));
})
.observe(play::check_set);
});
}
/// Finish the setup state by progressing to the play state
pub(crate) fn start_play(mut game_state: ResMut<NextState<GameState>>) {
game_state.set(GameState::Play);

@ -0,0 +1,6 @@
TODO:
* Shuffle deck
* Serve out 12 cards
* Check for sets
* Capture valid sets
* Deal out additional cards
Loading…
Cancel
Save