1 | /*************************************************************************** |
2 | * KBlocks, a falling blocks game for KDE * |
3 | * Copyright (C) 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | ***************************************************************************/ |
10 | #ifndef KBLOCKSSINGLEPLAYER_H |
11 | #define KBLOCKSSINGLEPLAYER_H |
12 | |
13 | #include <QTimer> |
14 | #include <QList> |
15 | |
16 | #include "SingleGameInterface.h" |
17 | #include "GamePlayerInterface.h" |
18 | |
19 | enum KBlocksPlayer_State |
20 | { |
21 | KBlocksPlayer_ThinkingState = 0, |
22 | KBlocksPlayer_ProcessingState, |
23 | KBlocksPlayer_Max_State_Count |
24 | }; |
25 | |
26 | class KBlocksSinglePlayer : public QObject |
27 | { |
28 | Q_OBJECT |
29 | |
30 | public: |
31 | KBlocksSinglePlayer(GamePlayerInterface * player, int thinkInterval, int processInterval); |
32 | ~KBlocksSinglePlayer(); |
33 | |
34 | public: |
35 | void startGame(SingleGameInterface * p); |
36 | void stopGame(); |
37 | |
38 | void pauseGame(bool flag); |
39 | |
40 | private: |
41 | void think(); |
42 | bool process(); |
43 | |
44 | private slots: |
45 | void doAction(); |
46 | |
47 | private: |
48 | GamePlayerInterface* mpPlayer; |
49 | SingleGameInterface* mpGame; |
50 | |
51 | int mPlayerState; |
52 | |
53 | int mThinkInterval; |
54 | int mProcessInterval; |
55 | |
56 | QTimer mActionTimer; |
57 | |
58 | GamePlayer_ActionList mActionList; |
59 | }; |
60 | |
61 | #endif |
62 | |
63 | |