added 4wins game
[NeonServV5.git] / src / modules / NeonFun.mod / game_4wins.h
diff --git a/src/modules/NeonFun.mod/game_4wins.h b/src/modules/NeonFun.mod/game_4wins.h
new file mode 100644 (file)
index 0000000..7e404b6
--- /dev/null
@@ -0,0 +1,63 @@
+/* game_4wins.h - NeonServ v5.4
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. 
+ */
+#ifndef _game_4wins_h
+#define _game_4wins_h
+#include "../../timeq.h"
+
+#define FOURWINS_STATE_WAITING 1
+#define FOURWINS_STATE_RUNNING 2
+
+#define FOURWINS_MATRIX_WIDTH 7
+#define FOURWINS_MATRIX_HEIGHT 6
+
+#define FOURWINS_MAX_STONES (FOURWINS_MATRIX_WIDTH * FOURWINS_MATRIX_HEIGHT)
+
+struct UserNode;
+struct ChanNode;
+struct ChanUser;
+struct ClientSocket;
+extern struct fourwins_game *fourwins_active_games;
+
+struct fourwins_guest {
+    struct ChanUser *chanuser;
+    struct fourwins_guest *next;
+};
+
+struct fourwins_game {
+    struct ChanUser *player[2];
+    int active_player;
+    struct fourwins_guest *guests;
+    struct ClientSocket *textbot;
+    int state : 3;
+    struct {
+        unsigned int field:2; /* 0,1,2 */
+    } matrix[FOURWINS_MATRIX_WIDTH][FOURWINS_MATRIX_HEIGHT];
+    int total_stones;
+    struct timeq_entry *timer;
+    struct fourwins_game *next;
+};
+
+int fourwins_next_free_y(struct fourwins_game *game, int x);
+int fourwins_check_win(struct fourwins_game *game, int x, int y);
+void fourwins_show_matrix(struct fourwins_game *game);
+TIMEQ_CALLBACK(fourwins_timeout);
+void fourwins_free_game(struct fourwins_game *game);
+void fourwins_event_part(struct ChanUser *chanuser);
+void fourwins_event_quit(struct UserNode *user);
+void fourwins_event_freechan(struct ChanNode *chan);
+
+#endif