s/start/begin

This commit is contained in:
Murilo Pereira 2011-05-09 00:38:31 -03:00
parent 539c0ecb00
commit 9ecf0acec8
16 changed files with 229 additions and 229 deletions

View File

@ -30,8 +30,8 @@ struct card *duplicate_card(struct card *card) {
card->value, card->value,
card->suit, card->suit,
card->face, card->face,
card->frame->start_y, card->frame->begin_y,
card->frame->start_x); card->frame->begin_x);
return(new_card); return(new_card);
} }
@ -47,9 +47,9 @@ void set_card(struct card *card,
enum value value, enum value value,
enum suit suit, enum suit suit,
enum face face, enum face face,
int start_y, int begin_y,
int start_x) { int begin_x) {
set_frame(card->frame, start_y, start_x); set_frame(card->frame, begin_y, begin_x);
card->value = value; card->value = value;
card->suit = suit; card->suit = suit;
card->face = face; card->face = face;

View File

@ -17,17 +17,17 @@ void allocate_cursor(struct cursor **cursor) {
} }
void initialize_cursor(struct cursor *cursor) { void initialize_cursor(struct cursor *cursor) {
cursor->x = CURSOR_STARTING_X; cursor->x = CURSOR_BEGIN_X;
cursor->y = CURSOR_STARTING_Y; cursor->y = CURSOR_BEGIN_Y;
} }
void move_cursor(struct cursor *cursor, enum movement movement) { void move_cursor(struct cursor *cursor, enum movement movement) {
switch (movement) { switch (movement) {
case LEFT: case LEFT:
if (cursor->x > CURSOR_STARTING_X) { if (cursor->x > CURSOR_BEGIN_X) {
erase_cursor(cursor); erase_cursor(cursor);
cursor->x = cursor->x - 8; cursor->x = cursor->x - 8;
if (cursor->y > CURSOR_STARTING_Y) { if (cursor->y > CURSOR_BEGIN_Y) {
move_cursor(cursor, UP); move_cursor(cursor, UP);
move_cursor(cursor, DOWN); move_cursor(cursor, DOWN);
} }
@ -35,28 +35,28 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
} }
break; break;
case DOWN: case DOWN:
if (cursor->y == CURSOR_STARTING_Y) { if (cursor->y == CURSOR_BEGIN_Y) {
erase_cursor(cursor); erase_cursor(cursor);
switch (cursor->x - 3) { switch (cursor->x - 3) {
case MANEUVRE_0_STARTING_X: case MANEUVRE_0_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_0); cursor->y = cursor->y + 7 + length(deck->maneuvre_0);
break; break;
case MANEUVRE_1_STARTING_X: case MANEUVRE_1_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_1); cursor->y = cursor->y + 7 + length(deck->maneuvre_1);
break; break;
case MANEUVRE_2_STARTING_X: case MANEUVRE_2_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_2); cursor->y = cursor->y + 7 + length(deck->maneuvre_2);
break; break;
case MANEUVRE_3_STARTING_X: case MANEUVRE_3_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_3); cursor->y = cursor->y + 7 + length(deck->maneuvre_3);
break; break;
case MANEUVRE_4_STARTING_X: case MANEUVRE_4_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_4); cursor->y = cursor->y + 7 + length(deck->maneuvre_4);
break; break;
case MANEUVRE_5_STARTING_X: case MANEUVRE_5_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_5); cursor->y = cursor->y + 7 + length(deck->maneuvre_5);
break; break;
case MANEUVRE_6_STARTING_X: case MANEUVRE_6_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_6); cursor->y = cursor->y + 7 + length(deck->maneuvre_6);
break; break;
} }
@ -67,7 +67,7 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
if (cursor->x < 49) { if (cursor->x < 49) {
erase_cursor(cursor); erase_cursor(cursor);
cursor->x = cursor->x + 8; cursor->x = cursor->x + 8;
if (cursor->y > CURSOR_STARTING_Y) { if (cursor->y > CURSOR_BEGIN_Y) {
move_cursor(cursor, UP); move_cursor(cursor, UP);
move_cursor(cursor, DOWN); move_cursor(cursor, DOWN);
} }
@ -77,7 +77,7 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
case UP: case UP:
if (cursor->y > 1) { if (cursor->y > 1) {
erase_cursor(cursor); erase_cursor(cursor);
cursor->y = CURSOR_STARTING_Y; cursor->y = CURSOR_BEGIN_Y;
draw_cursor(cursor); draw_cursor(cursor);
} }
break; break;

View File

@ -4,8 +4,8 @@
#include <stdbool.h> #include <stdbool.h>
#include "deck.h" #include "deck.h"
#define CURSOR_STARTING_X 4 #define CURSOR_BEGIN_X 4
#define CURSOR_STARTING_Y 7 #define CURSOR_BEGIN_Y 7
#define CURSOR_INVALID_SPOT_X 20 #define CURSOR_INVALID_SPOT_X 20
#define CURSOR_INVALID_SPOT_Y 7 #define CURSOR_INVALID_SPOT_Y 7

View File

@ -62,8 +62,8 @@ void erase_stack(struct stack *stack) {
wrefresh(stack->card->frame->shape); wrefresh(stack->card->frame->shape);
empty_stack = newwin(FRAME_HEIGHT, empty_stack = newwin(FRAME_HEIGHT,
FRAME_WIDTH, FRAME_WIDTH,
stack->card->frame->start_y, stack->card->frame->begin_y,
stack->card->frame->start_x); stack->card->frame->begin_x);
box(empty_stack, 0, 0); box(empty_stack, 0, 0);
wrefresh(empty_stack); wrefresh(empty_stack);
delwin(empty_stack); delwin(empty_stack);
@ -105,7 +105,7 @@ void draw_back(struct card *card) {
} }
void draw_card(struct card *card) { void draw_card(struct card *card) {
mvwin(card->frame->shape, card->frame->start_y, card->frame->start_x); mvwin(card->frame->shape, card->frame->begin_y, card->frame->begin_x);
if (card->face == EXPOSED) { if (card->face == EXPOSED) {
draw_front(card); draw_front(card);
} else { } else {
@ -119,8 +119,8 @@ void draw_stack(struct stack *stack) {
if (empty(stack)) { if (empty(stack)) {
WINDOW *empty_stack = newwin(FRAME_HEIGHT, WINDOW *empty_stack = newwin(FRAME_HEIGHT,
FRAME_WIDTH, FRAME_WIDTH,
stack->card->frame->start_y, stack->card->frame->begin_y,
stack->card->frame->start_x); stack->card->frame->begin_x);
box(empty_stack, 0, 0); box(empty_stack, 0, 0);
wrefresh(empty_stack); wrefresh(empty_stack);
delwin(empty_stack); delwin(empty_stack);

View File

@ -15,15 +15,15 @@ void allocate_frame(struct frame **frame) {
void initialize_frame(struct frame *frame) { void initialize_frame(struct frame *frame) {
frame->shape = NULL; frame->shape = NULL;
frame->start_y = 0; frame->begin_y = 0;
frame->start_x = 0; frame->begin_x = 0;
} }
struct frame *duplicate_frame(struct frame *frame) { struct frame *duplicate_frame(struct frame *frame) {
struct frame *new_frame; struct frame *new_frame;
allocate_frame(&new_frame); allocate_frame(&new_frame);
set_frame(new_frame, frame->start_y, frame->start_x); set_frame(new_frame, frame->begin_y, frame->begin_x);
return(new_frame); return(new_frame);
} }
@ -35,11 +35,11 @@ void free_frame(struct frame *frame) {
free(frame); free(frame);
} }
void set_frame(struct frame *frame, int start_y, int start_x) { void set_frame(struct frame *frame, int begin_y, int begin_x) {
frame->start_y = start_y; frame->begin_y = begin_y;
frame->start_x = start_x; frame->begin_x = begin_x;
frame->shape = newwin(FRAME_HEIGHT, frame->shape = newwin(FRAME_HEIGHT,
FRAME_WIDTH, FRAME_WIDTH,
frame->start_y, frame->begin_y,
frame->start_x); frame->begin_x);
} }

View File

@ -8,8 +8,8 @@
struct frame { struct frame {
WINDOW *shape; WINDOW *shape;
int start_y; int begin_y;
int start_x; int begin_x;
}; };
void allocate_frame(struct frame **); void allocate_frame(struct frame **);

View File

@ -11,35 +11,35 @@
bool stock_stack(struct stack *stack) { bool stock_stack(struct stack *stack) {
return(stack && stack->card && stack->card->frame && return(stack && stack->card && stack->card->frame &&
(stack->card->frame->start_y == STOCK_STARTING_Y) && (stack->card->frame->begin_y == STOCK_BEGIN_Y) &&
(stack->card->frame->start_x == STOCK_STARTING_X)); (stack->card->frame->begin_x == STOCK_BEGIN_X));
} }
bool waste_pile_stack(struct stack *stack) { bool waste_pile_stack(struct stack *stack) {
return(stack && stack->card && stack->card->frame && return(stack && stack->card && stack->card->frame &&
(stack->card->frame->start_y == WASTE_PILE_STARTING_Y) && (stack->card->frame->begin_y == WASTE_PILE_BEGIN_Y) &&
(stack->card->frame->start_x == WASTE_PILE_STARTING_X)); (stack->card->frame->begin_x == WASTE_PILE_BEGIN_X));
} }
bool foundation_stack(struct stack *stack) { bool foundation_stack(struct stack *stack) {
return(stack && stack->card && stack->card->frame && return(stack && stack->card && stack->card->frame &&
stack->card->frame->start_y == FOUNDATION_STARTING_Y && stack->card->frame->begin_y == FOUNDATION_BEGIN_Y &&
(stack->card->frame->start_x == FOUNDATION_0_STARTING_X || (stack->card->frame->begin_x == FOUNDATION_0_BEGIN_X ||
stack->card->frame->start_x == FOUNDATION_1_STARTING_X || stack->card->frame->begin_x == FOUNDATION_1_BEGIN_X ||
stack->card->frame->start_x == FOUNDATION_2_STARTING_X || stack->card->frame->begin_x == FOUNDATION_2_BEGIN_X ||
stack->card->frame->start_x == FOUNDATION_3_STARTING_X)); stack->card->frame->begin_x == FOUNDATION_3_BEGIN_X));
} }
bool maneuvre_stack(struct stack *stack) { bool maneuvre_stack(struct stack *stack) {
return(stack && stack->card && stack->card->frame && return(stack && stack->card && stack->card->frame &&
stack->card->frame->start_y >= MANEUVRE_STACKS_STARTING_Y && stack->card->frame->begin_y >= MANEUVRE_STACKS_BEGIN_Y &&
(stack->card->frame->start_x == MANEUVRE_0_STARTING_X || (stack->card->frame->begin_x == MANEUVRE_0_BEGIN_X ||
stack->card->frame->start_x == MANEUVRE_1_STARTING_X || stack->card->frame->begin_x == MANEUVRE_1_BEGIN_X ||
stack->card->frame->start_x == MANEUVRE_2_STARTING_X || stack->card->frame->begin_x == MANEUVRE_2_BEGIN_X ||
stack->card->frame->start_x == MANEUVRE_3_STARTING_X || stack->card->frame->begin_x == MANEUVRE_3_BEGIN_X ||
stack->card->frame->start_x == MANEUVRE_4_STARTING_X || stack->card->frame->begin_x == MANEUVRE_4_BEGIN_X ||
stack->card->frame->start_x == MANEUVRE_5_STARTING_X || stack->card->frame->begin_x == MANEUVRE_5_BEGIN_X ||
stack->card->frame->start_x == MANEUVRE_6_STARTING_X)); stack->card->frame->begin_x == MANEUVRE_6_BEGIN_X));
} }
bool valid_move(struct stack *origin, struct stack *destination) { bool valid_move(struct stack *origin, struct stack *destination) {
@ -76,11 +76,11 @@ void move_card(struct stack **origin, struct stack **destination) {
struct stack *stack; struct stack *stack;
if (!empty(*origin)) { if (!empty(*origin)) {
(*origin)->card->frame->start_x = (*destination)->card->frame->start_x; (*origin)->card->frame->begin_x = (*destination)->card->frame->begin_x;
(*origin)->card->frame->start_y = (*destination)->card->frame->start_y; (*origin)->card->frame->begin_y = (*destination)->card->frame->begin_y;
} }
if (!empty(*destination) && maneuvre_stack(*destination)) { if (!empty(*destination) && maneuvre_stack(*destination)) {
(*origin)->card->frame->start_y++; (*origin)->card->frame->begin_y++;
} }
if ((stack = pop(origin))) { if ((stack = pop(origin))) {
push(destination, stack->card); push(destination, stack->card);
@ -89,44 +89,44 @@ void move_card(struct stack **origin, struct stack **destination) {
static void set_stacks_initial_coordinates(struct deck *deck) { static void set_stacks_initial_coordinates(struct deck *deck) {
set_frame(deck->stock->card->frame, set_frame(deck->stock->card->frame,
STOCK_STARTING_Y, STOCK_BEGIN_Y,
STOCK_STARTING_X); STOCK_BEGIN_X);
set_frame(deck->waste_pile->card->frame, set_frame(deck->waste_pile->card->frame,
WASTE_PILE_STARTING_Y, WASTE_PILE_BEGIN_Y,
WASTE_PILE_STARTING_X); WASTE_PILE_BEGIN_X);
set_frame(deck->foundation_0->card->frame, set_frame(deck->foundation_0->card->frame,
FOUNDATION_STARTING_Y, FOUNDATION_BEGIN_Y,
FOUNDATION_0_STARTING_X); FOUNDATION_0_BEGIN_X);
set_frame(deck->foundation_1->card->frame, set_frame(deck->foundation_1->card->frame,
FOUNDATION_STARTING_Y, FOUNDATION_BEGIN_Y,
FOUNDATION_1_STARTING_X); FOUNDATION_1_BEGIN_X);
set_frame(deck->foundation_2->card->frame, set_frame(deck->foundation_2->card->frame,
FOUNDATION_STARTING_Y, FOUNDATION_BEGIN_Y,
FOUNDATION_2_STARTING_X); FOUNDATION_2_BEGIN_X);
set_frame(deck->foundation_3->card->frame, set_frame(deck->foundation_3->card->frame,
FOUNDATION_STARTING_Y, FOUNDATION_BEGIN_Y,
FOUNDATION_3_STARTING_X); FOUNDATION_3_BEGIN_X);
set_frame(deck->maneuvre_0->card->frame, set_frame(deck->maneuvre_0->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_0_STARTING_X); MANEUVRE_0_BEGIN_X);
set_frame(deck->maneuvre_1->card->frame, set_frame(deck->maneuvre_1->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_1_STARTING_X); MANEUVRE_1_BEGIN_X);
set_frame(deck->maneuvre_2->card->frame, set_frame(deck->maneuvre_2->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_2_STARTING_X); MANEUVRE_2_BEGIN_X);
set_frame(deck->maneuvre_3->card->frame, set_frame(deck->maneuvre_3->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_3_STARTING_X); MANEUVRE_3_BEGIN_X);
set_frame(deck->maneuvre_4->card->frame, set_frame(deck->maneuvre_4->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_4_STARTING_X); MANEUVRE_4_BEGIN_X);
set_frame(deck->maneuvre_5->card->frame, set_frame(deck->maneuvre_5->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_5_STARTING_X); MANEUVRE_5_BEGIN_X);
set_frame(deck->maneuvre_6->card->frame, set_frame(deck->maneuvre_6->card->frame,
MANEUVRE_STARTING_Y, MANEUVRE_BEGIN_Y,
MANEUVRE_6_STARTING_X); MANEUVRE_6_BEGIN_X);
} }
static void fill_deck(struct deck *deck) { static void fill_deck(struct deck *deck) {

View File

@ -7,28 +7,28 @@
#define NUMBER_OF_CARDS 52 #define NUMBER_OF_CARDS 52
#define MANEUVRE_STACKS_STARTING_Y 7 #define MANEUVRE_STACKS_BEGIN_Y 7
#define STOCK_STARTING_X 1 #define STOCK_BEGIN_X 1
#define STOCK_STARTING_Y 1 #define STOCK_BEGIN_Y 1
#define WASTE_PILE_STARTING_X 9 #define WASTE_PILE_BEGIN_X 9
#define WASTE_PILE_STARTING_Y 1 #define WASTE_PILE_BEGIN_Y 1
#define FOUNDATION_STARTING_Y 1 #define FOUNDATION_BEGIN_Y 1
#define FOUNDATION_0_STARTING_X 25 #define FOUNDATION_0_BEGIN_X 25
#define FOUNDATION_1_STARTING_X 33 #define FOUNDATION_1_BEGIN_X 33
#define FOUNDATION_2_STARTING_X 41 #define FOUNDATION_2_BEGIN_X 41
#define FOUNDATION_3_STARTING_X 49 #define FOUNDATION_3_BEGIN_X 49
#define MANEUVRE_STARTING_Y 9 #define MANEUVRE_BEGIN_Y 9
#define MANEUVRE_0_STARTING_X 1 #define MANEUVRE_0_BEGIN_X 1
#define MANEUVRE_1_STARTING_X 9 #define MANEUVRE_1_BEGIN_X 9
#define MANEUVRE_2_STARTING_X 17 #define MANEUVRE_2_BEGIN_X 17
#define MANEUVRE_3_STARTING_X 25 #define MANEUVRE_3_BEGIN_X 25
#define MANEUVRE_4_STARTING_X 33 #define MANEUVRE_4_BEGIN_X 33
#define MANEUVRE_5_STARTING_X 41 #define MANEUVRE_5_BEGIN_X 41
#define MANEUVRE_6_STARTING_X 49 #define MANEUVRE_6_BEGIN_X 49
struct deck *deck; struct deck *deck;
struct cursor *cursor; struct cursor *cursor;

View File

@ -6,13 +6,13 @@
#include "keyboard.h" #include "keyboard.h"
static bool cursor_on_stock(struct cursor *cursor) { static bool cursor_on_stock(struct cursor *cursor) {
return((cursor->x == CURSOR_STARTING_X) && (cursor->y == CURSOR_STARTING_Y)); return((cursor->x == CURSOR_BEGIN_X) && (cursor->y == CURSOR_BEGIN_Y));
} }
static struct stack *cursor_stack(struct cursor *cursor) { static struct stack *cursor_stack(struct cursor *cursor) {
struct stack *cursor_stack = NULL; struct stack *cursor_stack = NULL;
if (cursor->y == CURSOR_STARTING_Y) { if (cursor->y == CURSOR_BEGIN_Y) {
switch (cursor->x) { switch (cursor->x) {
case CURSOR_STOCK_X: cursor_stack = deck->stock; break; case CURSOR_STOCK_X: cursor_stack = deck->stock; break;
case CURSOR_WASTE_PILE_X: cursor_stack = deck->waste_pile; break; case CURSOR_WASTE_PILE_X: cursor_stack = deck->waste_pile; break;

View File

@ -98,8 +98,8 @@ struct stack *pop(struct stack **stack) {
NO_VALUE, NO_VALUE,
NO_SUIT, NO_SUIT,
NO_FACE, NO_FACE,
(*stack)->card->frame->start_y, (*stack)->card->frame->begin_y,
(*stack)->card->frame->start_x); (*stack)->card->frame->begin_x);
(*stack)->next = NULL; (*stack)->next = NULL;
} else { } else {
*stack = (*stack)->next; *stack = (*stack)->next;

View File

@ -17,10 +17,10 @@ void test_initialize_card() {
void test_duplicate_card() { void test_duplicate_card() {
struct card *card_0, *card_1; struct card *card_0, *card_1;
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_card(&card_0); allocate_card(&card_0);
set_card(card_0, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card_0, ACE, SPADES, EXPOSED, begin_y, begin_x);
card_1 = duplicate_card(card_0); card_1 = duplicate_card(card_0);
assert(card_0 != card_1); assert(card_0 != card_1);
@ -29,18 +29,18 @@ void test_duplicate_card() {
void test_set_card() { void test_set_card() {
struct card *card; struct card *card;
int start_y = 5; int begin_y = 5;
int start_x = 10; int begin_x = 10;
allocate_card(&card); allocate_card(&card);
initialize_card(card); initialize_card(card);
set_card(card, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card, ACE, SPADES, EXPOSED, begin_y, begin_x);
assert(card->value == ACE); assert(card->value == ACE);
assert(card->suit == SPADES); assert(card->suit == SPADES);
assert(card->face == EXPOSED); assert(card->face == EXPOSED);
assert(card->frame->start_y == start_y); assert(card->frame->begin_y == begin_y);
assert(card->frame->start_x == start_x); assert(card->frame->begin_x == begin_x);
free_card(card); free_card(card);
} }

View File

@ -9,18 +9,18 @@ void test_initialize_frame() {
initialize_frame(frame); initialize_frame(frame);
assert(frame->shape == NULL); assert(frame->shape == NULL);
assert(frame->start_y == 0); assert(frame->begin_y == 0);
assert(frame->start_x == 0); assert(frame->begin_x == 0);
free_frame(frame); free_frame(frame);
} }
void test_duplicate_frame() { void test_duplicate_frame() {
struct frame *frame_0, *frame_1; struct frame *frame_0, *frame_1;
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_frame(&frame_0); allocate_frame(&frame_0);
set_frame(frame_0, start_y, start_x); set_frame(frame_0, begin_y, begin_x);
frame_1 = duplicate_frame(frame_0); frame_1 = duplicate_frame(frame_0);
assert(frame_0 != frame_1); assert(frame_0 != frame_1);
@ -29,15 +29,15 @@ void test_duplicate_frame() {
void test_set_frame() { void test_set_frame() {
struct frame *frame; struct frame *frame;
int start_y = 5; int begin_y = 5;
int start_x = 10; int begin_x = 10;
allocate_frame(&frame); allocate_frame(&frame);
initialize_frame(frame); initialize_frame(frame);
set_frame(frame, start_y, start_x); set_frame(frame, begin_y, begin_x);
assert(frame->start_y == start_y); assert(frame->begin_y == begin_y);
assert(frame->start_x == start_x); assert(frame->begin_x == begin_x);
free_frame(frame); free_frame(frame);
} }

View File

@ -115,8 +115,8 @@ void test_valid_move_from_stock_to_stock() {
allocate_stack(&stock_1); allocate_stack(&stock_1);
initialize_stack(stock_0); initialize_stack(stock_0);
initialize_stack(stock_1); initialize_stack(stock_1);
set_card(stock_0->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock_0->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
set_card(stock_1->card, KING, HEARTS, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock_1->card, KING, HEARTS, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
assert(!valid_move(stock_0, stock_0)); assert(!valid_move(stock_0, stock_0));
assert(!valid_move(stock_0, stock_1)); assert(!valid_move(stock_0, stock_1));
assert(!valid_move(stock_1, stock_0)); assert(!valid_move(stock_1, stock_0));
@ -132,8 +132,8 @@ void test_valid_move_from_stock_to_waste_pile() {
allocate_stack(&waste_pile); allocate_stack(&waste_pile);
initialize_stack(stock); initialize_stack(stock);
initialize_stack(waste_pile); initialize_stack(waste_pile);
set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
set_card(waste_pile->card, KING, HEARTS, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile->card, KING, HEARTS, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
assert(valid_move(stock, waste_pile)); assert(valid_move(stock, waste_pile));
free_stack(stock); free_stack(stock);
free_stack(waste_pile); free_stack(waste_pile);
@ -144,15 +144,15 @@ void test_valid_move_from_stock_to_foundation_stacks() {
allocate_stack(&stock); allocate_stack(&stock);
initialize_stack(stock); initialize_stack(stock);
set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
assert(!valid_move(stock, foundation_stacks[i])); assert(!valid_move(stock, foundation_stacks[i]));
} }
@ -167,18 +167,18 @@ void test_valid_move_from_stock_to_maneuvre_stacks() {
allocate_stack(&stock); allocate_stack(&stock);
initialize_stack(stock); initialize_stack(stock);
set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
assert(!valid_move(stock, maneuvre_stacks[i])); assert(!valid_move(stock, maneuvre_stacks[i]));
} }
@ -195,8 +195,8 @@ void test_valid_move_from_waste_pile_to_stock() {
allocate_stack(&waste_pile); allocate_stack(&waste_pile);
initialize_stack(stock); initialize_stack(stock);
initialize_stack(waste_pile); initialize_stack(waste_pile);
set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
set_card(waste_pile->card, KING, HEARTS, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile->card, KING, HEARTS, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
assert(!valid_move(waste_pile, stock)); assert(!valid_move(waste_pile, stock));
free_stack(stock); free_stack(stock);
free_stack(waste_pile); free_stack(waste_pile);
@ -209,8 +209,8 @@ void test_valid_move_from_waste_pile_to_waste_pile() {
allocate_stack(&waste_pile_1); allocate_stack(&waste_pile_1);
initialize_stack(waste_pile_0); initialize_stack(waste_pile_0);
initialize_stack(waste_pile_1); initialize_stack(waste_pile_1);
set_card(waste_pile_0->card, ACE, SPADES, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile_0->card, ACE, SPADES, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
set_card(waste_pile_1->card, KING, HEARTS, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile_1->card, KING, HEARTS, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
assert(!valid_move(waste_pile_0, waste_pile_0)); assert(!valid_move(waste_pile_0, waste_pile_0));
assert(!valid_move(waste_pile_0, waste_pile_1)); assert(!valid_move(waste_pile_0, waste_pile_1));
assert(!valid_move(waste_pile_1, waste_pile_0)); assert(!valid_move(waste_pile_1, waste_pile_0));
@ -224,15 +224,15 @@ void test_valid_move_from_waste_pile_to_foundation_stacks() {
allocate_stack(&waste_pile); allocate_stack(&waste_pile);
initialize_stack(waste_pile); initialize_stack(waste_pile);
set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
assert(valid_move(waste_pile, foundation_stacks[i])); assert(valid_move(waste_pile, foundation_stacks[i]));
} }
@ -247,18 +247,18 @@ void test_valid_move_from_waste_pile_to_maneuvre_stacks() {
allocate_stack(&waste_pile); allocate_stack(&waste_pile);
initialize_stack(waste_pile); initialize_stack(waste_pile);
set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
assert(valid_move(waste_pile, maneuvre_stacks[i])); assert(valid_move(waste_pile, maneuvre_stacks[i]));
} }
@ -273,15 +273,15 @@ void test_valid_move_from_foundation_stack_to_stock() {
allocate_stack(&stock); allocate_stack(&stock);
initialize_stack(stock); initialize_stack(stock);
set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
assert(!valid_move(foundation_stacks[i], stock)); assert(!valid_move(foundation_stacks[i], stock));
} }
@ -296,15 +296,15 @@ void test_valid_move_from_foundation_stack_to_waste_pile() {
allocate_stack(&waste_pile); allocate_stack(&waste_pile);
initialize_stack(waste_pile); initialize_stack(waste_pile);
set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
assert(!valid_move(foundation_stacks[i], waste_pile)); assert(!valid_move(foundation_stacks[i], waste_pile));
} }
@ -321,10 +321,10 @@ void test_valid_move_from_foundation_stack_to_foundation_stacks() {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
if (i == j) { if (i == j) {
@ -347,21 +347,21 @@ void test_valid_move_from_foundation_stack_to_maneuvre_stacks() {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 7; j++) { for (int j = 0; j < 7; j++) {
assert(valid_move(foundation_stacks[i], maneuvre_stacks[j])); assert(valid_move(foundation_stacks[i], maneuvre_stacks[j]));
@ -380,18 +380,18 @@ void test_valid_move_from_maneuvre_stack_to_stock() {
allocate_stack(&stock); allocate_stack(&stock);
initialize_stack(stock); initialize_stack(stock);
set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_STARTING_Y, STOCK_STARTING_X); set_card(stock->card, ACE, SPADES, EXPOSED, STOCK_BEGIN_Y, STOCK_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
assert(!valid_move(maneuvre_stacks[i], stock)); assert(!valid_move(maneuvre_stacks[i], stock));
} }
@ -406,18 +406,18 @@ void test_valid_move_from_maneuvre_stack_to_waste_pile() {
allocate_stack(&waste_pile); allocate_stack(&waste_pile);
initialize_stack(waste_pile); initialize_stack(waste_pile);
set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_STARTING_Y, WASTE_PILE_STARTING_X); set_card(waste_pile->card, ACE, SPADES, EXPOSED, WASTE_PILE_BEGIN_Y, WASTE_PILE_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
assert(!valid_move(maneuvre_stacks[i], waste_pile)); assert(!valid_move(maneuvre_stacks[i], waste_pile));
} }
@ -435,21 +435,21 @@ void test_valid_move_from_maneuvre_stack_to_foundation_stacks() {
allocate_stack(&foundation_stacks[i]); allocate_stack(&foundation_stacks[i]);
initialize_stack(foundation_stacks[i]); initialize_stack(foundation_stacks[i]);
} }
set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_0_STARTING_X); set_card(foundation_stacks[0]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_0_BEGIN_X);
set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_1_STARTING_X); set_card(foundation_stacks[1]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_1_BEGIN_X);
set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_2_STARTING_X); set_card(foundation_stacks[2]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_2_BEGIN_X);
set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_STARTING_Y, FOUNDATION_3_STARTING_X); set_card(foundation_stacks[3]->card, ACE, SPADES, EXPOSED, FOUNDATION_BEGIN_Y, FOUNDATION_3_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
assert(valid_move(maneuvre_stacks[i], foundation_stacks[j])); assert(valid_move(maneuvre_stacks[i], foundation_stacks[j]));
@ -470,13 +470,13 @@ void test_valid_move_from_maneuvre_stack_to_maneuvre_stacks() {
allocate_stack(&maneuvre_stacks[i]); allocate_stack(&maneuvre_stacks[i]);
initialize_stack(maneuvre_stacks[i]); initialize_stack(maneuvre_stacks[i]);
} }
set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_0_STARTING_X); set_card(maneuvre_stacks[0]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_0_BEGIN_X);
set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_1_STARTING_X); set_card(maneuvre_stacks[1]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_1_BEGIN_X);
set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_2_STARTING_X); set_card(maneuvre_stacks[2]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_2_BEGIN_X);
set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_3_STARTING_X); set_card(maneuvre_stacks[3]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_3_BEGIN_X);
set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_4_STARTING_X); set_card(maneuvre_stacks[4]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_4_BEGIN_X);
set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_5_STARTING_X); set_card(maneuvre_stacks[5]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_5_BEGIN_X);
set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_STARTING_Y, MANEUVRE_6_STARTING_X); set_card(maneuvre_stacks[6]->card, ACE, SPADES, EXPOSED, MANEUVRE_BEGIN_Y, MANEUVRE_6_BEGIN_X);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) { for (int j = 0; j < 7; j++) {
if (i == j) { if (i == j) {

View File

@ -17,13 +17,13 @@ void test_initialize_stack() {
void test_duplicate_stack() { void test_duplicate_stack() {
struct stack *stack_0, *stack_1; struct stack *stack_0, *stack_1;
struct card *card[5]; struct card *card[5];
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_stack(&stack_0); allocate_stack(&stack_0);
initialize_stack(stack_0); initialize_stack(stack_0);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
allocate_card(&card[i]); allocate_card(&card[i]);
set_card(card[i], i, SPADES, EXPOSED, start_y, start_x); set_card(card[i], i, SPADES, EXPOSED, begin_y, begin_x);
push(&stack_0, card[i]); push(&stack_0, card[i]);
} }
stack_1 = duplicate_stack(stack_0); stack_1 = duplicate_stack(stack_0);

View File

@ -2,8 +2,8 @@
bool frames_equal(struct frame *frame_0, struct frame *frame_1) { bool frames_equal(struct frame *frame_0, struct frame *frame_1) {
if (frame_0 && frame_1) { if (frame_0 && frame_1) {
return(frame_0->start_y == frame_1->start_y && return(frame_0->begin_y == frame_1->begin_y &&
frame_0->start_x == frame_1->start_x); frame_0->begin_x == frame_1->begin_x);
} else if ((frame_0 && !frame_1) || (!frame_0 && frame_1)) { } else if ((frame_0 && !frame_1) || (!frame_0 && frame_1)) {
return(false); return(false);
} else { } else {

View File

@ -15,12 +15,12 @@ void test_frames_equal_with_one_null() {
void test_frames_equal_with_two_equivalent_frames() { void test_frames_equal_with_two_equivalent_frames() {
struct frame *frame_0, *frame_1; struct frame *frame_0, *frame_1;
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_frame(&frame_0); allocate_frame(&frame_0);
allocate_frame(&frame_1); allocate_frame(&frame_1);
set_frame(frame_0, start_y, start_x); set_frame(frame_0, begin_y, begin_x);
set_frame(frame_1, start_y, start_x); set_frame(frame_1, begin_y, begin_x);
assert(frames_equal(frame_0, frame_1)); assert(frames_equal(frame_0, frame_1));
} }
@ -47,12 +47,12 @@ void test_cards_equal_with_one_null() {
void test_cards_equal_with_two_equivalent_cards() { void test_cards_equal_with_two_equivalent_cards() {
struct card *card_0, *card_1; struct card *card_0, *card_1;
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_card(&card_0); allocate_card(&card_0);
allocate_card(&card_1); allocate_card(&card_1);
set_card(card_0, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card_0, ACE, SPADES, EXPOSED, begin_y, begin_x);
set_card(card_1, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card_1, ACE, SPADES, EXPOSED, begin_y, begin_x);
assert(cards_equal(card_0, card_1)); assert(cards_equal(card_0, card_1));
} }
@ -80,12 +80,12 @@ void test_stacks_equal_with_one_null() {
void test_stacks_equal_with_two_equivalent_stacks() { void test_stacks_equal_with_two_equivalent_stacks() {
struct stack *stack_0, *stack_1; struct stack *stack_0, *stack_1;
struct card *card_0, *card_1; struct card *card_0, *card_1;
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_card(&card_0); allocate_card(&card_0);
allocate_card(&card_1); allocate_card(&card_1);
set_card(card_0, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card_0, ACE, SPADES, EXPOSED, begin_y, begin_x);
set_card(card_1, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card_1, ACE, SPADES, EXPOSED, begin_y, begin_x);
allocate_stack(&stack_0); allocate_stack(&stack_0);
allocate_stack(&stack_1); allocate_stack(&stack_1);
push(&stack_0, card_0); push(&stack_0, card_0);
@ -97,12 +97,12 @@ void test_stacks_equal_with_two_equivalent_stacks() {
void test_stacks_equal_with_two_different_stacks() { void test_stacks_equal_with_two_different_stacks() {
struct stack *stack_0, *stack_1; struct stack *stack_0, *stack_1;
struct card *card_0, *card_1; struct card *card_0, *card_1;
const int start_y = 5, start_x = 10; const int begin_y = 5, begin_x = 10;
allocate_card(&card_0); allocate_card(&card_0);
allocate_card(&card_1); allocate_card(&card_1);
set_card(card_0, ACE, SPADES, EXPOSED, start_y, start_x); set_card(card_0, ACE, SPADES, EXPOSED, begin_y, begin_x);
set_card(card_1, KING, HEARTS, EXPOSED, start_y, start_x); set_card(card_1, KING, HEARTS, EXPOSED, begin_y, begin_x);
allocate_stack(&stack_0); allocate_stack(&stack_0);
allocate_stack(&stack_1); allocate_stack(&stack_1);
push(&stack_0, card_0); push(&stack_0, card_0);