diff --git a/img.c b/img.c index 82530cd5a881323f7a4afd7fac95317c399a9457..2fcedd347f7bed1d49a0881457303ce43a0163e5 100644 --- a/img.c +++ b/img.c @@ -333,7 +333,7 @@ static bool handle_http_request(int sockfd, struct User* user_arr[]) } else if (method == POST){ - if(strstr(buff, "quit=Quit") != NULL) + if(strstr(buff, "quit=") != NULL) { simple_load_html("7_gameover.html",sockfd,buff,n,curr_user); @@ -341,7 +341,40 @@ static bool handle_http_request(int sockfd, struct User* user_arr[]) } else if(curr_user->isOnline == 0) { - + char* username = strstr(buff, "user=")+5; + char u[MAX_BUFF]; + strcpy(u,"<br>"); + strcat(u, username); + u[strlen(username)]='\0'; + curr_user->isOnline = 1; + + edit_load_html("2_start.html", sockfd,buff,username,curr_user); + } + + else if (curr_user->isOnline == 2 ||curr_user->isOnline == 1 ) { + curr_user->isOnline = 2; + if (the_other_user(curr_user, user_arr)->stage==0 || the_other_user(curr_user, user_arr)->stage == 4) + { + simple_load_html("5_discarded.html",sockfd,buff,n,curr_user); + } + else if (the_other_user(curr_user, user_arr)->stage==3){ + simple_load_html("7_gameover.html",sockfd,buff,n,curr_user); + curr_user->stage = 3; + } + else if (curr_user->stage == 2|| curr_user->stage == 4){ + simple_load_html("6_endgame.html",sockfd,buff,n,curr_user); + if (curr_user->stage == 4){ + curr_user->stage = 1; + curr_user->isOnline = 1; + } + else{ + curr_user->stage = 2; + } + } + + else { + + } } }