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) {
switch (card->face) {
case NO_FACE: printf("No face "); break;
case COVERED: printf("Covered "); break;
case EXPOSED: printf("Exposed "); break;
default : printf("? ");
case NO_FACE: printf("No face "); break;
case COVERED: printf("Covered "); break;
case EXPOSED: printf("Exposed "); break;
default : printf("? ");
}
switch (card->value) {
case NO_VALUE: printf(", no value "); break;
case TWO : printf("two "); break;
case THREE : printf("three "); break;
case FOUR : printf("four "); break;
case FIVE : printf("five "); break;
case SIX : printf("six "); break;
case SEVEN : printf("seven "); break;
case EIGHT : printf("eight "); break;
case NINE : printf("nine "); break;
case TEN : printf("ten "); break;
case JACK : printf("jack "); break;
case QUEEN : printf("queen "); break;
case KING : printf("king "); break;
case ACE : printf("ace "); break;
default : printf("? ");
case NO_VALUE: printf(", no value "); break;
case TWO : printf("two "); break;
case THREE : printf("three "); break;
case FOUR : printf("four "); break;
case FIVE : printf("five "); break;
case SIX : printf("six "); break;
case SEVEN : printf("seven "); break;
case EIGHT : printf("eight "); break;
case NINE : printf("nine "); break;
case TEN : printf("ten "); break;
case JACK : printf("jack "); break;
case QUEEN : printf("queen "); break;
case KING : printf("king "); break;
case ACE : printf("ace "); break;
default : printf("? ");
}
switch (card->suit) {
case NO_SUIT : printf(", no suit "); break;
case DIAMONDS: printf("of diamonds "); break;
case SPADES : printf("of spades "); break;
case HEARTS : printf("of hearts "); break;
case CLUBS : printf("of clubs "); break;
case NO_SUIT : printf(", no suit "); break;
case DIAMONDS: printf("of diamonds "); break;
case SPADES : printf("of spades "); break;
case HEARTS : printf("of hearts "); break;
case CLUBS : printf("of clubs "); break;
}
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) {
switch (movement) {
case LEFT:
if (cursor->x > CURSOR_STARTING_X) {
erase_cursor(cursor);
cursor->x = cursor->x - 8;
if (cursor->y > CURSOR_STARTING_Y) {
move_cursor(cursor, UP);
move_cursor(cursor, DOWN);
}
draw_cursor(cursor);
case LEFT:
if (cursor->x > CURSOR_STARTING_X) {
erase_cursor(cursor);
cursor->x = cursor->x - 8;
if (cursor->y > CURSOR_STARTING_Y) {
move_cursor(cursor, UP);
move_cursor(cursor, DOWN);
}
break;
case DOWN:
if (cursor->y == CURSOR_STARTING_Y) {
erase_cursor(cursor);
switch (cursor->x - 3) {
case MANEUVRE_0_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_0);
break;
case MANEUVRE_1_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_1);
break;
case MANEUVRE_2_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_2);
break;
case MANEUVRE_3_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_3);
break;
case MANEUVRE_4_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_4);
break;
case MANEUVRE_5_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_5);
break;
case MANEUVRE_6_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_6);
break;
}
draw_cursor(cursor);
draw_cursor(cursor);
}
break;
case DOWN:
if (cursor->y == CURSOR_STARTING_Y) {
erase_cursor(cursor);
switch (cursor->x - 3) {
case MANEUVRE_0_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_0);
break;
case MANEUVRE_1_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_1);
break;
case MANEUVRE_2_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_2);
break;
case MANEUVRE_3_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_3);
break;
case MANEUVRE_4_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_4);
break;
case MANEUVRE_5_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_5);
break;
case MANEUVRE_6_STARTING_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre_6);
break;
}
break;
case RIGHT:
if (cursor->x < 49) {
erase_cursor(cursor);
cursor->x = cursor->x + 8;
if (cursor->y > CURSOR_STARTING_Y) {
move_cursor(cursor, UP);
move_cursor(cursor, DOWN);
}
draw_cursor(cursor);
draw_cursor(cursor);
}
break;
case RIGHT:
if (cursor->x < 49) {
erase_cursor(cursor);
cursor->x = cursor->x + 8;
if (cursor->y > CURSOR_STARTING_Y) {
move_cursor(cursor, UP);
move_cursor(cursor, DOWN);
}
break;
case UP:
if (cursor->y > 1) {
erase_cursor(cursor);
cursor->y = CURSOR_STARTING_Y;
draw_cursor(cursor);
}
break;
draw_cursor(cursor);
}
break;
case UP:
if (cursor->y > 1) {
erase_cursor(cursor);
cursor->y = CURSOR_STARTING_Y;
draw_cursor(cursor);
}
break;
}
/* 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) {
case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break;
case SPADES: strcpy(card_suit, SPADES_SYMBOL); break;
case HEARTS: strcpy(card_suit, HEARTS_SYMBOL); break;
case CLUBS: strcpy(card_suit, CLUBS_SYMBOL); break;
default: strcpy(card_suit, "?");
case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break;
case SPADES: strcpy(card_suit, SPADES_SYMBOL); break;
case HEARTS: strcpy(card_suit, HEARTS_SYMBOL); break;
case CLUBS: strcpy(card_suit, CLUBS_SYMBOL); break;
default: strcpy(card_suit, "?");
}
return(card_suit);
@ -35,20 +35,20 @@ char *card_value(enum value value) {
}
switch(value) {
case TWO: card_value = "2"; break;
case THREE: card_value = "3"; break;
case FOUR: card_value = "4"; break;
case FIVE: card_value = "5"; break;
case SIX: card_value = "6"; break;
case SEVEN: card_value = "7"; break;
case EIGHT: card_value = "8"; break;
case NINE: card_value = "9"; break;
case TEN: card_value = "10"; break;
case JACK: card_value = "J"; break;
case QUEEN: card_value = "Q"; break;
case KING: card_value = "K"; break;
case ACE: card_value = "A"; break;
default: card_value = "?";
case TWO: card_value = "2"; break;
case THREE: card_value = "3"; break;
case FOUR: card_value = "4"; break;
case FIVE: card_value = "5"; break;
case SIX: card_value = "6"; break;
case SEVEN: card_value = "7"; break;
case EIGHT: card_value = "8"; break;
case NINE: card_value = "9"; break;
case TEN: card_value = "10"; break;
case JACK: card_value = "J"; break;
case QUEEN: card_value = "Q"; break;
case KING: card_value = "K"; break;
case ACE: card_value = "A"; break;
default: card_value = "?";
}
return(card_value);

View File

@ -10,22 +10,22 @@ struct stack *cursor_stack(struct cursor *cursor) {
if (cursor->y == CURSOR_STARTING_Y) {
switch (cursor->x) {
case CURSOR_STOCK_X: cursor_stack = deck->stock; 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_1_X: cursor_stack = deck->foundation_1; 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_STOCK_X: cursor_stack = deck->stock; 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_1_X: cursor_stack = deck->foundation_1; break;
case CURSOR_FOUNDATION_2_X: cursor_stack = deck->foundation_2; break;
case CURSOR_FOUNDATION_3_X: cursor_stack = deck->foundation_3; break;
}
} else {
switch (cursor->x) {
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_2_X: cursor_stack = deck->maneuvre_2; 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_5_X: cursor_stack = deck->maneuvre_5; break;
case CURSOR_MANEUVRE_6_X: cursor_stack = deck->maneuvre_6; 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_2_X: cursor_stack = deck->maneuvre_2; 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_5_X: cursor_stack = deck->maneuvre_5; 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) {
switch (option = getch()) {
case 'h':
case KEY_LEFT:
move_cursor(cursor, LEFT);
break;
case 'j':
case KEY_DOWN:
move_cursor(cursor, DOWN);
break;
case 'k':
case KEY_UP:
move_cursor(cursor, UP);
break;
case 'l':
case KEY_RIGHT:
move_cursor(cursor, RIGHT);
break;
case KEY_SPACEBAR:
if (!cursor_on_invalid_spot(cursor) &&
!cursor_on_stock(cursor) &&
!cursor_on_stack(cursor, origin)) {
destination = cursor_stack(cursor);
move_card(&origin, &destination);
draw_stack(origin);
draw_stack(destination);
}
return;
case 'h':
case KEY_LEFT:
move_cursor(cursor, LEFT);
break;
case 'j':
case KEY_DOWN:
move_cursor(cursor, DOWN);
break;
case 'k':
case KEY_UP:
move_cursor(cursor, UP);
break;
case 'l':
case KEY_RIGHT:
move_cursor(cursor, RIGHT);
break;
case KEY_SPACEBAR:
if (!cursor_on_invalid_spot(cursor) &&
!cursor_on_stock(cursor) &&
!cursor_on_stack(cursor, origin)) {
destination = cursor_stack(cursor);
move_card(&origin, &destination);
draw_stack(origin);
draw_stack(destination);
}
return;
}
}

View File

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