diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-02-09 03:35:20 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-02-09 04:25:35 -0500 |
| commit | 0d2d9dccdccfaa13b5977e8b8ab18445d157d2f6 (patch) | |
| tree | e7c64fa031f5cf769282d71c7c7f7a0bfae95a56 /sigencore/Player.cpp | |
| parent | 4357fd55cc601d9f185a163da5c546a27f2c47bf (diff) | |
| download | sigen-0d2d9dccdccfaa13b5977e8b8ab18445d157d2f6.tar.gz sigen-0d2d9dccdccfaa13b5977e8b8ab18445d157d2f6.tar.xz sigen-0d2d9dccdccfaa13b5977e8b8ab18445d157d2f6.zip | |
Fixed money handling in Player to allow for overrides
Diffstat (limited to 'sigencore/Player.cpp')
| -rw-r--r-- | sigencore/Player.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sigencore/Player.cpp b/sigencore/Player.cpp index f2b8460a..b289018a 100644 --- a/sigencore/Player.cpp +++ b/sigencore/Player.cpp @@ -62,9 +62,20 @@ void Sigencore::Player::giveMoney(const int amount) m_money = qMax(m_sigmod->rules()->maxMoney(), m_money + amount); } -void Sigencore::Player::takeMoney(const int amount) +bool Sigencore::Player::giveMoney(const int amount, const bool allOrNothing) { - m_money = qMin(0, m_money - amount); + int playerMin = 0; + int playerMax = m_sigmod->rules()->maxMoney(); + valueOfType("money-minimum", &playerMin); + valueOfType("money-maximum", &playerMax); + const int newUnbounded = m_money + amount; + const int newAmount = qMin(qMax(0, playerMin), qMax(playerMax, newAmount)); + if (allOrNothing || (newUnbounded == newAmount)) + { + m_money = newAmount; + emit(moneyChanged(m_money)); + } + return qAbs(newUnbounded - newAmount); } Sigencore::TeamMember* Sigencore::Player::findMember(const QUuid& id) const |
