- if player1_deck.len() == 0 {
- player1_deck.clone_from_slice(&player1_captured);
- shuffle_deck(&mut player1_deck);
- player1_captured.clear();
- }
-
- if player2_deck.len() == 0 {
- player2_deck.clone_from_slice(&player2_captured);
- shuffle_deck(&mut player2_deck);
- player2_captured.clear();
+ /*
+ println!("nb card: {}", player1.deck.len() + player2.deck.len() + player1.captured.len() + player2.captured.len() + face_down.len());
+ println!("Player 1: {}", player1.deck.len() + player1.captured.len());
+ println!("Player 2: {}", player2.deck.len() + player2.captured.len());
+ println!("Face down: {}", face_down.len());
+ println!("---------");
+ */
+
+ match (player1.draw(), player2.draw()) {
+ (Some(c1), Some(c2)) =>
+ if c1 > c2 {
+ player1.add(&vec![c1, c2]);
+ if face_down.len() > 0 {
+ player1.add(&face_down);
+ face_down.clear();
+ }
+ } else if c2 > c1 {
+ player2.add(&vec![c1, c2]);
+ if face_down.len() > 0 {
+ player2.add(&face_down);
+ face_down.clear();
+ }
+ } else {
+ face_down.push(c1);
+ face_down.push(c2);
+ match (player1.draw(), player2.draw()) {
+ (Some(c3), Some(c4)) => {
+ face_down.push(c3);
+ face_down.push(c4);
+ }
+ _ =>
+ return current_turn
+ }
+ }
+
+ _ =>
+ return current_turn