Unmodularizing stupidity.

This commit is contained in:
Murilo Pereira 2011-06-07 00:27:43 -03:00
parent cba0615b24
commit 0780ab75fb
3 changed files with 13 additions and 17 deletions

View File

@ -33,19 +33,8 @@ static void unmark_cards(struct stack *stack) {
} }
} }
static void handle_stock_event() {
if (!stack_empty(deck->stock)) {
move_card(&(deck->stock), &(deck->waste_pile));
card_expose(deck->waste_pile->card);
erase_stack(deck->waste_pile);
draw_stack(deck->stock);
draw_stack(deck->waste_pile);
}
}
static void handle_card_movement(struct cursor *cursor) { static void handle_card_movement(struct cursor *cursor) {
struct stack **origin = cursor_stack(cursor); struct stack **origin = cursor_stack(cursor);
struct stack **destination;
int option; int option;
if (cursor_on_invalid_spot(cursor) || stack_empty(*origin)) { if (cursor_on_invalid_spot(cursor) || stack_empty(*origin)) {
@ -110,8 +99,9 @@ static void handle_card_movement(struct cursor *cursor) {
} }
} }
break; break;
case KEY_SPACEBAR: case KEY_SPACEBAR:;
destination = cursor_stack(cursor); /* http://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg259382.html */
struct stack **destination = cursor_stack(cursor);
int _marked_cards_count = marked_cards_count(*origin); int _marked_cards_count = marked_cards_count(*origin);
if (maneuvre_stack(*origin) && _marked_cards_count > 0) { if (maneuvre_stack(*origin) && _marked_cards_count > 0) {
erase_stack(*origin); erase_stack(*origin);
@ -172,7 +162,7 @@ static void handle_card_movement(struct cursor *cursor) {
} }
} }
void handle_keyboard_event(int key) { void keyboard_event(int key) {
switch (key) { switch (key) {
case 'h': case 'h':
case 'j': case 'j':
@ -188,7 +178,13 @@ void handle_keyboard_event(int key) {
break; break;
case KEY_SPACEBAR: case KEY_SPACEBAR:
if (cursor_on_stock(cursor)) { if (cursor_on_stock(cursor)) {
handle_stock_event(); if (!stack_empty(deck->stock)) {
move_card(&(deck->stock), &(deck->waste_pile));
card_expose(deck->waste_pile->card);
erase_stack(deck->waste_pile);
draw_stack(deck->stock);
draw_stack(deck->waste_pile);
}
} else { } else {
struct card *card; struct card *card;
if (cursor_stack(cursor) && if (cursor_stack(cursor) &&

View File

@ -10,6 +10,6 @@
extern struct deck *deck; extern struct deck *deck;
extern struct cursor *cursor; extern struct cursor *cursor;
void handle_keyboard_event(); void keyboard_event();
#endif #endif

View File

@ -57,7 +57,7 @@ int main(int argc, const char *argv[]) {
game_end(); game_end();
exit(0); exit(0);
} else { } else {
handle_keyboard_event(key); keyboard_event(key);
} }
} while (!game_won()); } while (!game_won());