Fixing indendation for 'switch'es.

This commit is contained in:
Murilo Pereira 2011-02-06 04:14:17 -02:00
parent 2a9d38116f
commit fc82c70b6a
5 changed files with 145 additions and 145 deletions

View File

@ -3,36 +3,36 @@
void print_card(struct card *card) { void print_card(struct card *card) {
switch (card->face) { switch (card->face) {
case NO_FACE: printf("No face "); break; case NO_FACE: printf("No face "); break;
case COVERED: printf("Covered "); break; case COVERED: printf("Covered "); break;
case EXPOSED: printf("Exposed "); break; case EXPOSED: printf("Exposed "); break;
default : printf("? "); default : printf("? ");
} }
switch (card->value) { switch (card->value) {
case NO_VALUE: printf(", no value "); break; case NO_VALUE: printf(", no value "); break;
case TWO : printf("two "); break; case TWO : printf("two "); break;
case THREE : printf("three "); break; case THREE : printf("three "); break;
case FOUR : printf("four "); break; case FOUR : printf("four "); break;
case FIVE : printf("five "); break; case FIVE : printf("five "); break;
case SIX : printf("six "); break; case SIX : printf("six "); break;
case SEVEN : printf("seven "); break; case SEVEN : printf("seven "); break;
case EIGHT : printf("eight "); break; case EIGHT : printf("eight "); break;
case NINE : printf("nine "); break; case NINE : printf("nine "); break;
case TEN : printf("ten "); break; case TEN : printf("ten "); break;
case JACK : printf("jack "); break; case JACK : printf("jack "); break;
case QUEEN : printf("queen "); break; case QUEEN : printf("queen "); break;
case KING : printf("king "); break; case KING : printf("king "); break;
case ACE : printf("ace "); break; case ACE : printf("ace "); break;
default : printf("? "); default : printf("? ");
} }
switch (card->suit) { switch (card->suit) {
case NO_SUIT : printf(", no suit "); break; case NO_SUIT : printf(", no suit "); break;
case DIAMONDS: printf("of diamonds "); break; case DIAMONDS: printf("of diamonds "); break;
case SPADES : printf("of spades "); break; case SPADES : printf("of spades "); break;
case HEARTS : printf("of hearts "); break; case HEARTS : printf("of hearts "); break;
case CLUBS : printf("of clubs "); break; case CLUBS : printf("of clubs "); break;
} }
printf("at y:%d x:%d, ", card->frame->start_y, card->frame->start_x); printf("at y:%d x:%d, ", card->frame->start_y, card->frame->start_x);

View File

@ -38,64 +38,64 @@ void erase_cursor(struct cursor *cursor) {
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_STARTING_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_STARTING_Y) {
move_cursor(cursor, UP); move_cursor(cursor, UP);
move_cursor(cursor, DOWN); move_cursor(cursor, DOWN);
}
draw_cursor(cursor);
} }
break; draw_cursor(cursor);
case DOWN: }
if (cursor->y == CURSOR_STARTING_Y) { break;
erase_cursor(cursor); case DOWN:
switch (cursor->x - 3) { if (cursor->y == CURSOR_STARTING_Y) {
case MANEUVRE_0_STARTING_X: erase_cursor(cursor);
cursor->y = cursor->y + 7 + length(deck->maneuvre_0); switch (cursor->x - 3) {
break; case MANEUVRE_0_STARTING_X:
case MANEUVRE_1_STARTING_X: cursor->y = cursor->y + 7 + length(deck->maneuvre_0);
cursor->y = cursor->y + 7 + length(deck->maneuvre_1); break;
break; case MANEUVRE_1_STARTING_X:
case MANEUVRE_2_STARTING_X: cursor->y = cursor->y + 7 + length(deck->maneuvre_1);
cursor->y = cursor->y + 7 + length(deck->maneuvre_2); break;
break; case MANEUVRE_2_STARTING_X:
case MANEUVRE_3_STARTING_X: cursor->y = cursor->y + 7 + length(deck->maneuvre_2);
cursor->y = cursor->y + 7 + length(deck->maneuvre_3); break;
break; case MANEUVRE_3_STARTING_X:
case MANEUVRE_4_STARTING_X: cursor->y = cursor->y + 7 + length(deck->maneuvre_3);
cursor->y = cursor->y + 7 + length(deck->maneuvre_4); break;
break; case MANEUVRE_4_STARTING_X:
case MANEUVRE_5_STARTING_X: cursor->y = cursor->y + 7 + length(deck->maneuvre_4);
cursor->y = cursor->y + 7 + length(deck->maneuvre_5); break;
break; case MANEUVRE_5_STARTING_X:
case MANEUVRE_6_STARTING_X: cursor->y = cursor->y + 7 + length(deck->maneuvre_5);
cursor->y = cursor->y + 7 + length(deck->maneuvre_6); break;
break; case MANEUVRE_6_STARTING_X:
} cursor->y = cursor->y + 7 + length(deck->maneuvre_6);
draw_cursor(cursor); break;
} }
break; draw_cursor(cursor);
case RIGHT: }
if (cursor->x < 49) { break;
erase_cursor(cursor); case RIGHT:
cursor->x = cursor->x + 8; if (cursor->x < 49) {
if (cursor->y > CURSOR_STARTING_Y) { erase_cursor(cursor);
move_cursor(cursor, UP); cursor->x = cursor->x + 8;
move_cursor(cursor, DOWN); if (cursor->y > CURSOR_STARTING_Y) {
} move_cursor(cursor, UP);
draw_cursor(cursor); move_cursor(cursor, DOWN);
} }
break; draw_cursor(cursor);
case UP: }
if (cursor->y > 1) { break;
erase_cursor(cursor); case UP:
cursor->y = CURSOR_STARTING_Y; if (cursor->y > 1) {
draw_cursor(cursor); erase_cursor(cursor);
} cursor->y = CURSOR_STARTING_Y;
break; draw_cursor(cursor);
}
break;
} }
/* this is needed because of the screen glitch that moving the cursor /* this is needed because of the screen glitch that moving the cursor

View File

@ -16,11 +16,11 @@ char *card_suit(enum suit suit) {
} }
switch(suit) { switch(suit) {
case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break; case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break;
case SPADES: strcpy(card_suit, SPADES_SYMBOL); break; case SPADES: strcpy(card_suit, SPADES_SYMBOL); break;
case HEARTS: strcpy(card_suit, HEARTS_SYMBOL); break; case HEARTS: strcpy(card_suit, HEARTS_SYMBOL); break;
case CLUBS: strcpy(card_suit, CLUBS_SYMBOL); break; case CLUBS: strcpy(card_suit, CLUBS_SYMBOL); break;
default: strcpy(card_suit, "?"); default: strcpy(card_suit, "?");
} }
return(card_suit); return(card_suit);
@ -35,20 +35,20 @@ char *card_value(enum value value) {
} }
switch(value) { switch(value) {
case TWO: card_value = "2"; break; case TWO: card_value = "2"; break;
case THREE: card_value = "3"; break; case THREE: card_value = "3"; break;
case FOUR: card_value = "4"; break; case FOUR: card_value = "4"; break;
case FIVE: card_value = "5"; break; case FIVE: card_value = "5"; break;
case SIX: card_value = "6"; break; case SIX: card_value = "6"; break;
case SEVEN: card_value = "7"; break; case SEVEN: card_value = "7"; break;
case EIGHT: card_value = "8"; break; case EIGHT: card_value = "8"; break;
case NINE: card_value = "9"; break; case NINE: card_value = "9"; break;
case TEN: card_value = "10"; break; case TEN: card_value = "10"; break;
case JACK: card_value = "J"; break; case JACK: card_value = "J"; break;
case QUEEN: card_value = "Q"; break; case QUEEN: card_value = "Q"; break;
case KING: card_value = "K"; break; case KING: card_value = "K"; break;
case ACE: card_value = "A"; break; case ACE: card_value = "A"; break;
default: card_value = "?"; default: card_value = "?";
} }
return(card_value); return(card_value);

View File

@ -10,22 +10,22 @@ struct stack *cursor_stack(struct cursor *cursor) {
if (cursor->y == CURSOR_STARTING_Y) { if (cursor->y == CURSOR_STARTING_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;
case CURSOR_FOUNDATION_0_X: cursor_stack = deck->foundation_0; break; case CURSOR_FOUNDATION_0_X: cursor_stack = deck->foundation_0; break;
case CURSOR_FOUNDATION_1_X: cursor_stack = deck->foundation_1; break; case CURSOR_FOUNDATION_1_X: cursor_stack = deck->foundation_1; break;
case CURSOR_FOUNDATION_2_X: cursor_stack = deck->foundation_2; break; case CURSOR_FOUNDATION_2_X: cursor_stack = deck->foundation_2; break;
case CURSOR_FOUNDATION_3_X: cursor_stack = deck->foundation_3; break; case CURSOR_FOUNDATION_3_X: cursor_stack = deck->foundation_3; break;
} }
} else { } else {
switch (cursor->x) { switch (cursor->x) {
case CURSOR_MANEUVRE_0_X: cursor_stack = deck->maneuvre_0; break; case CURSOR_MANEUVRE_0_X: cursor_stack = deck->maneuvre_0; break;
case CURSOR_MANEUVRE_1_X: cursor_stack = deck->maneuvre_1; break; case CURSOR_MANEUVRE_1_X: cursor_stack = deck->maneuvre_1; break;
case CURSOR_MANEUVRE_2_X: cursor_stack = deck->maneuvre_2; break; case CURSOR_MANEUVRE_2_X: cursor_stack = deck->maneuvre_2; break;
case CURSOR_MANEUVRE_3_X: cursor_stack = deck->maneuvre_3; break; case CURSOR_MANEUVRE_3_X: cursor_stack = deck->maneuvre_3; break;
case CURSOR_MANEUVRE_4_X: cursor_stack = deck->maneuvre_4; break; case CURSOR_MANEUVRE_4_X: cursor_stack = deck->maneuvre_4; break;
case CURSOR_MANEUVRE_5_X: cursor_stack = deck->maneuvre_5; break; case CURSOR_MANEUVRE_5_X: cursor_stack = deck->maneuvre_5; break;
case CURSOR_MANEUVRE_6_X: cursor_stack = deck->maneuvre_6; break; case CURSOR_MANEUVRE_6_X: cursor_stack = deck->maneuvre_6; break;
} }
} }
@ -71,32 +71,32 @@ void handle_card_movement(struct cursor *cursor) {
while (1) { while (1) {
switch (option = getch()) { switch (option = getch()) {
case 'h': case 'h':
case KEY_LEFT: case KEY_LEFT:
move_cursor(cursor, LEFT); move_cursor(cursor, LEFT);
break; break;
case 'j': case 'j':
case KEY_DOWN: case KEY_DOWN:
move_cursor(cursor, DOWN); move_cursor(cursor, DOWN);
break; break;
case 'k': case 'k':
case KEY_UP: case KEY_UP:
move_cursor(cursor, UP); move_cursor(cursor, UP);
break; break;
case 'l': case 'l':
case KEY_RIGHT: case KEY_RIGHT:
move_cursor(cursor, RIGHT); move_cursor(cursor, RIGHT);
break; break;
case KEY_SPACEBAR: case KEY_SPACEBAR:
if (!cursor_on_invalid_spot(cursor) && if (!cursor_on_invalid_spot(cursor) &&
!cursor_on_stock(cursor) && !cursor_on_stock(cursor) &&
!cursor_on_stack(cursor, origin)) { !cursor_on_stack(cursor, origin)) {
destination = cursor_stack(cursor); destination = cursor_stack(cursor);
move_card(&origin, &destination); move_card(&origin, &destination);
draw_stack(origin); draw_stack(origin);
draw_stack(destination); draw_stack(destination);
} }
return; return;
} }
} }

View File

@ -15,14 +15,14 @@ int main(int argc, const char *argv[]) {
while (key != KEY_SPACEBAR) { while (key != KEY_SPACEBAR) {
switch (key = getch()) { switch (key = getch()) {
case KEY_SPACEBAR: case KEY_SPACEBAR:
initialize_game(); initialize_game();
break; break;
case 'q': case 'q':
case 'Q': case 'Q':
end_game(); end_game();
end_curses(); end_curses();
exit(0); exit(0);
} }
} }