Skip to content

Commit

Permalink
Fixed Bug
Browse files Browse the repository at this point in the history
+ Fixed print stats of all players
  • Loading branch information
restylianos committed Jun 11, 2020
1 parent 98475bf commit 116a206
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
Binary file added game.bin
Binary file not shown.
Binary file added server.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions src/game_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ void to_print(map_t *map, player_t *player, monster_t monsters[], chest_t chests
print_map(map, monsters);
get_stats(player, monsters, map);
}
void to_print_multi(map_t *map, player_t players[], monster_t monsters[], chest_t chests[])
void to_print_multi(map_t *map, player_t players[], monster_t monsters[], chest_t chests[], int my_id)
{
print_map(map, monsters);
get_stats(players, monsters, map);
get_stats_multi(players, monsters, map, my_id);
}
/**
* Modifies the initial values of player stats giving him a buff of 50 points
Expand Down
2 changes: 1 addition & 1 deletion src/game_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
void add_stats(player_t *player);
char key_input(char *key);
void to_print(map_t *map, player_t *player, monster_t monsters[], chest_t chests[]);
void to_print_multi(map_t *map,player_t players[],monster_t monsters[], chest_t chests[]);
void to_print_multi(map_t *map,player_t players[],monster_t monsters[], chest_t chests[],int my_id);
int load_game(account_t *account, map_t *map, player_t *player, int mons_buffer[MAX_MONSTERS][MONS_ELMNTS], int chest_buffer[MAX_CHESTS]);
int save_game(map_t *map, account_t *account, player_t *player, monster_t mons_arr[], chest_t chest_arr[]);
void memset_arrays(int mons_buffer[][MONS_ELMNTS], int chest_buffer[MAX_CHESTS]);
Expand Down
4 changes: 2 additions & 2 deletions src/mode_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void *multi_game_handler(void *args)
sleep(2);
system("clear");
player_check_max_stats(&game->players[game->client->uid]);
to_print(&game->map, game->players, game->mons_arr, game->chest_arr);
to_print_multi(&game->map, game->players, game->mons_arr, game->chest_arr,game->client->uid);
update_objects(&game->map, game->mons_arr, game->chest_arr);
usleep(10000);
fflush(stderr);
Expand All @@ -378,7 +378,7 @@ void *multi_game_handler(void *args)
game->players[game->client->uid].x = 18;
game->players[game->client->uid].y = 48;
}
to_print_multi(&game->map, game->players, game->mons_arr, game->chest_arr);
to_print_multi(&game->map, game->players, game->mons_arr, game->chest_arr,game->client->uid);

return NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion src/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ void get_stats(player_t *player, monster_t monsters[], map_t *map)
printf("]\n");
printf("Save and exit by pressing #\n");
}
void get_stats_multi(player_t players[], monster_t monsters[], map_t *map)
void get_stats_multi(player_t players[], monster_t monsters[], map_t *map, int my_id)
{
int i;
for (i = 0; i < 3; i++)
{
if(my_id == i) printf("\033[1;37mMe: \033[0m ");
printf("\033[1;33m"); //Set the text to the color red
printf("HP: %d ", players[i].health);
printf("\033[0m");
Expand Down
2 changes: 1 addition & 1 deletion src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void object_found(map_t *map, player_t *player, char key_press, monster_t mons_a
int *check_obj(map_t *map, player_t *player, int obj_array[2]);
void player_die(player_t *player);
void get_stats(player_t *player, monster_t monsters[], map_t *map);
void get_stats_multi(player_t players[], monster_t monster[], map_t *map);
void get_stats_multi(player_t players[], monster_t monster[], map_t *map, int my_id);
int attack(float accuracy, float damage, float armor);
void open_chest(chest_t chest, player_t *player);
int check_level_up(monster_t mons_arr[], map_t *map);
Expand Down

0 comments on commit 116a206

Please sign in to comment.