blob: e944e970e66091efea17a4d7026fe4089bcf895c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; see the file COPYING.LIB. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
#include "player.h"
#include "player.moc"
#include "estate.h"
Player::Player(int playerId) : TQObject()
{
m_id = playerId;
m_game = 0;
m_name = "";
m_host = "";
m_image = "";
m_location = m_destination = 0;
m_money = 0;
m_changed = m_isSelf = false;
m_bankrupt = m_hasDebt = m_hasTurn = m_canRoll = m_canBuy = m_canAuction = m_canUseCard = m_inJail = false;
}
void Player::setGame(Game *game)
{
if (m_game != game)
{
m_game = game;
m_changed = true;
}
}
Game *Player::game()
{
return m_game;
}
void Player::setLocation(Estate *location)
{
if (m_location != location)
{
m_location = location;
m_changed = true;
}
}
void Player::setDestination(Estate *destination)
{
if (m_destination != destination)
{
m_destination = destination;
m_changed = true;
}
}
void Player::setBankrupt(bool bankrupt)
{
if (m_bankrupt != bankrupt)
{
m_bankrupt = bankrupt;
m_changed = true;
}
}
void Player::setHasDebt(bool hasDebt)
{
if (m_hasDebt != hasDebt)
{
m_hasDebt = hasDebt;
m_changed = true;
}
}
void Player::setHasTurn(const bool hasTurn)
{
if (m_hasTurn != hasTurn)
{
m_hasTurn = hasTurn;
m_changed = true;
if (m_hasTurn && m_isSelf)
emit gainedTurn();
}
}
void Player::setCanRoll(bool canRoll)
{
if (m_canRoll != canRoll)
{
m_canRoll = canRoll;
m_changed = true;
}
}
void Player::setCanBuy(bool canBuy)
{
if (m_canBuy != canBuy)
{
m_canBuy = canBuy;
m_changed = true;
}
}
void Player::setCanAuction(bool canAuction)
{
if (m_canAuction != canAuction)
{
m_canAuction = canAuction;
m_changed = true;
}
}
void Player::setCanUseCard(bool canUseCard)
{
if (m_canUseCard != canUseCard)
{
m_canUseCard = canUseCard;
m_changed = true;
}
}
void Player::setInJail(const bool inJail)
{
if (m_inJail != inJail)
{
m_inJail = inJail;
m_changed = true;
}
}
void Player::setName(const TQString _n)
{
if (m_name != _n)
{
m_name = _n;
m_changed = true;
}
}
void Player::setHost(const TQString &host)
{
if (m_host != host)
{
m_host = host;
m_changed = true;
}
}
void Player::setImage(const TQString &image)
{
if (m_image != image)
{
m_image = image;
m_changed = true;
}
}
void Player::setMoney(unsigned int money)
{
if (m_money != money)
{
m_money = money;
m_changed = true;
}
}
void Player::update(bool force)
{
if (m_changed || force)
{
emit changed(this);
m_changed = false;
}
}
|