File indexing completed on 2024-04-28 07:51:25

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 KBLOCKSNETPLAYER_H
0008 #define KBLOCKSNETPLAYER_H
0009 
0010 #include "KBlocksNetClient.h"
0011 #include "KBlocksSingleGame.h"
0012 #include "GamePlayerInterface.h"
0013 
0014 class KBlocksNetPlayer
0015 {
0016 public:
0017     KBlocksNetPlayer(GamePlayerInterface *player, const string &serverIP, int localPort);
0018     ~KBlocksNetPlayer();
0019 
0020 public:
0021     void joinGame(int gameIndex);
0022     void quitGame();
0023 
0024     void startGame(KBlocksSingleGame *p);
0025     void stopGame();
0026 
0027     bool execute();
0028 
0029 private:
0030     int  formIntFromByte(char *data);
0031 
0032 private:
0033     GamePlayerInterface *mpPlayer = nullptr;
0034     KBlocksSingleGame *mpGame = nullptr;
0035     KBlocksNetClient *mpNetClient = nullptr;
0036 
0037     int mSendLength;
0038 
0039     GamePlayer_ActionList mActionList;
0040 };
0041 
0042 #endif
0043