diff --git a/card_stuffs/src/lib.rs b/card_stuffs/src/lib.rs index d2ba0ba..ad090d4 100644 --- a/card_stuffs/src/lib.rs +++ b/card_stuffs/src/lib.rs @@ -189,7 +189,7 @@ impl Deck { } #[derive(Debug, Copy, Clone)] -enum NumPassesThroughDeck { +pub enum NumPassesThroughDeck { Unlimited, Limited(u64), } @@ -202,7 +202,7 @@ pub struct Klondike { pub deck: Vec, // this term is a bit overloaded pub waste: Vec, pub foundation: [Vec; 4], // 4 = len of num suits - _max_num_passes_through_deck: NumPassesThroughDeck, + max_num_passes_through_deck: NumPassesThroughDeck, pub current_num_passes_through_deck: u64, pub num_cards_turned: u8, } @@ -217,7 +217,15 @@ impl Klondike { } } } + // TODO return some sort of error pub fn waste_to_deck(self: &mut Self) { + match self.max_num_passes_through_deck { + NumPassesThroughDeck::Unlimited => (), + NumPassesThroughDeck::Limited(n) => if n >= self.current_num_passes_through_deck { + // no! + return + }, + } if self.deck.len() != 0 { // no! } else { @@ -247,7 +255,7 @@ impl Default for Klondike { deck: deck.cards, waste: Vec::new(), foundation: [Vec::new(), Vec::new(), Vec::new(), Vec::new()], // is this really the best way? - _max_num_passes_through_deck: NumPassesThroughDeck::Unlimited, + max_num_passes_through_deck: NumPassesThroughDeck::Unlimited, current_num_passes_through_deck: 0, num_cards_turned: 3, } diff --git a/card_stuffs/src/main.rs b/card_stuffs/src/main.rs index c04cbbd..023316e 100644 --- a/card_stuffs/src/main.rs +++ b/card_stuffs/src/main.rs @@ -3,11 +3,10 @@ use card_stuffs::{self}; use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind}; use ratatui::{ - buffer::Buffer, layout::{Constraint, Layout, Rect, Flex}, style::{Style, Stylize, Color}, text::Line, - widgets::{Block, BorderType, Borders, ListItem, List, Widget, Paragraph}, + widgets::{Block, BorderType, Borders, Paragraph}, DefaultTerminal, Frame, };