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->suit,
card->face,
card->frame->start_y,
card->frame->start_x);
card->frame->begin_y,
card->frame->begin_x);
return(new_card);
}
@@ -47,9 +47,9 @@ void set_card(struct card *card,
enum value value,
enum suit suit,
enum face face,
int start_y,
int start_x) {
set_frame(card->frame, start_y, start_x);
int begin_y,
int begin_x) {
set_frame(card->frame, begin_y, begin_x);
card->value = value;
card->suit = suit;
card->face = face;

View File

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

View File

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

View File

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

View File

@@ -15,15 +15,15 @@ void allocate_frame(struct frame **frame) {
void initialize_frame(struct frame *frame) {
frame->shape = NULL;
frame->start_y = 0;
frame->start_x = 0;
frame->begin_y = 0;
frame->begin_x = 0;
}
struct frame *duplicate_frame(struct frame *frame) {
struct 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);
}
@@ -35,11 +35,11 @@ void free_frame(struct frame *frame) {
free(frame);
}
void set_frame(struct frame *frame, int start_y, int start_x) {
frame->start_y = start_y;
frame->start_x = start_x;
void set_frame(struct frame *frame, int begin_y, int begin_x) {
frame->begin_y = begin_y;
frame->begin_x = begin_x;
frame->shape = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
frame->start_y,
frame->start_x);
frame->begin_y,
frame->begin_x);
}

View File

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

View File

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

View File

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

View File

@@ -6,13 +6,13 @@
#include "keyboard.h"
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) {
struct stack *cursor_stack = NULL;
if (cursor->y == CURSOR_STARTING_Y) {
if (cursor->y == CURSOR_BEGIN_Y) {
switch (cursor->x) {
case CURSOR_STOCK_X: cursor_stack = deck->stock; 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_SUIT,
NO_FACE,
(*stack)->card->frame->start_y,
(*stack)->card->frame->start_x);
(*stack)->card->frame->begin_y,
(*stack)->card->frame->begin_x);
(*stack)->next = NULL;
} else {
*stack = (*stack)->next;