Added an empty pile symbol
This commit is contained in:
@@ -25,13 +25,7 @@ const CARD_HEIGHT: u16 = 11;
|
||||
const CARD_WIDTH: u16 = 15;
|
||||
|
||||
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([
|
||||
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);
|
||||
// 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(false),
|
||||
top_waste
|
||||
);
|
||||
}
|
||||
if cards_in_waste.len() >= 3 {
|
||||
frame.render_widget(
|
||||
partially_covered_card(&cards_in_waste[cards_in_waste.len() - 1]),
|
||||
@@ -183,6 +185,30 @@ fn facedown_card(top: bool) -> Paragraph<'static> {
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
fn empty_pile(top: bool) -> Paragraph<'static> {
|
||||
// made using https://www.asciiart.eu/
|
||||
let hidden_card = format!(
|
||||
"
|
||||
XX XX
|
||||
XX XX
|
||||
|
||||
X X
|
||||
X X
|
||||
X X
|
||||
XXXXXXX"
|
||||
);
|
||||
|
||||
let mut borders = Borders::TOP | Borders::LEFT | Borders::RIGHT;
|
||||
if top {
|
||||
borders |= Borders::BOTTOM;
|
||||
}
|
||||
|
||||
Paragraph::new(hidden_card)
|
||||
.block(Block::new()
|
||||
.borders(borders)
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
impl App {
|
||||
/// runs the application's main loop until the user quits
|
||||
pub fn run(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user