Made use of the max turns thing

Unsure I'll ever use it... eh
This commit is contained in:
2025-03-08 00:10:20 +00:00
parent b86df849bc
commit bcc493d5f9
2 changed files with 12 additions and 5 deletions

View File

@@ -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<Card>, // this term is a bit overloaded
pub waste: Vec<Card>,
pub foundation: [Vec<Card>; 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,
}

View File

@@ -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,
};