1 /*
2  *  Copyright (C) 2011-2016  OpenDungeons Team
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 
18 #ifndef ROOMCASINO_H
19 #define ROOMCASINO_H
20 
21 #include "rooms/Room.h"
22 #include "rooms/RoomType.h"
23 
24 class Creature;
25 class Tile;
26 
27 class RoomCasinoGameCreatureInfo
28 {
29 public:
RoomCasinoGameCreatureInfo(Creature * creature,bool isReadyCreature)30     RoomCasinoGameCreatureInfo(Creature* creature, bool isReadyCreature) :
31         mCreature(nullptr),
32         mIsReady(false)
33     {}
34 
35     Creature* mCreature;
36     bool mIsReady;
37 };
38 
39 class RoomCasinoGame
40 {
41 public:
RoomCasinoGame()42     RoomCasinoGame() :
43         mCreature1(nullptr, false),
44         mCreature2(nullptr, false),
45         mCooldown(0)
46     {}
47 
48     RoomCasinoGameCreatureInfo mCreature1;
49     RoomCasinoGameCreatureInfo mCreature2;
50     uint32_t mCooldown;
51 };
52 
53 class RoomCasino: public Room
54 {
55 public:
56     RoomCasino(GameMap* gameMap);
57 
getType()58     RoomType getType() const override
59     { return mRoomType; }
60 
61     void doUpkeep() override;
62     bool hasOpenCreatureSpot(Creature* creature) override;
63     bool addCreatureUsingRoom(Creature* creature) override;
64     void removeCreatureUsingRoom(Creature* creature) override;
65     void absorbRoom(Room* room) override;
66     bool useRoom(Creature& creature, bool forced) override;
67 
68     static const RoomType mRoomType;
69 
70 protected:
71     BuildingObject* notifyActiveSpotCreated(ActiveSpotPlace place, Tile* tile) override;
72     void notifyActiveSpotRemoved(ActiveSpotPlace place, Tile* tile) override;
73 
74 private:
75     void setCreatureWinning(Creature& creature, const Ogre::Vector3& gamePosition);
76     void setCreatureLoosing(Creature& creature, const Ogre::Vector3& gamePosition);
77     std::map<Tile*,RoomCasinoGame> mCreaturesSpots;
78 };
79 
80 #endif // ROOMCASINO_H
81