1 // Brain Party 2 // Copyright (C) 2010 Paul Hudson (http://www.tuxradar.com/brainparty) 3 4 // Brain Party is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 3 7 // of the License, or (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, write to the Free Software 16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 18 #ifndef __DICEOFF_H__ 19 #define __DICEOFF_H__ 20 21 #include "Minigame.h" 22 23 enum Ownership { OWNER_NONE, OWNER_PLAYER, OWNER_AI }; 24 25 class BPMiniGame_DiceOff_Die { 26 public: 27 int Value; 28 int NumNeighbours; 29 30 Ownership Owner; 31 BPPoint Pos; 32 33 int Index; 34 int X; 35 int Y; 36 37 Colour Col; 38 int LastStateChange; 39 BPMiniGame_DiceOff_Die()40 BPMiniGame_DiceOff_Die() { 41 Owner = OWNER_NONE; 42 LastStateChange = -5000; 43 } 44 }; 45 46 47 48 class BPMiniGame_DiceOff : public BPMiniGame { 49 static const int NumRows = 8; 50 static const int NumCols = 6; 51 static const int DiceSize = 50; 52 static const int ChainSpeed = 150; 53 static const int ChangeSpeed = 300; 54 static const int AIThinkSpeed = 500; 55 56 bool OurTurn; 57 bool FirstAITurn; // used to stop the AI from choosing edge squares in its first turn, as this can be fatal if they player started next to them! 58 59 Colour NeutralColor; 60 Colour PlayerColor; 61 Colour AIColor; 62 63 BPPList<Texture*> DicePics; 64 65 BPPList<BPMiniGame_DiceOff_Die*> Dice; 66 BPList<BPMiniGame_DiceOff_Die*> AIClosedList; // this must be a BPList otherwise we delete dice in the Dice list! 67 BPList<BPMiniGame_DiceOff_Die*> CheckChangeList; // this must be a BPList otherwise we delete dice in the Dice list! 68 69 bool PlaySound; 70 71 int ChangeStartTime; // allows us to kill changes if they enter a loop 72 int LastStateChange; 73 MiniGameStates State; 74 75 public: 76 BPMiniGame_DiceOff(BPGame* game); 77 ~BPMiniGame_DiceOff(); 78 79 void Start(); 80 int GetWeight(); 81 void Tick(); 82 void Render(); 83 84 void OnMouseDown(); 85 void OnMouseUp(); 86 void OnMouseMove(); 87 88 int CountNeighbours(int x, int y); 89 void BumpDie(BPMiniGame_DiceOff_Die* die, Ownership newowner); 90 void AITurn(); 91 void AICheck(BPMiniGame_DiceOff_Die* die); 92 void SetGameState(MiniGameStates state); 93 void UpdateScore(); 94 }; 95 96 #endif 97