~ubuntu-branches/debian/sid/monopd/sid

« back to all changes in this revision

Viewing changes to .pc/01_gcc43_includes.patch/src/estategroup.cpp

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-02-28 15:39:47 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140228153947-1a5z05x3alj61wx1
Tags: 0.9.5-1
* Imported Upstream version 0.9.5.
  - Add support for IPv6 and systemd.
* Update watch file and point to the new upstream location
  at tuxfamily.org.
* Drop all patches. Merged upstream.
* debian/control:
  - Drop libcapsinetwork-dev from Build-Depends.
    Essential features of libcapsinetwork were merged into monopd and
    IPv6 support was added.
  - Add pkg-config to Build-Depends.
  - Add libsystemd-daemon-dev [linux-any] to Build-Depends.
  - Update homepage field and point to gtkatlantic.gradator.net.
* Add monopd.service and monopd.socket file and support systemd.
* Update monopd.6 man page.
* Use dh-systemd helper.
* Update debian/copyright. Add new BSD license.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
2
 
//
3
 
// This program is free software; you can redistribute it and/or
4
 
// modify it under the terms of the GNU General Public License
5
 
// version 2 as published by the Free Software Foundation.
6
 
//
7
 
// This program is distributed in the hope that it will be useful,
8
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10
 
// General Public License for more details.
11
 
//
12
 
// You should have received a copy of the GNU General Public License
13
 
// along with this program; see the file COPYING.  If not, write to
14
 
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15
 
// Boston, MA 02111-1307, USA.
16
 
 
17
 
#include <iostream>
18
 
 
19
 
#include <math++/nodes.h>
20
 
 
21
 
#include "estate.h"
22
 
#include "estategroup.h"
23
 
#include "game.h"
24
 
#include "io.h"
25
 
#include "player.h"
26
 
 
27
 
EstateGroup::EstateGroup(int id, Game *game, std::string name) : GameObject(id, GameObject::Unknown, game)
28
 
{
29
 
        setProperty("name", name, game);
30
 
        m_rentMath = m_rentVar = "";
31
 
        m_price = m_housePrice = 0;
32
 
}
33
 
 
34
 
void EstateGroup::setPrice(unsigned int price)
35
 
{
36
 
        if (m_price != price)
37
 
                m_price = price;
38
 
}
39
 
 
40
 
unsigned int EstateGroup::price()
41
 
{
42
 
        return m_price;
43
 
}
44
 
 
45
 
void EstateGroup::setHousePrice(unsigned int housePrice)
46
 
{
47
 
        if (m_housePrice != housePrice)
48
 
                m_housePrice = housePrice;
49
 
}
50
 
 
51
 
unsigned int EstateGroup::housePrice()
52
 
{
53
 
        return m_housePrice;
54
 
}
55
 
 
56
 
void EstateGroup::setRentMath(const std::string rentMath)
57
 
{
58
 
        if (m_rentMath != rentMath)
59
 
                m_rentMath = rentMath;
60
 
}
61
 
 
62
 
void EstateGroup::setRentVar(const std::string rentVar)
63
 
{
64
 
        if (m_rentVar != rentVar)
65
 
                m_rentVar = rentVar;
66
 
}
67
 
 
68
 
int EstateGroup::rent(Player *pLand, const std::string &rentMath)
69
 
{
70
 
        std::string mathStr = rentMath.size() ? rentMath : m_rentMath;
71
 
 
72
 
        if (mathStr.size())
73
 
        {
74
 
                Estate *estate = pLand->estate();
75
 
 
76
 
                stringReplace(mathStr, "${DICE}", std::string(itoa((m_game->dice[0] + m_game->dice[1]))));
77
 
                stringReplace(mathStr, "${GROUPOWNED}", std::string(itoa(estate->groupSize(estate->owner()))));
78
 
                stringReplace(mathStr, "${HOUSES}", std::string(itoa(estate->getIntProperty("houses"))));
79
 
 
80
 
                try {
81
 
                        std::string exprStr(mathStr);
82
 
                        std::auto_ptr<math::TNode<double> >expr(math::TReader<double>::parse(exprStr));
83
 
                        std::auto_ptr<math::TNode<double> >se(math::TSimplifier<double>::simplify(expr.get()));
84
 
                        return atoi(math::TPrinter<double>::print(se.get()).c_str());
85
 
                } catch (const math::EMath& e) {
86
 
                        return 0;
87
 
                } catch (...) {
88
 
                        return 0;
89
 
                }
90
 
        }
91
 
        return 0;
92
 
}