Compare commits
2 Commits
a64031e3bc
...
bcc493d5f9
| Author | SHA1 | Date | |
|---|---|---|---|
| bcc493d5f9 | |||
| b86df849bc |
@@ -189,7 +189,7 @@ impl Deck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum NumPassesThroughDeck {
|
pub enum NumPassesThroughDeck {
|
||||||
Unlimited,
|
Unlimited,
|
||||||
Limited(u64),
|
Limited(u64),
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ pub struct Klondike {
|
|||||||
pub deck: Vec<Card>, // this term is a bit overloaded
|
pub deck: Vec<Card>, // this term is a bit overloaded
|
||||||
pub waste: Vec<Card>,
|
pub waste: Vec<Card>,
|
||||||
pub foundation: [Vec<Card>; 4], // 4 = len of num suits
|
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 current_num_passes_through_deck: u64,
|
||||||
pub num_cards_turned: u8,
|
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) {
|
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 {
|
if self.deck.len() != 0 {
|
||||||
// no!
|
// no!
|
||||||
} else {
|
} else {
|
||||||
@@ -247,7 +255,7 @@ impl Default for Klondike {
|
|||||||
deck: deck.cards,
|
deck: deck.cards,
|
||||||
waste: Vec::new(),
|
waste: Vec::new(),
|
||||||
foundation: [Vec::new(), Vec::new(), Vec::new(), Vec::new()], // is this really the best way?
|
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,
|
current_num_passes_through_deck: 0,
|
||||||
num_cards_turned: 3,
|
num_cards_turned: 3,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ use card_stuffs::{self};
|
|||||||
|
|
||||||
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
buffer::Buffer,
|
|
||||||
layout::{Constraint, Layout, Rect, Flex},
|
layout::{Constraint, Layout, Rect, Flex},
|
||||||
style::{Style, Stylize, Color},
|
style::{Style, Stylize, Color},
|
||||||
text::Line,
|
text::Line,
|
||||||
widgets::{Block, BorderType, Borders, ListItem, List, Widget, Paragraph},
|
widgets::{Block, BorderType, Borders, Paragraph},
|
||||||
DefaultTerminal, Frame,
|
DefaultTerminal, Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,6 +89,9 @@ fn deck_widget(cards_in_deck: &Vec<card_stuffs::Card>) -> Paragraph<'static> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn card_widget<'a>(card: &'a card_stuffs::Card, top: bool, highlight: bool, select: bool) -> Paragraph<'a> {
|
fn card_widget<'a>(card: &'a card_stuffs::Card, top: bool, highlight: bool, select: bool) -> Paragraph<'a> {
|
||||||
|
if !card.visible {
|
||||||
|
return facedown_card(top);
|
||||||
|
}
|
||||||
|
|
||||||
let card_image = format!(
|
let card_image = format!(
|
||||||
"{value}{suit}
|
"{value}{suit}
|
||||||
|
|||||||
Reference in New Issue
Block a user