File indexing completed on 2024-04-21 04:02:08

0001 /***************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                *
0003 *   SPDX-FileCopyrightText: 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com>       *
0004 *                                                                         *
0005 *   SPDX-License-Identifier: GPL-2.0-or-later
0006 ***************************************************************************/
0007 #ifndef KBLOCKSPLAYNETWORK_H
0008 #define KBLOCKSPLAYNETWORK_H
0009 
0010 #include "KBlocksGameLogic.h"
0011 #include "GamePlayerInterface.h"
0012 #include "KBlocksNetPlayer.h"
0013 
0014 class KBlocksPlayNetwork
0015 {
0016 public:
0017     KBlocksPlayNetwork(int capacity, const string &serverIP, int localPort);
0018     ~KBlocksPlayNetwork();
0019 
0020 public:
0021     bool addGamePlayer(GamePlayerInterface *p);
0022     void clearGamePlayer();
0023 
0024     void startGame();
0025     void stopGame();
0026 
0027     int  execute();
0028 
0029     void cancelExecute();
0030 
0031 private:
0032     string mServerIP;
0033     int mLocalPort;
0034 
0035     bool mRunning;
0036 
0037     int mPlayerCount;
0038     int mMaxCapacity;
0039     KBlocksNetPlayer **maPlayerList;
0040 
0041     KBlocksGameLogic *mpGameLogic = nullptr;
0042 };
0043 
0044 #endif
0045