Fixed some things.
* Movement to empty maneuvre stacks only accept kings. * Fixed moving to foundation stacks that are not empty. * Card values go from ACE to KING.
This commit is contained in:
parent
2092abc021
commit
51c3b51a8b
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
enum value {
|
enum value {
|
||||||
NO_VALUE = -1,
|
NO_VALUE = -1,
|
||||||
|
ACE = 1,
|
||||||
TWO = 2,
|
TWO = 2,
|
||||||
THREE = 3,
|
THREE = 3,
|
||||||
FOUR = 4,
|
FOUR = 4,
|
||||||
@ -16,8 +17,7 @@ enum value {
|
|||||||
TEN = 10,
|
TEN = 10,
|
||||||
JACK = 11,
|
JACK = 11,
|
||||||
QUEEN = 12,
|
QUEEN = 12,
|
||||||
KING = 13,
|
KING = 13
|
||||||
ACE = 14
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum suit {
|
enum suit {
|
||||||
|
13
src/game.c
13
src/game.c
@ -80,17 +80,18 @@ bool valid_move(struct stack *origin, struct stack *destination) {
|
|||||||
if (empty(destination)) {
|
if (empty(destination)) {
|
||||||
if (origin->card->value == ACE) {
|
if (origin->card->value == ACE) {
|
||||||
return(true);
|
return(true);
|
||||||
} else if (origin->card->suit == destination->card->suit &&
|
|
||||||
origin->card->value + 1 == destination->card->value) {
|
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
} else if (origin->card->suit == destination->card->suit &&
|
||||||
|
origin->card->value == destination->card->value + 1) {
|
||||||
|
return(true);
|
||||||
}
|
}
|
||||||
} else if (maneuvre_stack(destination)) {
|
} else if (maneuvre_stack(destination)) {
|
||||||
if (empty(destination)) {
|
if (empty(destination)) {
|
||||||
if (origin->card->value == KING) {
|
if (origin->card->value == KING) {
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
} else if ((origin->card->suit + destination->card->suit) % 2 == 1 &&
|
} else if (destination->card->face == EXPOSED &&
|
||||||
|
(origin->card->suit + destination->card->suit) % 2 == 1 &&
|
||||||
origin->card->value + 1 == destination->card->value) {
|
origin->card->value + 1 == destination->card->value) {
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -116,9 +117,9 @@ void move_card(struct stack **origin, struct stack **destination) {
|
|||||||
static void fill_deck(struct deck *deck) {
|
static void fill_deck(struct deck *deck) {
|
||||||
struct card *card[NUMBER_OF_CARDS];
|
struct card *card[NUMBER_OF_CARDS];
|
||||||
|
|
||||||
for (int i = TWO; i <= ACE; i++) {
|
for (int i = ACE; i <= KING; i++) {
|
||||||
for (int j = DIAMONDS; j <= CLUBS; j++) {
|
for (int j = DIAMONDS; j <= CLUBS; j++) {
|
||||||
int index = 4 * (i - TWO) + j;
|
int index = 4 * (i - ACE) + j;
|
||||||
allocate_card(&(card[index]));
|
allocate_card(&(card[index]));
|
||||||
set_card(card[index], i, j, COVERED, 1, 1);
|
set_card(card[index], i, j, COVERED, 1, 1);
|
||||||
push(&(deck->stock), card[index]);
|
push(&(deck->stock), card[index]);
|
||||||
|
Loading…
Reference in New Issue
Block a user