Skip to content

Commit

Permalink
Merge pull request #15 from UtkarshMe/issue_14
Browse files Browse the repository at this point in the history
  • Loading branch information
coditva authored Nov 22, 2017
2 parents 304fb12 + 2e37f16 commit baab60e
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 185 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set (PROJECT_SOURCES
src/main.c
src/interface.c
src/map.c
src/action.c
src/command.c
src/key.c
src/msg.c
src/game.c
Expand Down
27 changes: 18 additions & 9 deletions include/action.h → include/command.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* include/action.h
* Declare the interface to handle user input
* include/command.c
* Declare the interface for taking and executing commands
*
* Copyright (C) 2017 Utkarsh Mahshwari <[email protected]>
*
Expand All @@ -18,14 +18,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ACTION_H_D9AS6ZWN
#define ACTION_H_D9AS6ZWN
#ifndef COMMAND_H_0TNF49V3
#define COMMAND_H_0TNF49V3


/**
* Ask user for input and build the command
* @return The pointer to the command
*/
command_t * command_get();


/**
* Take a key as input and update the map checking if the move is valid or not
* @param The map to update
* @return The command entered by the user
* Execute the command on the given map
* @param The pointer to the map
* @patam The pointer to the command
*/
command_t action_make_move(const map_t *map);
void command_exec(const map_t *, const command_t *);


#endif /* end of include guard: ACTION_H_D9AS6ZWN */
#endif /* end of include guard: COMMAND_H_0TNF49V3 */
9 changes: 7 additions & 2 deletions include/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,16 @@ typedef struct {
typedef struct {
enum {
COMMAND_NOP,
COMMAND_MOTION,
COMMAND_HELP,
COMMAND_QUIT,
COMMAND_OTHER,
} type;
char value;
int count;
struct {
int count;
int value;
} motion;
int oper;
} command_t;


Expand Down
7 changes: 7 additions & 0 deletions include/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ void interface_display_status(game_status_t);
input_key_t interface_input_key();


/**
* Put the key back to the input queue
* @param The key to put back
*/
void interface_input_key_undo(input_key_t);


/**
* Keep taking input till the user presses enter
* @return The line terminated by '\0'
Expand Down
170 changes: 0 additions & 170 deletions src/action.c

This file was deleted.

Loading

0 comments on commit baab60e

Please sign in to comment.