1
// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
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.
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.
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.
20
#include "cardgroup.h"
23
CardGroup::CardGroup(int id, Game *game, std::string name) : GameObject(id, GameObject::Unknown, game)
25
setProperty("name", name, game);
28
CardGroup::~CardGroup()
30
while (!m_cards.empty()) { delete *m_cards.begin(); m_cards.erase(m_cards.begin()); }
33
Card *CardGroup::newCard(unsigned int id, const std::string name)
35
Card *card = new Card(this, id);
36
card->setProperty("name", name, m_game);
37
m_cards.push_back(card);
41
Card *CardGroup::nextCard()
45
if (m_cards.size() > 0)
51
m_cards.erase(m_cards.begin());
53
// Reinsert it at the back
54
m_cards.push_back(card);
60
Card *CardGroup::findCard(unsigned int id)
63
for (std::vector<Card *>::iterator it = m_cards.begin() ; it != m_cards.end() && (card = *it) ; ++it)
69
void CardGroup::pushCard(Card *card)
71
m_cards.push_back(card);
74
void CardGroup::popCard()
79
void CardGroup::shuffleCards()
81
random_shuffle(m_cards.begin(), m_cards.end());