Compare commits

...

2 Commits

Author SHA1 Message Date
5106f6c53c Empty piles now use empty piles
And I fixed the bug where it had no bottom border. It's because I didn't tell
it to have a border on the bottom. Funny that!
2025-03-07 23:40:03 +00:00
064139d698 Added an empty pile symbol 2025-03-07 23:34:24 +00:00

View File

@@ -25,13 +25,7 @@ const CARD_HEIGHT: u16 = 11;
const CARD_WIDTH: u16 = 15; const CARD_WIDTH: u16 = 15;
fn draw_waste(cards_in_waste: &Vec<card_stuffs::Card>, area: Rect, frame: &mut Frame) { fn draw_waste(cards_in_waste: &Vec<card_stuffs::Card>, area: Rect, frame: &mut Frame) {
if cards_in_waste.len() == 0 {
frame.render_widget(
// TODO something different here to show empty stack - also it's too tall for some reason
facedown_card(false),
area
);
}
let horizontal = Layout::horizontal([ let horizontal = Layout::horizontal([
Constraint::Length(3), Constraint::Length(3),
Constraint::Length(3), Constraint::Length(3),
@@ -39,6 +33,14 @@ fn draw_waste(cards_in_waste: &Vec<card_stuffs::Card>, area: Rect, frame: &mut F
]); ]);
let [w1, w2, top_waste] = horizontal.areas(area); let [w1, w2, top_waste] = horizontal.areas(area);
// There must be a better way to do this // There must be a better way to do this
if cards_in_waste.len() == 0 {
frame.render_widget(
// TODO too tall for some reason
empty_pile(),
top_waste
);
}
if cards_in_waste.len() >= 3 { if cards_in_waste.len() >= 3 {
frame.render_widget( frame.render_widget(
partially_covered_card(&cards_in_waste[cards_in_waste.len() - 1]), partially_covered_card(&cards_in_waste[cards_in_waste.len() - 1]),
@@ -183,6 +185,25 @@ fn facedown_card(top: bool) -> Paragraph<'static> {
.border_type(BorderType::Rounded)) .border_type(BorderType::Rounded))
} }
fn empty_pile() -> Paragraph<'static> {
// made using https://www.asciiart.eu/
let hidden_card = format!(
"
XX XX
XX XX
X X
X X
X X
XXXXXXX"
);
Paragraph::new(hidden_card)
.block(Block::new()
.borders(Borders::ALL)
.border_type(BorderType::Rounded))
}
impl App { impl App {
/// runs the application's main loop until the user quits /// runs the application's main loop until the user quits
pub fn run(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> { pub fn run(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> {
@@ -236,7 +257,7 @@ impl App {
for fa in foundation_areas { for fa in foundation_areas {
frame.render_widget( frame.render_widget(
facedown_card(true), empty_pile(),
fa fa
); );
} }
@@ -269,6 +290,7 @@ impl App {
} }
} }
} }
let vertical = Layout::vertical(constraints); let vertical = Layout::vertical(constraints);
let card_display: [Rect; card_stuffs::NUM_PILES_KLONDIKE + 13] = vertical.areas(pileses[pile]); let card_display: [Rect; card_stuffs::NUM_PILES_KLONDIKE + 13] = vertical.areas(pileses[pile]);