fantasy_realms_unofficial_api 0.1.0

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

pub(crate) const ISLAND: Card = Card {
    name: Name::Island,
    suit: Suit::Flood,
    strength: 14,
    adder: None,
    wild: None,
    modifier: Some(island_modifier),
    immunity: None,
    blanks: None,
    bonus: None,
    penalty: None,
};

pub(crate) fn island_modifier(hand: &Vec<Card>) -> Vec<Vec<Card>> {
    let mut new_hand = hand
        .iter()
        .enumerate()
        .filter_map(|(i, card)| {
            if matches!(card.suit, Suit::Flood | Suit::Flame) && 
               (card.penalty.is_some() || card.blanks.is_some()) {
                let new_card = Card {
                    blanks: None,
                    penalty: None,
                    ..*card
                };
                let mut new_hand: Vec<Card> = hand.clone();
                new_hand[i] = new_card;
                Some(new_hand)
            } else {
                None
            }
        })
        .collect::<Vec<Vec<Card>>>();
    new_hand.push(hand.clone());
    new_hand
}