Added actual klondlike solitaire rules for moving cards.
This commit is contained in:
parent
69d3647dae
commit
74bdd55bd5
39
src/game.c
39
src/game.c
@ -1,7 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -74,34 +73,32 @@ bool maneuvre_stack(struct stack *stack) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool valid_move(struct stack *origin, struct stack *destination) {
|
bool valid_move(struct stack *origin, struct stack *destination) {
|
||||||
if (stock_stack(origin)) {
|
if (origin->card->face == EXPOSED) {
|
||||||
if (waste_pile_stack(destination)) {
|
if (stock_stack(origin) && waste_pile_stack(destination)) {
|
||||||
return(true);
|
return(true);
|
||||||
} else {
|
} else if (foundation_stack(destination)) {
|
||||||
return(false);
|
if (empty(destination)) {
|
||||||
}
|
if (origin->card->value == ACE) {
|
||||||
} else if (waste_pile_stack(origin)) {
|
|
||||||
if (foundation_stack(destination) || maneuvre_stack(destination)) {
|
|
||||||
return(true);
|
return(true);
|
||||||
} else {
|
} else if (origin->card->suit == destination->card->suit &&
|
||||||
return(false);
|
origin->card->value + 1 == destination->card->value) {
|
||||||
}
|
|
||||||
} else if (foundation_stack(origin)) {
|
|
||||||
if ((foundation_stack(destination) && origin != destination) || maneuvre_stack(destination)) {
|
|
||||||
return(true);
|
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);
|
return(true);
|
||||||
} else {
|
|
||||||
return(false);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else if ((origin->card->suit + destination->card->suit) % 2 == 1 &&
|
||||||
return(false);
|
origin->card->value + 1 == destination->card->value) {
|
||||||
|
return(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
void move_card(struct stack **origin, struct stack **destination) {
|
void move_card(struct stack **origin, struct stack **destination) {
|
||||||
struct card *tmp;
|
struct card *tmp;
|
||||||
|
Loading…
Reference in New Issue
Block a user