|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
use bevy::prelude::*;
|
|
|
|
|
|
|
|
|
|
use crate::{deck::Card, GameState};
|
|
|
|
|
use crate::{deck::Card, menu::UiMessage, GameState};
|
|
|
|
|
|
|
|
|
|
pub struct PlayPlugin;
|
|
|
|
|
|
|
|
|
|
@ -47,6 +47,7 @@ pub(crate) fn toggle_selected(
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
query: Query<&Selected>,
|
|
|
|
|
) {
|
|
|
|
|
commands.trigger(UiMessage("".into()));
|
|
|
|
|
let e = trigger.entity();
|
|
|
|
|
if query.contains(e) {
|
|
|
|
|
commands.entity(e).remove::<Selected>();
|
|
|
|
|
@ -68,7 +69,7 @@ pub(crate) fn reset_rotation(
|
|
|
|
|
pub(crate) fn check_set(
|
|
|
|
|
_trigger: Trigger<Pointer<Click>>,
|
|
|
|
|
mut query: Query<(Entity, &Card, &mut Visibility, &mut Transform), With<Selected>>,
|
|
|
|
|
mut sets: Query<&SetNumber>,
|
|
|
|
|
sets: Query<&SetNumber>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
let mut cards = query.iter();
|
|
|
|
|
@ -91,11 +92,12 @@ pub(crate) fn check_set(
|
|
|
|
|
.remove::<Selected>()
|
|
|
|
|
.insert(SetNumber(set_number));
|
|
|
|
|
});
|
|
|
|
|
commands.trigger(UiMessage("Yipee!".into()));
|
|
|
|
|
}
|
|
|
|
|
} else if cards.len() > 3 {
|
|
|
|
|
info!("Too many cards!")
|
|
|
|
|
commands.trigger(UiMessage("Too many cards!".into()));
|
|
|
|
|
} else if cards.len() < 3 {
|
|
|
|
|
info!("Not enough cards!")
|
|
|
|
|
commands.trigger(UiMessage("Not enough cards!".into()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -234,6 +236,14 @@ pub(crate) fn check_for_sets(
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if let Some((a, b, c)) = candidate {
|
|
|
|
|
// Message for adding
|
|
|
|
|
match selected.iter().len() {
|
|
|
|
|
0 => commands.trigger(UiMessage("First one's free!".into())),
|
|
|
|
|
1 => commands.trigger(UiMessage("This one is tricky!".into())),
|
|
|
|
|
2 => commands.trigger(UiMessage("Threes company!".into())),
|
|
|
|
|
_ => commands.trigger(UiMessage("I don't feel so good...".into())),
|
|
|
|
|
};
|
|
|
|
|
// Add the selected component to the next entity
|
|
|
|
|
if !selected.contains(a) {
|
|
|
|
|
commands.entity(a).insert(Selected);
|
|
|
|
|
} else if !selected.contains(b) {
|
|
|
|
|
@ -241,9 +251,9 @@ pub(crate) fn check_for_sets(
|
|
|
|
|
} else if !selected.contains(c) {
|
|
|
|
|
commands.entity(c).insert(Selected);
|
|
|
|
|
} else {
|
|
|
|
|
info!("I cannot hold your hand further...");
|
|
|
|
|
commands.trigger(UiMessage("Lock it in!".into()));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
info!("No sets!");
|
|
|
|
|
commands.trigger(UiMessage("I'm stumped!".into()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|