1 /* game_uno.h - NeonServ v5.6
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
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.
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.
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/>.
19 #include "../../timeq.h"
21 #define UNO_STATE_WAITING 1
22 #define UNO_STATE_RUNNING 2
24 #define UNO_COLOR_BLACK 0
25 #define UNO_COLOR_RED 1
26 #define UNO_COLOR_BLUE 2
27 #define UNO_COLOR_GREEN 3
28 #define UNO_COLOR_YELLOW 4
30 #define UNO_CARD_NUMBER_0 0
31 #define UNO_CARD_NUMBER_1 1
32 #define UNO_CARD_NUMBER_2 2
33 #define UNO_CARD_NUMBER_3 3
34 #define UNO_CARD_NUMBER_4 4
35 #define UNO_CARD_NUMBER_5 5
36 #define UNO_CARD_NUMBER_6 6
37 #define UNO_CARD_NUMBER_7 7
38 #define UNO_CARD_NUMBER_8 8
39 #define UNO_CARD_NUMBER_9 9
40 #define UNO_CARD_SKIP 10
41 #define UNO_CARD_DIRECTION 11
42 #define UNO_CARD_ADD_2 12
43 #define UNO_CARD_ADD_4 13
44 #define UNO_CARD_COLOR 14
46 #define UNO_IS_NUMBER_CARD(ccard) (ccard->card <= 9)
52 extern struct uno_game *uno_active_games;
57 struct uno_card *prev, *next;
60 struct uno_card_deck {
61 struct uno_card *cards;
66 struct ChanUser *chanuser;
67 struct uno_card *cards;
70 struct uno_player *prev, *next;
74 struct ChanNode *channel;
75 struct ClientSocket *textbot;
77 int reverse_direction : 1;
78 int take_cards_pending : 1;
79 struct uno_card_deck *deck;
80 struct uno_card *top_card;
81 struct uno_player *player;
82 struct uno_player *winner;
83 struct uno_player *active_player;
86 struct timeq_entry *timer;
87 struct uno_game *next;
90 struct uno_card_deck *uno_shuffle_deck();
91 struct uno_card *uno_get_card(struct uno_card_deck *deck);
92 void uno_free_deck(struct uno_card_deck *deck);
93 void uno_free_player(struct uno_player *player, struct uno_card_deck *deck);
94 void uno_free_topcard(struct uno_card *card);
95 void uno_free_game(struct uno_game *game);
96 struct uno_player *uno_get_next_player(struct uno_game *game);
97 void uno_show_player_cards(struct uno_game *game, struct uno_player *player);
98 void uno_show_top_card(struct uno_game *game);
100 TIMEQ_CALLBACK(uno_game_wait_timeout);
101 TIMEQ_CALLBACK(uno_player_timeout);
103 void uno_action_take_card(struct uno_game *game, struct uno_player *player);
104 struct uno_card *uno_parse_card(struct uno_game *game, struct uno_player *player, char *arg1);
105 int uno_check_card_valid(struct uno_game *game, struct uno_card *card);
106 void uno_play_card(struct uno_game *game, struct uno_player *player, struct uno_card *card);
108 void uno_event_part(struct ChanUser *chanuser);
109 void uno_event_freechan(struct ChanNode *chan);