File indexing completed on 2025-02-16 03:47:38

0001 /*******************************************************************
0002  *
0003  * Copyright 2007  Aron Boström <c02ab@efd.lth.se>
0004  *
0005  * Bovo is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2, or (at your option)
0008  * any later version.
0009  *
0010  * Bovo is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with Bovo; see the file COPYING.  If not, write to
0017  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  *
0020  ********************************************************************/
0021 
0022 #ifndef BOVO_COMMON_H
0023 #define BOVO_COMMON_H
0024 
0025 /** @file file containing common system wide typedefs, enums and exceptions */
0026 
0027 /* Number of columns and rows (the same) */
0028 #define NUMCOLS 22
0029 
0030 /** namespace for game engine */
0031 namespace bovo
0032 {
0033 
0034 /* a very short positive natural number, such as a X or Y coordinate */
0035 using usi = unsigned short;
0036 
0037 /* a very long positive natural number, such as score for a certain square */
0038 using uli = unsigned long;
0039 
0040 /**
0041  * @brief Exception for a busy square
0042  * @description Exception thrown when you tries to set a player of a square
0043  * that is already occupied by a player ("X" or "O").
0044  *
0045  * @code
0046  * try {
0047  *     throw busy();
0048  * } catch (busy) {
0049  *     //<i> error handling code</i>
0050  * }
0051  * @endcode
0052  */
0053 struct busy {
0054 };
0055 
0056 /**
0057  * @brief Exception for a coordinate outside board
0058  * @description Exception thrown when a trying to refer to a coordinate
0059  * outside of playing board.
0060  *
0061  * @code
0062  * try {
0063  *     throw outOfBounds();
0064  * } catch (outOfBounds) {
0065  *     //<i> error handling code</i>
0066  * }
0067  * @endcode
0068  */
0069 struct outOfBounds {
0070 };
0071 
0072 /**
0073  * @brief Exception for Game Over
0074  * @description Exception thrown when a Game is already over.
0075  *
0076  * @code
0077  * try {
0078  *     throw gameover();
0079  * } catch (gameover) {
0080  *     //<i> error handling code</i>
0081  * }
0082  * @endcode
0083  */
0084 struct gameover {
0085 };
0086 
0087 /**
0088  * Exception thrown when a player isn't valid (neither "X", "O" nor "No")
0089  *
0090  * @code
0091  * try {
0092  *     throw notValidPlayer();
0093  * } catch (notValidPlayer) {
0094  *     //<i> error handling code</i>
0095  * }
0096  * @endcode
0097  */
0098 struct notValidPlayer {
0099 };
0100 
0101 /**
0102  * Enum for the player id
0103  */
0104 enum Player {
0105     X = 1, /**< Player 1 */
0106     O = 2, /**< Player 2 */
0107     No = 0 /**< No player (empty) */
0108 };
0109 
0110 /**
0111  * Enum for whether a game is in demo mode or playing mode
0112  */
0113 enum DemoMode {
0114     Demo = true, /**< Game is a demo */
0115     NotDemo = false /**< Game is not a demo */
0116 };
0117 
0118 } /* namespace bovo */
0119 
0120 #endif // BOVO_COMMON_H