delete() for all structures.
This commit is contained in:
parent
ecaa2a4c68
commit
90c7ce6280
21
lib/deck.c
21
lib/deck.c
@ -40,3 +40,24 @@ void initialize_deck(struct deck *deck) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void delete_deck(struct deck *deck) {
|
||||||
|
delete_stack(deck->stock);
|
||||||
|
|
||||||
|
delete_stack(deck->foundation_0);
|
||||||
|
delete_stack(deck->foundation_1);
|
||||||
|
delete_stack(deck->foundation_2);
|
||||||
|
delete_stack(deck->foundation_3);
|
||||||
|
|
||||||
|
delete_stack(deck->maneuvre_0);
|
||||||
|
delete_stack(deck->maneuvre_1);
|
||||||
|
delete_stack(deck->maneuvre_2);
|
||||||
|
delete_stack(deck->maneuvre_3);
|
||||||
|
delete_stack(deck->maneuvre_4);
|
||||||
|
delete_stack(deck->maneuvre_5);
|
||||||
|
delete_stack(deck->maneuvre_6);
|
||||||
|
|
||||||
|
free(deck);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@ struct deck {
|
|||||||
|
|
||||||
void allocate_deck(struct deck **);
|
void allocate_deck(struct deck **);
|
||||||
void initialize_deck(struct deck *);
|
void initialize_deck(struct deck *);
|
||||||
//void delete_deck(struct deck *);
|
void delete_deck(struct deck *);
|
||||||
|
void shuffle_deck(struct deck *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,6 +42,8 @@ void draw_empty_stacks() {
|
|||||||
delwin(empty_stack[i]);
|
delwin(empty_stack[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(empty_stack);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +51,9 @@ void initialize_game() {
|
|||||||
struct deck *deck = NULL;
|
struct deck *deck = NULL;
|
||||||
|
|
||||||
draw_empty_stacks();
|
draw_empty_stacks();
|
||||||
|
allocate_deck(&deck);
|
||||||
|
initialize_deck(deck);
|
||||||
|
delete_deck(deck);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,18 @@ void allocate_stack(struct stack **stack) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initialize_stack(struct stack *stack) {
|
void initialize_stack(struct stack *stack) {
|
||||||
stack->card = NULL;
|
|
||||||
stack->next = NULL;
|
stack->next = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void delete_stack(struct stack *stack) {
|
||||||
|
delete_card(stack->card);
|
||||||
|
free(stack);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool empty(struct stack *stack) {
|
bool empty(struct stack *stack) {
|
||||||
return(stack->card == NULL);
|
return(stack->card == NULL);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ struct stack {
|
|||||||
|
|
||||||
void allocate_stack(struct stack **);
|
void allocate_stack(struct stack **);
|
||||||
void initialize_stack(struct stack *);
|
void initialize_stack(struct stack *);
|
||||||
|
void delete_stack(struct stack *);
|
||||||
bool empty(struct stack *);
|
bool empty(struct stack *);
|
||||||
int length(struct stack *);
|
int length(struct stack *);
|
||||||
void push(struct stack **, struct card *);
|
void push(struct stack **, struct card *);
|
||||||
|
Loading…
Reference in New Issue
Block a user