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 {
|
||||
NO_VALUE = -1,
|
||||
ACE = 1,
|
||||
TWO = 2,
|
||||
THREE = 3,
|
||||
FOUR = 4,
|
||||
@ -16,8 +17,7 @@ enum value {
|
||||
TEN = 10,
|
||||
JACK = 11,
|
||||
QUEEN = 12,
|
||||
KING = 13,
|
||||
ACE = 14
|
||||
KING = 13
|
||||
};
|
||||
|
||||
enum suit {
|
||||
|
29
src/game.c
29
src/game.c
@ -62,14 +62,14 @@ bool foundation_stack(struct stack *stack) {
|
||||
|
||||
bool maneuvre_stack(struct stack *stack) {
|
||||
return(stack && stack->card && stack->card->frame &&
|
||||
stack->card->frame->begin_y >= MANEUVRE_BEGIN_Y &&
|
||||
(stack->card->frame->begin_x == MANEUVRE_0_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_1_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_2_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_3_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_4_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_5_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_6_BEGIN_X));
|
||||
stack->card->frame->begin_y >= MANEUVRE_BEGIN_Y &&
|
||||
(stack->card->frame->begin_x == MANEUVRE_0_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_1_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_2_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_3_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_4_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_5_BEGIN_X ||
|
||||
stack->card->frame->begin_x == MANEUVRE_6_BEGIN_X));
|
||||
}
|
||||
|
||||
bool valid_move(struct stack *origin, struct stack *destination) {
|
||||
@ -80,17 +80,18 @@ bool valid_move(struct stack *origin, struct stack *destination) {
|
||||
if (empty(destination)) {
|
||||
if (origin->card->value == ACE) {
|
||||
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)) {
|
||||
if (empty(destination)) {
|
||||
if (origin->card->value == KING) {
|
||||
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) {
|
||||
return(true);
|
||||
}
|
||||
@ -116,9 +117,9 @@ void move_card(struct stack **origin, struct stack **destination) {
|
||||
static void fill_deck(struct deck *deck) {
|
||||
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++) {
|
||||
int index = 4 * (i - TWO) + j;
|
||||
int index = 4 * (i - ACE) + j;
|
||||
allocate_card(&(card[index]));
|
||||
set_card(card[index], i, j, COVERED, 1, 1);
|
||||
push(&(deck->stock), card[index]);
|
||||
|
Loading…
Reference in New Issue
Block a user