Update of /home/kde/kdegames/atlantik/libatlantic In directory office:/tmp/cvs-serv27006/libatlantic Modified Files: Tag: atlantik_3_3_branch Makefile.am atlantic_core.cpp atlantic_core.h Added Files: Tag: atlantik_3_3_branch game.cpp game.h Log Message: deprecate updategamelist for gameupdate --- NEW FILE: game.cpp --- // Copyright (c) 2003 Rob Kaper // // 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., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. #include #include "game.h" Game::Game(int gameId) : QObject() { m_id = gameId; m_description = QString::null; m_type = QString::null; m_players = 0; m_changed = false; } int Game::id() const { return m_id; } void Game::setCanBeJoined(const bool &canBeJoined) { if (m_canBeJoined != canBeJoined) { m_canBeJoined = canBeJoined; m_changed = true; } } bool Game::canBeJoined() const { return m_canBeJoined; } void Game::setDescription(const QString &description) { if (m_description != description) { m_description = description; m_changed = true; } } QString Game::description() const { return m_description; } void Game::setName(const QString &name) { if (m_name != name) { m_name = name; m_changed = true; } } QString Game::name() const { return m_name; } void Game::setType(const QString &type) { if (m_type != type) { m_type = type; m_changed = true; } } QString Game::type() const { return m_type; } void Game::update(bool force) { if (m_changed || force) { emit changed(this); m_changed = false; } } int Game::players() { return m_players; } void Game::setPlayers(int players) { if (m_players != players) { m_players = players; m_changed = true; } } #include "game.moc" --- NEW FILE: game.h --- // Copyright (c) 2003 Rob Kaper // // 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., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. #ifndef LIBATLANTIC_GAME_H #define LIBATLANTIC_GAME_H #include class QString; class Game : public QObject { Q_OBJECT public: Game(int gameId); int id() const; void setCanBeJoined(const bool &canBeJoined); bool canBeJoined() const; void setDescription(const QString &description); QString description() const; void setName(const QString &name); QString name() const; void setType(const QString &type); QString type() const; int players(); void setPlayers(int players); void update(bool force = false); signals: void changed(Game *game); private: bool m_changed; bool m_canBeJoined; QString m_description, m_name, m_type; int m_id, m_players; }; #endif Index: Makefile.am =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/Makefile.am,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -d -r1.11 -r1.11.2.1 --- Makefile.am 31 Dec 2002 11:50:10 -0000 1.11 +++ Makefile.am 15 Nov 2003 22:09:06 -0000 1.11.2.1 @@ -6,11 +6,10 @@ libatlantic_la_LIBADD = $(LIB_QT) libatlantic_la_SOURCES = atlantic_core.cpp auction.cpp estate.cpp \ - estategroup.cpp player.cpp trade.cpp + estategroup.cpp game.cpp player.cpp trade.cpp libatlanticincludedir = $(includedir)/atlantic libatlanticinclude_HEADERS = atlantic_core.h auction.h estate.h \ - estategroup.h player.h trade.h + estategroup.h game.h player.h trade.h -METASOURCES = AUTO - +METASOURCES = AUTO Index: atlantic_core.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/atlantic_core.cpp,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -d -r1.27 -r1.27.2.1 --- atlantic_core.cpp 5 Nov 2003 23:40:24 -0000 1.27 +++ atlantic_core.cpp 15 Nov 2003 22:09:06 -0000 1.27.2.1 @@ -16,20 +16,21 @@ #include -#include "atlantic_core.moc" +#include "atlantic_core.h" -#include "player.h" +#include "auction.h" #include "estate.h" #include "estategroup.h" +#include "game.h" +#include "player.h" #include "trade.h" -#include "auction.h" AtlanticCore::AtlanticCore(QObject *parent, const char *name) : QObject(parent, name) { m_playerSelf = 0; } -void AtlanticCore::reset(bool deletePlayers) +void AtlanticCore::reset(bool deletePermanents) { m_auctions.setAutoDelete(true); m_auctions.clear(); @@ -52,7 +53,7 @@ Player *player = 0; for (QPtrListIterator it(m_players); (player = *it) ; ++it) { - if (deletePlayers) + if (deletePermanents) { emit removeGUI(player); player->deleteLater(); @@ -63,10 +64,18 @@ player->setDestination(0); } } - if (deletePlayers) + if (deletePermanents) { m_players.clear(); m_playerSelf = 0; + + Game *game = 0; + for (QPtrListIterator it(m_games); (game = *it) ; ++it) + { + emit removeGUI(game); + game->deleteLater(); + } + m_games.clear(); } } @@ -85,10 +94,19 @@ return m_players; } -Player *AtlanticCore::newPlayer(int playerId) +Player *AtlanticCore::newPlayer(int playerId, const bool &playerSelf) { Player *player = new Player(playerId); m_players.append(player); + + if (playerSelf) + { + player->setIsSelf(playerSelf); + m_playerSelf = player; + } + + emit createGUI(player); + return player; } @@ -109,6 +127,47 @@ player->deleteLater(); } +QPtrList AtlanticCore::games() +{ + return m_games; +} + +Game *AtlanticCore::newGame(int gameId, const QString &type) +{ + Game *game = new Game(gameId); + m_games.append(game); + + if ( !type.isNull() ) + game->setType(type); + + emit createGUI(game); + + return game; +} + +Game *AtlanticCore::findGame(int gameId, const QString &type) +{ + Game *game = 0; + for (QPtrListIterator it(m_games); (game = *it) ; ++it) + if (game->id() == gameId && (type.isNull() || type == game->type()) ) + return game; + + return 0; +} + +void AtlanticCore::removeGame(Game *game) +{ + m_games.remove(game); + emit removeGUI(game); + game->deleteLater(); +} + +void AtlanticCore::emitGames() +{ + for (QPtrListIterator it(m_games); (*it) ; ++it) + emit createGUI( (*it) ); +} + QPtrList AtlanticCore::estates() { return m_estates; @@ -178,6 +237,9 @@ { Trade *trade = new Trade(tradeId); m_trades.append(trade); + + emit createGUI(trade); + return trade; } @@ -225,6 +287,10 @@ else std::cout << " P: " << player->name().latin1() << ", game " << QString::number(player->gameId()).latin1() << std::endl; + Game *game = 0; + for (QPtrListIterator it(m_games); (game = *it) ; ++it) + std::cout << " G: " << QString::number(game->id()).latin1() << std::endl; + Estate *estate = 0; for (QPtrListIterator it(m_estates); (estate = *it) ; ++it) std::cout << " E: " << estate->name().latin1() << std::endl; @@ -240,5 +306,6 @@ Trade *trade = 0; for (QPtrListIterator it(m_trades); (trade = *it) ; ++it) std::cout << "T: " << QString::number(trade->tradeId()).latin1() << std::endl; - } + +#include "atlantic_core.moc" Index: atlantic_core.h =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/atlantic_core.h,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -d -r1.22 -r1.22.2.1 --- atlantic_core.h 14 Jul 2003 08:03:07 -0000 1.22 +++ atlantic_core.h 15 Nov 2003 22:09:06 -0000 1.22.2.1 @@ -23,6 +23,7 @@ class Player; class Estate; class EstateGroup; +class Game; class Trade; class Auction; @@ -39,10 +40,16 @@ Player *playerSelf(); QPtrList players(); - Player *newPlayer(int playerId); + Player *newPlayer(int playerId, const bool &playerSelf = false); Player *findPlayer(int playerId); void removePlayer(Player *player); + QPtrList games(); + Game *newGame(int gameId, const QString &type = QString::null); + Game *findGame(int gameId, const QString &type = QString::null); + void removeGame(Game *game); + void emitGames(); + QPtrList estates(); Estate *newEstate(int estateId); Estate *findEstate(int estateId); @@ -64,14 +71,17 @@ void printDebug(); signals: + void createGUI(Player *player); void removeGUI(Player *player); - void deletePlayer(Player *player); + void createGUI(Game *game); + void removeGUI(Game *game); + void createGUI(Trade *trade); void removeGUI(Trade *trade); - void deleteTrade(Trade *trade); private: Player *m_playerSelf; QPtrList m_players; + QPtrList m_games; QPtrList m_estates; QPtrList m_estateGroups; QPtrList m_trades; _______________________________________________ atlantik-cvs mailing list atlantik-cvs@kde.org https://mail.kde.org/mailman/listinfo/atlantik-cvs