[Tux4kids-commits] r1199 - tuxmath/branches/lan/server
akash gangil
gangil-guest at alioth.debian.org
Tue Jul 14 07:59:51 UTC 2009
Author: gangil-guest
Date: 2009-07-14 07:59:49 +0000 (Tue, 14 Jul 2009)
New Revision: 1199
Modified:
tuxmath/branches/lan/server/server.c
tuxmath/branches/lan/server/server.h
Log:
Wrong Answers considered
Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c 2009-07-14 03:32:02 UTC (rev 1198)
+++ tuxmath/branches/lan/server/server.c 2009-07-14 07:59:49 UTC (rev 1199)
@@ -45,6 +45,7 @@
void remove_client(int i);
int msg_set_name(int i, char* buf);
void game_msg_correct_answer(int i, int id);
+void game_msg_wrong_answer(int i, int id);
void game_msg_quit(int i);
void game_msg_exit(int i);
void start_game(int i);
@@ -54,7 +55,6 @@
void broadcast_msg(char* msg);
void throttle(int loop_msec);
void game_msg_next_question(void);
-//void game_msg_total_questions_left(int i);
int no_questions_left(void);
int mission_accomplished(void);
@@ -494,9 +494,38 @@
if(strncmp(command, "CORRECT_ANSWER", strlen("CORRECT_ANSWER")) == 0)
{
game_msg_correct_answer(i,id);
+ if(!MC_TotalQuestionsLeft())
+ {
+ if(!no_questions_left())
+ printf(" no_questions_left() failed..\n");
+ }
+ if (MC_MissionAccomplished())
+ {
+ if(!mission_accomplished())
+ printf(" mission_accomplished() failed..\n");
+ }
+
game_msg_next_question();
}
+ else if(strncmp(command, "WRONG_ANSWER",strlen("WRONG_ANSWER")) == 0) /* Player answered the question incorrectly , meaning comet crashed into a city or an igloo */
+ {
+ game_msg_wrong_answer(i,id);
+ if(!MC_TotalQuestionsLeft())
+ {
+ if(!no_questions_left())
+ printf(" no_questions_left() failed..\n");
+ }
+ if (MC_MissionAccomplished())
+ {
+ if(!mission_accomplished())
+ printf(" mission_accomplished() failed..\n");
+ }
+
+ game_msg_next_question();
+
+ }
+
else if(strncmp(command, "NEXT_QUESTION",strlen("NEXT_QUESTION")) == 0) /* Send Next Question */
{
game_msg_next_question();
@@ -520,9 +549,26 @@
}
+
+void game_msg_wrong_answer(int i, int id)
+{
+ int n;
+ char buf[NET_BUF_LEN];
+ //Announcement for server and all clients:
+ snprintf(buf, NET_BUF_LEN,
+ "question id %d was answered incorrectly by %s\n",
+ id, client[i].name);
+ printf("%s", buf);
+ broadcast_msg(buf);
/* Functions for all the messages we can receive from the client: */
+ //Tell mathcards so lists get updated:
+ MC_NotAnsweredCorrectly_id(id);
+
+
+}
+
int msg_set_name(int i, char* buf)
{
char* p;
@@ -539,10 +585,6 @@
return 0;
}
-
-
-
-
void game_msg_correct_answer(int i, int id)
{
int n;
Modified: tuxmath/branches/lan/server/server.h
===================================================================
--- tuxmath/branches/lan/server/server.h 2009-07-14 03:32:02 UTC (rev 1198)
+++ tuxmath/branches/lan/server/server.h 2009-07-14 07:59:49 UTC (rev 1199)
@@ -33,8 +33,7 @@
CORRECT_ANSWER,
NOT_ANSWERED_CORRECTLY,
NEXT_QUESTION,
- TOTAL_QUESTIONS_LEFT,
- MISSION_ACCOMPLISHED,
+ TOTAL_QUESTIONS_LEFT
};
More information about the Tux4kids-commits
mailing list