File indexing completed on 2024-05-12 07:58:36
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 KBLOCKSSINGLEPLAYER_H 0008 #define KBLOCKSSINGLEPLAYER_H 0009 0010 #include <QTimer> 0011 0012 #include "SingleGameInterface.h" 0013 #include "GamePlayerInterface.h" 0014 0015 enum KBlocksPlayer_State { 0016 KBlocksPlayer_ThinkingState = 0, 0017 KBlocksPlayer_ProcessingState, 0018 KBlocksPlayer_Max_State_Count 0019 }; 0020 0021 class KBlocksSinglePlayer : public QObject 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 KBlocksSinglePlayer(GamePlayerInterface *player, int thinkInterval, int processInterval); 0027 ~KBlocksSinglePlayer() override; 0028 0029 public: 0030 void startGame(SingleGameInterface *p); 0031 void stopGame(); 0032 0033 void pauseGame(bool flag); 0034 0035 private: 0036 void think(); 0037 bool process(); 0038 0039 private Q_SLOTS: 0040 void doAction(); 0041 0042 private: 0043 GamePlayerInterface *mpPlayer = nullptr; 0044 SingleGameInterface *mpGame = nullptr; 0045 0046 int mPlayerState; 0047 0048 int mThinkInterval; 0049 int mProcessInterval; 0050 0051 QTimer mActionTimer; 0052 0053 GamePlayer_ActionList mActionList; 0054 }; 0055 0056 #endif 0057