diff --git a/src/play.rs b/src/play.rs index 84f426f..fa9f2d2 100644 --- a/src/play.rs +++ b/src/play.rs @@ -208,34 +208,40 @@ pub(crate) fn check_for_sets( mut help_set: Local>, mut commands: Commands, ) { - if help_set.is_none() { - *help_set = cards - .iter_combinations() - .find_map(|[(ea, ca), (eb, cb), (ec, cc)]| { - info!("\n\t{}\n\t{}\n\t{}", ca, cb, cc); - (is_set((ca, cb, cc))).then_some((ea, eb, ec)) - }); + match *help_set { + None => { + *help_set = cards + .iter_combinations() + .find_map(|[(ea, ca), (eb, cb), (ec, cc)]| { + (is_set((ca, cb, cc))).then_some((ea, eb, ec)) + }); + } + Some((a, b, c)) => { + if cards.get_many([a, b, c]).is_err() { + *help_set = cards + .iter_combinations() + .find_map(|[(ea, ca), (eb, cb), (ec, cc)]| { + (is_set((ca, cb, cc))).then_some((ea, eb, ec)) + }); + } + } } // TODO: Check if help_set cards are all still on board, if not set to None help_set.iter().for_each(|(a, b, c)| { - info!("Processing {} {} {}", a, b, c); match ( selected.contains(*a), selected.contains(*b), selected.contains(*c), ) { (false, false, false) => { - info!("Adding selected to first card"); commands.entity(*a).insert(Selected); } (true, false, false) => { - info!("Adding selected to second card"); commands.entity(*b).insert(Selected); } (true, true, false) => { - info!("Adding selected to third card"); commands.entity(*c).insert(Selected); } (true, true, true) => info!("I can't hold your hand any further."),