[][src]Trait freecell::CardCollection

pub trait CardCollection where
    Self: Sized
{ fn add_card(&self, card: Card) -> Result<Self, ()>;
fn pop_card(&self) -> Vec<(Self, Card)>; }

Required methods

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

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

fn pop_card(&self) -> Vec<(Self, 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.

Loading content...

Implementors

impl CardCollection for Foundations[src]

fn add_card(&self, card: Card) -> Result<Self, ()>[src]

Attempts to put a card on the foundation of the appropriate suit.

An Ace can be put on a foundation iff there is no other card on the foundation of that suit. This is always the case in a valid game state.

Any other card c can be put on a foundation iff the top card on the foundation of that suit has a rank exactly one lower than card c.

fn pop_card(&self) -> Vec<(Self, Card)>[src]

Always returns an empty Vec, since cards cannot be removed from foundations.

impl CardCollection for Cascade[src]

impl CardCollection for Freecells[src]

Loading content...