fixed 4wins game counter and prevent players playing against their selves...
authorpk910 <philipp@zoelle1.de>
Thu, 22 Mar 2012 19:29:54 +0000 (20:29 +0100)
committerpk910 <philipp@zoelle1.de>
Thu, 22 Mar 2012 19:30:27 +0000 (20:30 +0100)
src/modules/NeonFun.mod/cmd_neonfun.c
src/modules/NeonFun.mod/cmd_neonfun_4wins.c
src/modules/NeonFun.mod/game_uno.c

index 195749885344a5ee085a35ad02b2edc02860362e..031b7050c0b41959c862406805abff25dbf4aa76 100644 (file)
@@ -52,6 +52,7 @@ static const struct default_language_entry msgtab[] = {
     {"NF_UNO_NAME", "Name"},
     {"NF_UNO_WON_GAMES", "Won Games"},
     {"NF_UNO_TOTAL_WON_GAMES", "Total won Games"},
+    {"NF_UNO_LESS_PLAYERS", "There are not enough players to start the game."},
     
     {"NF_4WINS_NOT_YOUR_TURN", "Wait your turn!"},
     {"NF_4WINS_INVALID_COLUMN", "invalid column!"},
@@ -70,6 +71,7 @@ static const struct default_language_entry msgtab[] = {
     {"NF_4WINS_VIEWING_GAME", "You are now viewing the game."},
     {"NF_4WINS_GAME_CLOSED", "Game aborted."},
     {"NF_4WINS_TIMEOUT", "Game aborted (timeout)."},
+    {"NF_4WINS_SELF", "You may not play against yourself."},
     {NULL, NULL}
 };
 
index a282a144d836c2e65e5f9d386b3072d9eb6ba4aa..2aafcb69f464d01f7dac82c6dfc1c4b0d4133fcb 100644 (file)
@@ -36,6 +36,11 @@ CMD_BIND(neonfun_cmd_4wins) {
         timeq_del(game->timer);
         game->timer = NULL;
         game->state = FOURWINS_STATE_RUNNING;
+        if((game->player[0]->user->flags & USERFLAG_ISAUTHED) && (game->player[1]->user->flags & USERFLAG_ISAUTHED) && !stricmp(game->player[0]->user->auth, game->player[1]->user->auth)) {
+            fourwins_reply(game, "NF_4WINS_SELF");
+            fourwins_free_game(game);
+            return;
+        }
         fourwins_reply(game, "NF_4WINS_START", user->nick);
         if((game->player[0]->user->flags & USERFLAG_ISAUTHED)) {
             char *tmp;
@@ -74,6 +79,10 @@ CMD_BIND(neonfun_cmd_4wins) {
             reply(getTextBot(), user, "NS_USER_UNKNOWN", argv[0]);
             return;
         }
+        if(opp_user == user) {
+            reply(getTextBot(), user, "NF_4WINS_SELF");
+            return;
+        }
         struct ChanUser *opponent = getChanUser(opp_user, chan);
         if(!opponent) {
             reply(getTextBot(), user, "NF_4WINS_OPPONENT_NOT_IN_CHAN", opp_user->nick);
index 4f17aebe40ac4188844bab73883f51ce72d8f13d..1500c243b44fdb0e091b26571f8c957733cb642f 100644 (file)
@@ -276,7 +276,7 @@ TIMEQ_CALLBACK(uno_game_wait_timeout) {
     struct uno_game *game = data;
     game->timer = NULL;
     if(game->players == 1) {
-        //TEXT: too less users
+        uno_reply(game, NULL, "NF_UNO_LESS_PLAYERS");
         uno_free_game(game);
         return;
     }