Name-spaced functions for deck.
This commit is contained in:
parent
95a1c77a25
commit
bc6b04eb36
@ -6,7 +6,7 @@
|
|||||||
#include "deck.h"
|
#include "deck.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
void allocate_deck(struct deck **deck) {
|
void deck_malloc(struct deck **deck) {
|
||||||
if (!(*deck = malloc(sizeof(**deck)))) {
|
if (!(*deck = malloc(sizeof(**deck)))) {
|
||||||
fprintf(stderr, tty_solitaire_error_message(errno, __FILE__, __LINE__));
|
fprintf(stderr, tty_solitaire_error_message(errno, __FILE__, __LINE__));
|
||||||
exit(errno);
|
exit(errno);
|
||||||
@ -21,7 +21,7 @@ void allocate_deck(struct deck **deck) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_deck(struct deck *deck) {
|
void deck_init(struct deck *deck) {
|
||||||
stack_init(deck->stock);
|
stack_init(deck->stock);
|
||||||
stack_init(deck->waste_pile);
|
stack_init(deck->waste_pile);
|
||||||
for (int i = 0; i < FOUNDATION_STACKS_NUMBER; i++) {
|
for (int i = 0; i < FOUNDATION_STACKS_NUMBER; i++) {
|
||||||
@ -32,7 +32,7 @@ void initialize_deck(struct deck *deck) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_deck(struct deck *deck) {
|
void deck_free(struct deck *deck) {
|
||||||
stack_free(deck->stock);
|
stack_free(deck->stock);
|
||||||
stack_free(deck->waste_pile);
|
stack_free(deck->waste_pile);
|
||||||
for (int i = 0; i < FOUNDATION_STACKS_NUMBER; i++) {
|
for (int i = 0; i < FOUNDATION_STACKS_NUMBER; i++) {
|
||||||
|
@ -13,8 +13,8 @@ struct deck {
|
|||||||
struct stack *maneuvre[MANEUVRE_STACKS_NUMBER];
|
struct stack *maneuvre[MANEUVRE_STACKS_NUMBER];
|
||||||
};
|
};
|
||||||
|
|
||||||
void allocate_deck(struct deck **);
|
void deck_malloc(struct deck **);
|
||||||
void initialize_deck(struct deck *);
|
void deck_init(struct deck *);
|
||||||
void free_deck(struct deck *);
|
void deck_free(struct deck *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -180,8 +180,8 @@ static void deal_cards(struct deck *deck) {
|
|||||||
void game_init() {
|
void game_init() {
|
||||||
allocate_cursor(&cursor);
|
allocate_cursor(&cursor);
|
||||||
initialize_cursor(cursor);
|
initialize_cursor(cursor);
|
||||||
allocate_deck(&deck);
|
deck_malloc(&deck);
|
||||||
initialize_deck(deck);
|
deck_init(deck);
|
||||||
|
|
||||||
/* Setting initial stacks' coordinates. */
|
/* Setting initial stacks' coordinates. */
|
||||||
set_frame(deck->stock->card->frame, STOCK_BEGIN_Y, STOCK_BEGIN_X);
|
set_frame(deck->stock->card->frame, STOCK_BEGIN_Y, STOCK_BEGIN_X);
|
||||||
@ -203,7 +203,7 @@ void game_init() {
|
|||||||
|
|
||||||
void game_end() {
|
void game_end() {
|
||||||
free_cursor(cursor);
|
free_cursor(cursor);
|
||||||
free_deck(deck);
|
deck_free(deck);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_won() {
|
bool game_won() {
|
||||||
|
Loading…
Reference in New Issue
Block a user