Fixed waste display issue and added cards per draw
This commit is contained in:
@@ -203,8 +203,8 @@ pub struct Klondike {
|
|||||||
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,
|
||||||
_current_num_passes_through_deck: u64,
|
pub current_num_passes_through_deck: u64,
|
||||||
num_cards_turned: u8,
|
pub num_cards_turned: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Klondike {
|
impl Klondike {
|
||||||
@@ -223,6 +223,7 @@ impl Klondike {
|
|||||||
} else {
|
} else {
|
||||||
self.deck = self.waste.clone();
|
self.deck = self.waste.clone();
|
||||||
self.waste = vec![];
|
self.waste = vec![];
|
||||||
|
self.current_num_passes_through_deck += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +248,7 @@ impl Default for Klondike {
|
|||||||
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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ fn draw_waste(cards_in_waste: &Vec<card_stuffs::Card>, area: Rect, frame: &mut F
|
|||||||
}
|
}
|
||||||
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() - 3]),
|
||||||
w1
|
w1
|
||||||
);
|
);
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
@@ -49,16 +49,16 @@ fn draw_waste(cards_in_waste: &Vec<card_stuffs::Card>, area: Rect, frame: &mut F
|
|||||||
w2
|
w2
|
||||||
);
|
);
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
card_widget(&cards_in_waste[cards_in_waste.len() - 3], true, false, false),
|
card_widget(&cards_in_waste[cards_in_waste.len() - 1], true, false, false),
|
||||||
top_waste
|
top_waste
|
||||||
);
|
);
|
||||||
} else if cards_in_waste.len() == 2 {
|
} else if cards_in_waste.len() == 2 {
|
||||||
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() - 2]),
|
||||||
w2
|
w2
|
||||||
);
|
);
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
card_widget(&cards_in_waste[cards_in_waste.len() - 2], true, false, false),
|
card_widget(&cards_in_waste[cards_in_waste.len() - 1], true, false, false),
|
||||||
top_waste
|
top_waste
|
||||||
);
|
);
|
||||||
} else if cards_in_waste.len() == 1 {
|
} else if cards_in_waste.len() == 1 {
|
||||||
@@ -218,7 +218,7 @@ impl App {
|
|||||||
Constraint::Min(0),
|
Constraint::Min(0),
|
||||||
Constraint::Length(1),
|
Constraint::Length(1),
|
||||||
]);
|
]);
|
||||||
let [title_bar, main_area, _status_bar] = vertical.areas(frame.area());
|
let [title_bar, main_area, status_bar] = vertical.areas(frame.area());
|
||||||
|
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Block::new()
|
Block::new()
|
||||||
@@ -228,9 +228,15 @@ impl App {
|
|||||||
title_bar
|
title_bar
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let status_bar_info = format!("Cards Per-Draw: {} ---- Times Through Deck: {} ", self.cards.num_cards_turned, self.cards.current_num_passes_through_deck);
|
||||||
|
frame.render_widget(
|
||||||
|
Block::new().borders(Borders::TOP).title(status_bar_info),
|
||||||
|
status_bar
|
||||||
|
);
|
||||||
|
|
||||||
let vertical = Layout::vertical([
|
let vertical = Layout::vertical([
|
||||||
Constraint::Length(CARD_HEIGHT),
|
Constraint::Length(CARD_HEIGHT),
|
||||||
Constraint::Min(0)
|
Constraint::Min(0),
|
||||||
]);
|
]);
|
||||||
let [dwf_area, piles_area] = vertical.areas(main_area);
|
let [dwf_area, piles_area] = vertical.areas(main_area);
|
||||||
|
|
||||||
@@ -332,6 +338,8 @@ impl App {
|
|||||||
KeyCode::Char('q') => self.exit(),
|
KeyCode::Char('q') => self.exit(),
|
||||||
KeyCode::Char('d') => self.cards.deck_to_waste(),
|
KeyCode::Char('d') => self.cards.deck_to_waste(),
|
||||||
KeyCode::Char('w') => self.cards.waste_to_deck(),
|
KeyCode::Char('w') => self.cards.waste_to_deck(),
|
||||||
|
KeyCode::Char('1') => self.cards.num_cards_turned = 1,
|
||||||
|
KeyCode::Char('3') => self.cards.num_cards_turned = 3,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user