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

« back to all changes in this revision

Viewing changes to .pc/01_gcc43_includes.patch/src/cardgroup.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 <algo.h>
18
 
 
19
 
#include "card.h"
20
 
#include "cardgroup.h"
21
 
#include "game.h"
22
 
 
23
 
CardGroup::CardGroup(int id, Game *game, std::string name) : GameObject(id, GameObject::Unknown, game)
24
 
{
25
 
        setProperty("name", name, game);
26
 
}
27
 
 
28
 
CardGroup::~CardGroup()
29
 
{
30
 
        while (!m_cards.empty()) { delete *m_cards.begin(); m_cards.erase(m_cards.begin()); }
31
 
}
32
 
 
33
 
Card *CardGroup::newCard(unsigned int id, const std::string name)
34
 
{
35
 
        Card *card = new Card(this, id);
36
 
        card->setProperty("name", name, m_game);
37
 
        m_cards.push_back(card);
38
 
        return card;
39
 
}
40
 
 
41
 
Card *CardGroup::nextCard()
42
 
{
43
 
        Card *card = 0;
44
 
 
45
 
        if (m_cards.size() > 0)
46
 
        {
47
 
                // Fetch first card
48
 
                card = m_cards[0];
49
 
 
50
 
                // Remove first card
51
 
                m_cards.erase(m_cards.begin());
52
 
        
53
 
                // Reinsert it at the back
54
 
                m_cards.push_back(card);
55
 
        }
56
 
 
57
 
        return card;
58
 
}
59
 
 
60
 
Card *CardGroup::findCard(unsigned int id)
61
 
{
62
 
        Card *card = 0;
63
 
        for (std::vector<Card *>::iterator it = m_cards.begin() ; it != m_cards.end() && (card = *it) ; ++it)
64
 
                if (card->id() == id)
65
 
                        return card;
66
 
        return 0;
67
 
}
68
 
 
69
 
void CardGroup::pushCard(Card *card)
70
 
{
71
 
        m_cards.push_back(card);
72
 
}
73
 
 
74
 
void CardGroup::popCard()
75
 
{
76
 
        m_cards.pop_back();
77
 
}
78
 
 
79
 
void CardGroup::shuffleCards()
80
 
{
81
 
        random_shuffle(m_cards.begin(), m_cards.end());
82
 
}