File indexing completed on 2024-04-21 04:04:50

0001 /*
0002    This library is free software; you can redistribute it and/or
0003    modify it under the terms of the GNU General Public
0004    License either version 2
0005    of the License, or (at your option) any later version.as published by the Free Software Foundation.
0006 
0007    This library is distributed in the hope that it will be useful,
0008    but WITHOUT ANY WARRANTY; without even the implied warranty of
0009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0010    Library General Public License for more details.
0011 
0012    You should have received a copy of the GNU General Public License
0013    along with this library; see the file COPYING.LIB.  If not, write to
0014    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0015    Boston, MA 02110-1301, USA.
0016 */
0017 
0018 #ifndef NEWGAMESETUP_H
0019 #define NEWGAMESETUP_H
0020 
0021 #include "GameLogic/gameautomaton.h"
0022 
0023 
0024 #include <QList>
0025 #include <QMap>
0026 
0027 namespace Ksirk
0028 {
0029   class NewPlayerData;
0030   namespace GameLogic
0031   {
0032     class ONU;
0033   }
0034 }
0035   
0036 class NewGameSetup
0037 {
0038 public:
0039   explicit NewGameSetup(Ksirk::GameLogic::GameAutomaton* automaton);
0040 
0041   virtual ~NewGameSetup() {}
0042   
0043   inline Ksirk::GameLogic::GameAutomaton* automaton() {return m_automaton;}
0044   inline const QString& skin() const {return m_skin;}
0045   inline void setSkin(const QString& skin) {m_skin= skin;}
0046 
0047   inline QMap<QString, Ksirk::GameLogic::ONU*>& worlds() {return m_worlds;}
0048   
0049   inline QList<Ksirk::NewPlayerData*>& players() {return m_players;}
0050   inline const QList<Ksirk::NewPlayerData*>& players() const {return m_players;}
0051 
0052   inline int nbPlayers() const {return m_nbPlayers;}
0053   inline void setNbPlayers(int nbPlayers) {m_nbPlayers = nbPlayers;}
0054 
0055   int nbLocalPlayers() const;
0056 
0057   inline int nbNetworkPlayers() const {return m_nbNetworkPlayers;}
0058   inline void setNbNetworkPlayers(int nbNetworkPlayers) {m_nbNetworkPlayers = nbNetworkPlayers;}
0059 
0060   inline bool useGoals() const {return m_useGoals;}
0061   inline void setUseGoals(bool useGoals) {m_useGoals = useGoals;}
0062 
0063   inline Ksirk::GameLogic::GameAutomaton::NetworkGameType networkGameType() const
0064   {
0065     return m_networkGameType;
0066   }
0067   inline void setNetworkGameType(Ksirk::GameLogic::GameAutomaton::NetworkGameType networkGameType)
0068   {
0069     m_networkGameType = networkGameType;
0070   }
0071 
0072   inline int tcpPort() const {return m_tcpPort;}
0073   inline void setTcpPort(int tcpPort) {m_tcpPort = tcpPort;}
0074   inline const QString& host() const {return m_host;}
0075   inline void setHost(const QString& host) {m_host = host;}
0076 
0077   bool addPlayer(Ksirk::NewPlayerData* player);
0078 
0079   void clear();
0080   
0081 private:
0082   Ksirk::GameLogic::GameAutomaton* m_automaton;
0083   QString m_skin;
0084   QMap<QString, Ksirk::GameLogic::ONU*> m_worlds;
0085   
0086   QList<Ksirk::NewPlayerData*> m_players;
0087   int m_nbPlayers;
0088   int m_nbNetworkPlayers;
0089   bool m_useGoals;
0090   Ksirk::GameLogic::GameAutomaton::NetworkGameType m_networkGameType;
0091   int m_tcpPort;
0092   QString m_host;
0093 };
0094 
0095 QDataStream& operator<<(QDataStream& stream, const NewGameSetup& ngs);
0096 QDataStream& operator>>(QDataStream& stream, NewGameSetup& ngs);
0097 
0098 #endif // NEWGAMESETUP_H