From atlantik-devel Tue Jan 20 06:51:32 2004 From: kde () office ! kde ! org Date: Tue, 20 Jan 2004 06:51:32 +0000 To: atlantik-devel Subject: [atlantik-cvs] CVS: kdegames/atlantik/libatlantic configoption.cpp, Message-Id: <20040120065132.DF75226C8 () office ! kde ! org> X-MARC-Message: https://marc.info/?l=atlantik-devel&m=107458154104348 Update of /home/kde/kdegames/atlantik/libatlantic In directory office:/tmp/cvs-serv26057/libatlantic Modified Files: Makefile.am atlantic_core.cpp atlantic_core.h estate.cpp estate.h player.cpp player.h Added Files: configoption.cpp configoption.h game.cpp game.h Log Message: Merge atlantik_3_3_branch into HEAD. Index: Makefile.am =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Makefile.am 31 Dec 2002 11:50:10 -0000 1.11 +++ Makefile.am 20 Jan 2004 06:51:30 -0000 1.12 @@ -5,12 +5,11 @@ libatlantic_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined -version-info 3:0:2 libatlantic_la_LIBADD = $(LIB_QT) -libatlantic_la_SOURCES = atlantic_core.cpp auction.cpp estate.cpp \ - estategroup.cpp player.cpp trade.cpp +libatlantic_la_SOURCES = atlantic_core.cpp auction.cpp configoption.cpp estate.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 +libatlanticinclude_HEADERS = atlantic_core.h auction.h configoption.h estate.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.28 diff -u -d -r1.27 -r1.28 --- atlantic_core.cpp 5 Nov 2003 23:40:24 -0000 1.27 +++ atlantic_core.cpp 20 Jan 2004 06:51:30 -0000 1.28 @@ -16,20 +16,22 @@ #include -#include "atlantic_core.moc" +#include "atlantic_core.h" -#include "player.h" +#include "auction.h" +#include "configoption.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(); @@ -40,6 +42,9 @@ m_estateGroups.setAutoDelete(true); m_estateGroups.clear(); m_estateGroups.setAutoDelete(false); + m_configOptions.setAutoDelete(true); + m_configOptions.clear(); + m_configOptions.setAutoDelete(false); Trade *trade = 0; for (QPtrListIterator it(m_trades); (trade = *it) ; ++it) @@ -52,7 +57,7 @@ Player *player = 0; for (QPtrListIterator it(m_players); (player = *it) ; ++it) { - if (deletePlayers) + if (deletePermanents) { emit removeGUI(player); player->deleteLater(); @@ -63,13 +68,26 @@ 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(); } } +bool AtlanticCore::selfIsMaster() const +{ + return (m_playerSelf && m_playerSelf->game() && m_playerSelf->game()->master() == m_playerSelf); +} + void AtlanticCore::setPlayerSelf(Player *player) { m_playerSelf = player; @@ -85,10 +103,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 +136,65 @@ 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(const QString &type) +{ + Game *game = 0; + for (QPtrListIterator it(m_games); (game = *it) ; ++it) + if (game->id() == -1 && game->type() == type) + return game; + + return 0; +} + +Game *AtlanticCore::findGame(int gameId) +{ + if (gameId == -1) + return 0; + + Game *game = 0; + for (QPtrListIterator it(m_games); (game = *it) ; ++it) + if (game->id() == gameId) + return game; + + return 0; +} + +Game *AtlanticCore::gameSelf() +{ + return( m_playerSelf ? m_playerSelf->game() : 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 +264,9 @@ { Trade *trade = new Trade(tradeId); m_trades.append(trade); + + emit createGUI(trade); + return trade; } @@ -216,14 +305,45 @@ delete auction; } +ConfigOption *AtlanticCore::newConfigOption(int configId) +{ + ConfigOption *configOption = new ConfigOption(configId); + m_configOptions.append(configOption); + + emit createGUI(configOption); + + return configOption; +} + +void AtlanticCore::removeConfigOption(ConfigOption *configOption) +{ + m_configOptions.remove(configOption); + emit removeGUI(configOption); + configOption->deleteLater(); +} + +ConfigOption *AtlanticCore::findConfigOption(int configId) +{ + ConfigOption *configOption = 0; + for (QPtrListIterator it(m_configOptions); (configOption = *it) ; ++it) + if (configOption->id() == configId) + return configOption; + + return 0; +} + void AtlanticCore::printDebug() { Player *player = 0; for (QPtrListIterator it(m_players); (player = *it) ; ++it) if (player == m_playerSelf) - std::cout << "PS: " << player->name().latin1() << ", game " << QString::number(player->gameId()).latin1() << std::endl; + std::cout << "PS: " << player->name().latin1() << ", game " << QString::number(player->game() ? player->game()->id() : -1).latin1() << std::endl; else - std::cout << " P: " << player->name().latin1() << ", game " << QString::number(player->gameId()).latin1() << std::endl; + std::cout << " P: " << player->name().latin1() << ", game " << QString::number(player->game() ? player->game()->id() : -1).latin1() << std::endl; + + Game *game = 0; + for (QPtrListIterator it(m_games); (game = *it) ; ++it) + std::cout << " G: " << QString::number(game->id()).latin1() << ", master: " << QString::number(game->master() ? game->master()->id() : -1 ).latin1() << std::endl; Estate *estate = 0; for (QPtrListIterator it(m_estates); (estate = *it) ; ++it) @@ -235,10 +355,15 @@ Auction *auction = 0; for (QPtrListIterator it(m_auctions); (auction = *it) ; ++it) - std::cout << "A: " << QString::number(auction->auctionId()).latin1() << std::endl; + std::cout << " A: " << QString::number(auction->auctionId()).latin1() << std::endl; Trade *trade = 0; for (QPtrListIterator it(m_trades); (trade = *it) ; ++it) - std::cout << "T: " << QString::number(trade->tradeId()).latin1() << std::endl; + std::cout << " T: " << QString::number(trade->tradeId()).latin1() << std::endl; + ConfigOption *configOption = 0; + for (QPtrListIterator it(m_configOptions); (configOption = *it) ; ++it) + std::cout << "CO:" << QString::number(configOption->id()).latin1() << " " << configOption->name().latin1() << " " << configOption->value().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.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- atlantic_core.h 5 Dec 2003 21:02:38 -0000 1.23 +++ atlantic_core.h 20 Jan 2004 06:51:30 -0000 1.24 @@ -21,8 +21,10 @@ #include class Player; +class ConfigOption; class Estate; class EstateGroup; +class Game; class Trade; class Auction; @@ -35,14 +37,24 @@ void reset(bool deletePermanents = false); + bool selfIsMaster() const; + void setPlayerSelf(Player *player); 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(const QString &type); // finds game types + Game *findGame(int gameId); // finds actual games + Game *gameSelf(); + void removeGame(Game *game); + void emitGames(); + QPtrList estates(); Estate *newEstate(int estateId); Estate *findEstate(int estateId); @@ -61,21 +73,31 @@ Auction *newAuction(int auctionId, Estate *estate); void delAuction(Auction *auction); + ConfigOption *newConfigOption(int configId); + void removeConfigOption(ConfigOption *configOption); + ConfigOption *findConfigOption(int configId); + 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); + void createGUI(ConfigOption *configOption); + void removeGUI(ConfigOption *configOption); private: Player *m_playerSelf; QPtrList m_players; + QPtrList m_games; QPtrList m_estates; QPtrList m_estateGroups; QPtrList m_trades; QPtrList m_auctions; + QPtrList m_configOptions; }; #endif Index: estate.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/estate.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- estate.cpp 13 Jul 2003 21:27:43 -0000 1.10 +++ estate.cpp 20 Jan 2004 06:51:30 -0000 1.11 @@ -27,6 +27,7 @@ m_owner = 0; m_houses = 0; m_price = 0; + m_money = 0; m_estateGroup = 0; m_changed = m_canBeOwned = m_canBuyHouses = m_canSellHouses = m_isMortgaged = m_canToggleMortgage = false; m_bgColor = QColor(); @@ -138,6 +139,20 @@ } } +void Estate::setMoney(int money) +{ + if (m_money != money) + { + m_money = money; + m_changed = true; + } +} + +int Estate::money() +{ + return m_money; +} + void Estate::update(bool force) { if (m_changed || force) Index: estate.h =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/estate.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- estate.h 23 Jun 2003 03:05:27 -0000 1.13 +++ estate.h 20 Jan 2004 06:51:30 -0000 1.14 @@ -56,6 +56,8 @@ QColor bgColor() const { return m_bgColor; } void setPrice(const unsigned int price) { m_price = price; } unsigned int price() const { return m_price; } + void setMoney(int money); + int money(); void update(bool force = false); signals: @@ -75,6 +77,7 @@ Player *m_owner; EstateGroup *m_estateGroup; unsigned int m_houses, m_price; + int m_money; bool m_canBeOwned, m_canBuyHouses, m_canSellHouses, m_isMortgaged, m_canToggleMortgage; QColor m_bgColor, m_color; }; Index: player.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/player.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- player.cpp 16 Jul 2003 21:53:16 -0000 1.21 +++ player.cpp 20 Jan 2004 06:51:30 -0000 1.22 @@ -21,25 +21,30 @@ Player::Player(int playerId) : QObject() { m_id = playerId; - m_gameId = -1; + m_game = 0; m_name = ""; m_host = ""; m_image = ""; m_location = m_destination = 0; m_money = 0; m_changed = m_isSelf = false; - m_master = m_bankrupt = m_hasDebt = m_hasTurn = m_canRoll = m_canBuy = m_canAuction = m_canUseCard = m_inJail = false; + m_bankrupt = m_hasDebt = m_hasTurn = m_canRoll = m_canBuy = m_canAuction = m_canUseCard = m_inJail = false; } -void Player::setGame(int gameId) +void Player::setGame(Game *game) { - if (m_gameId != gameId) + if (m_game != game) { - m_gameId = gameId; + m_game = game; m_changed = true; } } +Game *Player::game() +{ + return m_game; +} + void Player::setLocation(Estate *location) { if (m_location != location) @@ -58,15 +63,6 @@ } } -void Player::setMaster(bool master) -{ - if (m_master != master) - { - m_master = master; - m_changed = true; - } -} - void Player::setBankrupt(bool bankrupt) { if (m_bankrupt != bankrupt) Index: player.h =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantic/player.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- player.h 3 Dec 2003 19:10:39 -0000 1.19 +++ player.h 20 Jan 2004 06:51:30 -0000 1.20 @@ -21,6 +21,7 @@ #include class Estate; +class Game; class Player : public QObject { @@ -30,16 +31,14 @@ Player(int playerId); int id() { return m_id; } - void setGame(int gameId); - int gameId() { return m_gameId; } + void setGame(Game *game); + Game *game(); void setLocation(Estate *location); Estate *location() { return m_location; } void setDestination(Estate *destination); Estate *destination() { return m_destination; } void setIsSelf(const bool isSelf) { m_isSelf = isSelf; } bool isSelf() const { return m_isSelf; } - void setMaster(bool master); - bool master() { return m_master; } void setBankrupt(bool bankrupt); bool isBankrupt() { return m_bankrupt; } void setHasDebt(bool hasDebt); @@ -71,11 +70,12 @@ void gainedTurn(); private: - int m_id, m_gameId; + int m_id; bool m_changed, m_isSelf; - bool m_master, m_bankrupt, m_hasDebt, m_hasTurn, m_canRoll, m_canBuy, m_canAuction, m_canUseCard, m_inJail; + bool m_bankrupt, m_hasDebt, m_hasTurn, m_canRoll, m_canBuy, m_canAuction, m_canUseCard, m_inJail; unsigned int m_money; QString m_name, m_host, m_image; + Game *m_game; Estate *m_location, *m_destination; }; _______________________________________________ atlantik-cvs mailing list atlantik-cvs@kde.org https://mail.kde.org/mailman/listinfo/atlantik-cvs