Drew a crap card
This commit is contained in:
@@ -8,7 +8,7 @@ use ratatui::{
|
||||
style::Stylize,
|
||||
symbols::border,
|
||||
text::{Line, Text},
|
||||
widgets::{block::title, Block, BorderType, Borders, Paragraph, Widget, Padding},
|
||||
widgets::{block::title, Block, BorderType, Borders, Paragraph, Widget, Padding, ListItem, List},
|
||||
DefaultTerminal, Frame,
|
||||
};
|
||||
|
||||
@@ -19,7 +19,32 @@ pub struct App {
|
||||
}
|
||||
|
||||
const CARD_HEIGHT: u16 = 12;
|
||||
const CARD_WIDTH: u16 = 10;
|
||||
const CARD_WIDTH: u16 = 17;
|
||||
|
||||
fn card_widget(card: &card_stuffs::Card) -> List {
|
||||
let five_card = [
|
||||
format!("{value}{suit} ", value=card.value, suit=card.suit),
|
||||
format!(" "),
|
||||
format!(" {suit} {suit} ", suit=card.suit),
|
||||
format!(" "),
|
||||
format!(" "),
|
||||
format!(" {suit} ", suit=card.suit),
|
||||
format!(" "),
|
||||
format!(" "),
|
||||
format!(" {suit} {suit} ", suit=card.suit),
|
||||
format!(" "),
|
||||
format!(" {value}{suit}", value=card.value, suit=card.suit),
|
||||
];
|
||||
let card: Vec<ListItem> = five_card.iter().map(|(m)| {
|
||||
ListItem::new(m.to_string())
|
||||
})
|
||||
.collect();
|
||||
|
||||
List::new(card)
|
||||
.block(Block::new()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
||||
@@ -79,9 +104,11 @@ impl App {
|
||||
Constraint::Length(2),
|
||||
]);
|
||||
let piles_and_spacers: [Rect; 14] = horizontal.areas(piles_area);
|
||||
let a_card = card_widget(&self.cards.piles[0][0]);
|
||||
for pile in 0..card_stuffs::NUM_PILES_KLONDIKE {
|
||||
frame.render_widget(
|
||||
Block::new().borders(Borders::ALL).title(format!("pile {}", pile)),
|
||||
//&a_card,
|
||||
piles_and_spacers[pile*2]
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user