Added actual klondlike solitaire rules for moving cards.

This commit is contained in:
Murilo Pereira 2011-06-01 02:18:53 -03:00
parent 69d3647dae
commit 74bdd55bd5

View File

@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <assert.h>
@ -74,34 +73,32 @@ bool maneuvre_stack(struct stack *stack) {
}
bool valid_move(struct stack *origin, struct stack *destination) {
if (stock_stack(origin)) {
if (waste_pile_stack(destination)) {
if (origin->card->face == EXPOSED) {
if (stock_stack(origin) && waste_pile_stack(destination)) {
return(true);
} else {
return(false);
}
} else if (waste_pile_stack(origin)) {
if (foundation_stack(destination) || maneuvre_stack(destination)) {
} else if (foundation_stack(destination)) {
if (empty(destination)) {
if (origin->card->value == ACE) {
return(true);
} else {
return(false);
}
} else if (foundation_stack(origin)) {
if ((foundation_stack(destination) && origin != destination) || maneuvre_stack(destination)) {
} else if (origin->card->suit == destination->card->suit &&
origin->card->value + 1 == destination->card->value) {
return(true);
} else {
return(false);
}
} else if (maneuvre_stack(origin)) {
if ((maneuvre_stack(destination) && origin != destination) || foundation_stack(destination)) {
}
} else if (maneuvre_stack(destination)) {
if (empty(destination)) {
if (origin->card->value == KING) {
return(true);
} else {
return(false);
}
} else {
return(false);
} else if ((origin->card->suit + destination->card->suit) % 2 == 1 &&
origin->card->value + 1 == destination->card->value) {
return(true);
}
}
}
return(false);
}
void move_card(struct stack **origin, struct stack **destination) {
struct card *tmp;