rewrote IRC cache parser to be (hopefully) more stable
[NeonServV5.git] / src / modules / NeonFun.mod / game_4wins.h
1 /* game_4wins.h - NeonServ v5.4
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17 #ifndef _game_4wins_h
18 #define _game_4wins_h
19 #include "../../timeq.h"
20
21 #define FOURWINS_STATE_WAITING 1
22 #define FOURWINS_STATE_RUNNING 2
23
24 #define FOURWINS_MATRIX_WIDTH 7
25 #define FOURWINS_MATRIX_HEIGHT 6
26
27 #define FOURWINS_MAX_STONES (FOURWINS_MATRIX_WIDTH * FOURWINS_MATRIX_HEIGHT)
28
29 struct UserNode;
30 struct ChanNode;
31 struct ChanUser;
32 struct ClientSocket;
33 extern struct fourwins_game *fourwins_active_games;
34
35 struct fourwins_guest {
36     struct ChanUser *chanuser;
37     struct fourwins_guest *next;
38 };
39
40 struct fourwins_game {
41     struct ChanUser *player[2];
42     int active_player;
43     struct fourwins_guest *guests;
44     struct ClientSocket *textbot;
45     int state : 3;
46     struct {
47         unsigned int field:2; /* 0,1,2 */
48     } matrix[FOURWINS_MATRIX_WIDTH][FOURWINS_MATRIX_HEIGHT];
49     int total_stones;
50     struct timeq_entry *timer;
51     struct fourwins_game *next;
52 };
53
54 int fourwins_next_free_y(struct fourwins_game *game, int x);
55 int fourwins_check_win(struct fourwins_game *game, int x, int y);
56 void fourwins_show_matrix(struct fourwins_game *game);
57 TIMEQ_CALLBACK(fourwins_timeout);
58 void fourwins_free_game(struct fourwins_game *game);
59 void fourwins_event_part(struct ChanUser *chanuser);
60 void fourwins_event_freechan(struct ChanNode *chan);
61
62 #endif