fantasy_realms_unofficial_api 0.1.0

An unofficial API for the Fantasy Realms card game.
Documentation
use strum::IntoEnumIterator;
use super::*;

pub(crate) const BOOK_OF_CHANGES: Card = Card {
    name: Name::BookOfChanges,
    suit: Suit::Artifact,
    strength: 3,
    adder: None,
    wild: None,
    modifier: Some(book_of_changes_modifier),
    immunity: None,
    blanks: None,
    bonus: None,
    penalty: None,
};

pub(crate) fn book_of_changes_modifier(hand: &Vec<Card>) -> Vec<Vec<Card>> {
    hand.iter()
        .enumerate()
        .flat_map(|(i, card)| {
            Suit::iter()
                .filter(|&suit| suit != Suit::Wild)
                .map(|suit| {
                    let mut new_hand = hand.clone();
                    new_hand[i] = Card {
                        suit: suit,
                        ..*card
                    };
                    new_hand
                })
                .collect::<Vec<Vec<Card>>>()
        })
        .collect::<Vec<Vec<Card>>>()
}