diff --git a/main.c b/main.c index f1c5997..00514dc 100755 --- a/main.c +++ b/main.c @@ -93,6 +93,10 @@ int getNear(int dir){ return map[coord.x][coord.y].type; } +int getInventory(){ + return current_dude->inventory; +} + void spawnDudes(){ int i; t_dude new_dude; diff --git a/orange.c b/orange.c index 0660416..f3c37fd 100644 --- a/orange.c +++ b/orange.c @@ -7,7 +7,7 @@ typedef struct{ int plop; // custom info } t_data; -t_action orange_update(void* my_info, void* com_data, int success){ +t_action orange_update(void* my_info, t_com* communication_data, int success){ t_data* data = (t_data*)my_info; t_action action; diff --git a/purple.c b/purple.c index 7118807..be0f063 100644 --- a/purple.c +++ b/purple.c @@ -40,7 +40,7 @@ int dist(t_coord coord, int x, int y){ return abs(coord.x-x) + abs(coord.y-y); } -t_action purple_update(void* my_info, void* com_data, int success){ +t_action purple_update(void* my_info, t_com* com_data, int success){ t_data* data = (t_data*)my_info; t_action action; int i, type; diff --git a/team.h b/team.h index 3eb50eb..c182865 100644 --- a/team.h +++ b/team.h @@ -1,14 +1,35 @@ #ifndef TEAM_H #define TEAM_H -#define LIBRARY_SIZE 128 -#define DUDE_MEMORY 128 +#define WRITE 0 +#define READ 4 + +// coordinates structure +typedef struct{ + int x; + int y; +} t_coord; // Directions enum{ NORTH, SOUTH, EAST, WEST }; +// communication +#define LIBRARY_SIZE 128 +#define DUDE_MEMORY 128 +enum{ + BOOK_1, + BOOK_2, + BOOK_3, + BOOK_4 +}; + +typedef struct{ + int flag; + char data[32]; +} t_com; + // Tile types enum{ BEDROCK, GRASS, TREE, BERRIES, ROCK, IRON_ORE, // nature @@ -19,25 +40,21 @@ enum{ // Action types enum{ - MOVE, ATTACK, PICK, PUT, WORK, WAIT, COMMUNICATE + MOVE, + ATTACK, + PICK, + PUT, + WORK, + WAIT, + COMMUNICATE }; -typedef struct{ - int x; - int y; -} t_coord; - typedef struct{ int type; int dir; void* data; } t_action; -typedef struct{ - int dest; - void* message; -} t_communication; - int getInventory(); int getNear(int dir); diff --git a/tools.c b/tools.c index 6dea48e..654cbd9 100644 --- a/tools.c +++ b/tools.c @@ -6,6 +6,10 @@ typedef struct{ int ok; } t_move; +typedef struct{ + int dmg; +} t_attack; + t_move* clearMoves[MAX_DUDES*NB_TEAMS]; int nb_clear = 0; t_move* occupiedMoves[MAX_DUDES*NB_TEAMS];