From 2cd63146ca96049f8f3e44cd83e8652998acd434 Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Sat, 10 Apr 2010 00:56:44 -0300 Subject: [PATCH] Added function to deal the cards when the game starts. --- lib/deck.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lib/deck.h | 1 + 2 files changed, 47 insertions(+) diff --git a/lib/deck.c b/lib/deck.c index 8ccfc8a..ad76ff4 100644 --- a/lib/deck.c +++ b/lib/deck.c @@ -203,3 +203,49 @@ void shuffle_deck(struct deck *deck) { return; } + +void deal_cards(struct deck *deck) { + move_card(&(deck->stock), &(deck->maneuvre_0)); + expose_card(deck->maneuvre_0->card); + move_card(&(deck->stock), &(deck->maneuvre_1)); + move_card(&(deck->stock), &(deck->maneuvre_2)); + move_card(&(deck->stock), &(deck->maneuvre_3)); + move_card(&(deck->stock), &(deck->maneuvre_4)); + move_card(&(deck->stock), &(deck->maneuvre_5)); + move_card(&(deck->stock), &(deck->maneuvre_6)); + + move_card(&(deck->stock), &(deck->maneuvre_1)); + expose_card(deck->maneuvre_1->card); + move_card(&(deck->stock), &(deck->maneuvre_2)); + move_card(&(deck->stock), &(deck->maneuvre_3)); + move_card(&(deck->stock), &(deck->maneuvre_4)); + move_card(&(deck->stock), &(deck->maneuvre_5)); + move_card(&(deck->stock), &(deck->maneuvre_6)); + + move_card(&(deck->stock), &(deck->maneuvre_2)); + expose_card(deck->maneuvre_2->card); + move_card(&(deck->stock), &(deck->maneuvre_3)); + move_card(&(deck->stock), &(deck->maneuvre_4)); + move_card(&(deck->stock), &(deck->maneuvre_5)); + move_card(&(deck->stock), &(deck->maneuvre_6)); + + move_card(&(deck->stock), &(deck->maneuvre_3)); + expose_card(deck->maneuvre_3->card); + move_card(&(deck->stock), &(deck->maneuvre_4)); + move_card(&(deck->stock), &(deck->maneuvre_5)); + move_card(&(deck->stock), &(deck->maneuvre_6)); + + move_card(&(deck->stock), &(deck->maneuvre_4)); + expose_card(deck->maneuvre_4->card); + move_card(&(deck->stock), &(deck->maneuvre_5)); + move_card(&(deck->stock), &(deck->maneuvre_6)); + + move_card(&(deck->stock), &(deck->maneuvre_5)); + expose_card(deck->maneuvre_5->card); + move_card(&(deck->stock), &(deck->maneuvre_6)); + + move_card(&(deck->stock), &(deck->maneuvre_6)); + expose_card(deck->maneuvre_6->card); + + return; +} diff --git a/lib/deck.h b/lib/deck.h index 6433a51..ba0e55c 100644 --- a/lib/deck.h +++ b/lib/deck.h @@ -56,5 +56,6 @@ void delete_deck(struct deck *); void set_deck_stacks_coordinates(struct deck *); void fill_deck(struct deck *); void shuffle_deck(struct deck *); +void deal_cards(struct deck *); #endif