Debian Codegraph @

src/trade.h

raw
1 // Copyright © 2001-2003 Rob Kaper <[email protected]>,
2 // 2001 Erik Bourget <[email protected]>
3 // 2010-2015 Sylvain Rochet <[email protected]>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // version 2 as published by the Free Software Foundation.
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 GNU
12 // 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; see the file COPYING. If not, see
16 // <http://www.gnu.org/licenses/>.
17
18 #ifndef MONOP_TRADE_H
19 #define MONOP_TRADE_H
20
21 #include <map>
22 #include <string>
23 #include <vector>
24
25 #include "gameobject.h"
26
27 class GameObject;
28 class Player;
29 class TradeComponent;
30
31 enum Status { Setup, Active };
32
33 class Trade : public GameObject
34 {
35 public:
36 Trade(Player *pFrom, Player *pTo, int id);
37 virtual ~Trade();
38
39 void ioWrite(const char *fmt, ...);
40 void ioWrite(const std::string data);
41 void writeComponentMsg(TradeComponent *tc, Player *player = 0);
42
43 Player *firstFrom();
44 Player *firstTarget();
45 GameObject *takeFirstObject();
46 GameObject *findMoneyObject(Player *pFrom, Player *targetPlayer);
47 void updateObject(GameObject *gameObject, Player *pFrom, Player *targetPlayer);
48 void updateMoney(Player *from, Player *targetPlayer, unsigned int money);
49 void setPlayerAccept(Player *player, const bool acceptTrade);
50 void delComponent(const enum GameObject::Type, int id);
51
52 bool hasPlayer(Player *player);
53 bool allAccept();
54 int status;
55
56 private:
57 void addPlayer(Player *player);
58 void resetAcceptFlags();
59
60 void delComponent(TradeComponent *tc);
61
62 Player *m_actor;
63 std::vector<TradeComponent *> m_components;
64 std::vector<Player *> m_players;
65 std::map<Player *, bool> m_acceptMap;
66 };
67
68 #endif // MONOP_TRADE_H