added NeonFun Bot with UNO Game
[NeonServV5.git] / src / modules / NeonFun.mod / game_uno.h
diff --git a/src/modules/NeonFun.mod/game_uno.h b/src/modules/NeonFun.mod/game_uno.h
new file mode 100644 (file)
index 0000000..356fc00
--- /dev/null
@@ -0,0 +1,112 @@
+/* game_uno.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_uno_h
+#define _game_uno_h
+#include "../../timeq.h"
+
+#define UNO_STATE_WAITING 1
+#define UNO_STATE_RUNNING 2
+
+#define UNO_COLOR_BLACK  0
+#define UNO_COLOR_RED    1
+#define UNO_COLOR_BLUE   2
+#define UNO_COLOR_GREEN  3
+#define UNO_COLOR_YELLOW 4
+
+#define UNO_CARD_NUMBER_0  0
+#define UNO_CARD_NUMBER_1  1
+#define UNO_CARD_NUMBER_2  2
+#define UNO_CARD_NUMBER_3  3
+#define UNO_CARD_NUMBER_4  4
+#define UNO_CARD_NUMBER_5  5
+#define UNO_CARD_NUMBER_6  6
+#define UNO_CARD_NUMBER_7  7
+#define UNO_CARD_NUMBER_8  8
+#define UNO_CARD_NUMBER_9  9
+#define UNO_CARD_SKIP      10
+#define UNO_CARD_DIRECTION 11
+#define UNO_CARD_ADD_2     12
+#define UNO_CARD_ADD_4     13
+#define UNO_CARD_COLOR     14
+
+#define UNO_IS_NUMBER_CARD(ccard) (ccard->card <= 9)
+
+struct UserNode;
+struct ChanNode;
+struct ChanUser;
+struct ClientSocket;
+extern struct uno_game *uno_active_games;
+
+struct uno_card {
+    unsigned char color;
+    unsigned char card;
+    struct uno_card *prev, *next;
+};
+
+struct uno_card_deck {
+    struct uno_card *cards;
+    int count;
+};
+
+struct uno_player {
+    struct ChanUser *chanuser;
+    struct uno_card *cards;
+    int count;
+    int timeout;
+    struct uno_player *prev, *next;
+};
+
+struct uno_game {
+    struct ChanNode *channel;
+    struct ClientSocket *textbot;
+    int state : 3;
+    int reverse_direction : 1;
+    int take_cards_pending : 1;
+    struct uno_card_deck *deck;
+    struct uno_card *top_card;
+    struct uno_player *player;
+    struct uno_player *winner;
+    struct uno_player *active_player;
+    int players;
+    
+    struct timeq_entry *timer;
+    struct uno_game *next;
+};
+
+struct uno_card_deck *uno_shuffle_deck();
+struct uno_card *uno_get_card(struct uno_card_deck *deck);
+void uno_free_deck(struct uno_card_deck *deck);
+void uno_free_player(struct uno_player *player, struct uno_card_deck *deck);
+void uno_free_topcard(struct uno_card *card);
+void uno_free_game(struct uno_game *game);
+struct uno_player *uno_get_next_player(struct uno_game *game);
+void uno_show_player_cards(struct uno_game *game, struct uno_player *player);
+void uno_show_top_card(struct uno_game *game);
+
+TIMEQ_CALLBACK(uno_game_wait_timeout);
+TIMEQ_CALLBACK(uno_player_timeout);
+
+void uno_action_take_card(struct uno_game *game, struct uno_player *player);
+struct uno_card *uno_parse_card(struct uno_game *game, struct uno_player *player, char *arg1);
+int uno_check_card_valid(struct uno_game *game, struct uno_card *card);
+void uno_play_card(struct uno_game *game, struct uno_player *player, struct uno_card *card);
+
+void uno_event_part(struct ChanUser *chanuser);
+void uno_event_quit(struct UserNode *user);
+void uno_event_freechan(struct ChanNode *chan);
+
+#endif