Passing cards from the stock to the waste pile.
This commit is contained in:
parent
ee3daeb30a
commit
87909b5075
@ -100,3 +100,7 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool cursor_on_stock(struct cursor *cursor) {
|
||||
return((cursor->x == CURSOR_STARTING_X) && (cursor->y == CURSOR_STARTING_Y));
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef CURSOR_H
|
||||
#define CURSOR_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CURSOR_STARTING_X 4
|
||||
#define CURSOR_STARTING_Y 7
|
||||
|
||||
@ -17,5 +19,6 @@ void allocate_cursor(struct cursor **);
|
||||
void initialize_cursor(struct cursor *);
|
||||
void draw_cursor(struct cursor *);
|
||||
void move_cursor(struct cursor *, enum movement);
|
||||
bool cursor_on_stock(struct cursor *);
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <stdlib.h>
|
||||
#include <ncurses.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
11
lib/game.c
11
lib/game.c
@ -220,3 +220,14 @@ void end_game(struct deck *deck) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void handle_stock_event() {
|
||||
if (!empty(deck->stock)) {
|
||||
move_card(&(deck->stock), &(deck->waste_pile));
|
||||
expose_card(deck->waste_pile->card);
|
||||
draw_stack(deck->stock);
|
||||
draw_stack(deck->waste_pile);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -36,5 +36,6 @@ void greet_player();
|
||||
void initialize_game();
|
||||
void prepare_game(struct deck **);
|
||||
void end_game();
|
||||
void handle_stock_event();
|
||||
|
||||
#endif
|
||||
|
@ -46,6 +46,13 @@ int main(int argc, const char *argv[]) {
|
||||
case KEY_RIGHT:
|
||||
move_cursor(cursor, RIGHT);
|
||||
break;
|
||||
case KEY_SPACEBAR:
|
||||
if (cursor_on_stock(cursor)) {
|
||||
handle_stock_event();
|
||||
} else {
|
||||
/*handle_card_event();*/
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
end_curses();
|
||||
|
Loading…
Reference in New Issue
Block a user