pub struct Solitaire {
pub stockpile: Deck<StandardCard>,
pub waste: Vec<StandardCard>,
pub tablue: [Vec<SolitaireCard>; 7],
pub foundation: [Vec<SolitaireCard>; 4],
/* private fields */
}Expand description
Solitaire
Fields§
§stockpile: Deck<StandardCard>stockpile of cards
waste: Vec<StandardCard>Waste pile
tablue: [Vec<SolitaireCard>; 7]Table
foundation: [Vec<SolitaireCard>; 4]Foundation pile
Implementations§
Source§impl Solitaire
impl Solitaire
Sourcepub fn draw_card(&mut self) -> SError<StandardCard>
pub fn draw_card(&mut self) -> SError<StandardCard>
Move a card from stockpile to waste pile, if stockpile is empty, move waste to stockpile and draw card
§Errors
Errors if there is no more cards to draw Can also error if moves exceed u32
Sourcepub fn peek(&self) -> SError<StandardCard>
pub fn peek(&self) -> SError<StandardCard>
Peek at the next card
§Errors
Errors if there is no cards to peek at from either the stockpile or waste
Sourcepub fn move_to(&mut self, target: Area, destination: Area) -> SError<()>
pub fn move_to(&mut self, target: Area, destination: Area) -> SError<()>
Move card(s) from target -> Destination
§Errors
First Check phase: /// Target rules:
- Foundation
- The row must be less than 4
- Stockpile
- Waste must not be empty
- Stockpile must not be empty
- Waste
- Waste must not be empty
- Tablue
- Row must be less than 7
- The requested amount must be less than or equal to the number of faceup cards
- The tablue must be all faceup if requested amount is 0 (All)
Destination:
- Foundation
- Row less than 4
- Tablue
- Row less than 7
- Stockpile OR Waste
- Always ok
Second Phase:
Target Stockpile:
- Stockpile (Not Allowed)
- Waste
- Failed to draw from stockpile
- Foundation
- Card(s) not allowed to be stacked (Solitaire Rules)
- Tablue
- Card(s) not allowed to be stacked (Solitaire Rules)
Target Waste:
- Stockpile (Never allowed)
- Waste (Never allowed)
- Foundation
- Card(s) not allowed to be stacked (Solitaire Rules)
- Tablue
- Card(s) not allowed to be stacked (Solitaire Rules)
Target Tablue:
- Stockpile (Never allowed)
- Waste (Never allowed)
- Tablue
- Card(s) not allowed to be stacked (Solitaire Rules)
- Foundation
- Card(s) not allowed to be stacked (Solitaire Rules)
Target Foundation:
- Waste (Never allowed)
- Stockpile (Never allowed)
- Foundation (Never allowed)
- Tablue
- Card(s) not allowed to be stacked (Solitaire Rules)
Can also error if moves exceed the max of u32
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Solitaire
impl<'de> Deserialize<'de> for Solitaire
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Solitaire
Source§impl Ord for Solitaire
impl Ord for Solitaire
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Solitaire
impl PartialOrd for Solitaire
impl StructuralPartialEq for Solitaire
Auto Trait Implementations§
impl Freeze for Solitaire
impl RefUnwindSafe for Solitaire
impl Send for Solitaire
impl Sync for Solitaire
impl Unpin for Solitaire
impl UnsafeUnpin for Solitaire
impl UnwindSafe for Solitaire
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more