Cascade

Type Alias Cascade 

Source
pub type Cascade = Vec<Card>;
Expand description

A stack of arbitrary cards.

§Rules

Adding cards: A card can be put on a cascade iff its rank is 1 lower than that of the top card of the cascade and it has a different colour than the top card of the cascade.

Removing cards: Only the top card of the cascade can be removed.

§Examples

TODO [high priority] Add examples

Aliased Type§

pub struct Cascade { /* private fields */ }

Trait Implementations§

Source§

impl CardCollection for Cascade

Source§

fn add_card(&self, card: Card) -> Result<Cascade, ()>

Creates a copy of the CardCollection, but with an additional card added. Fails if the card cannot be put into the collection.
Source§

fn pop_card(&self) -> Vec<(Cascade, Card)>

Creates all possible versions of the CardCollection where one card has been removed. Each returned CardCollection is paired with the removed card. If no card can be removed according to the rules, an empty Vec is returned.