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 KBLOCKSGAMELOGIC_H
11#define KBLOCKSGAMELOGIC_H
12
13#include <stdlib.h>
14
15#include "GameLogicInterface.h"
16#include "SingleGameInterface.h"
17
18#include "KBlocksDefine.h"
19
20#include "KBlocksGameRecorder.h"
21#include "KBlocksGameReplayer.h"
22
23#include "KBlocksSingleGame.h"
24
25class KBlocksGameLogic : public GameLogicInterface
26{
27 public:
28 explicit KBlocksGameLogic(int capacity, bool record = false);
29 KBlocksGameLogic(KBlocksGameReplayer * p);
30 ~KBlocksGameLogic();
31
32 public:
33 int getActiveGameCount();
34 KBlocksSingleGame* getSingleGame(int index);
35
36 bool playRecordOneStep(int * changedPiece);
37 void getRecordLastField(int index);
38 void saveRecord(const char * fileName, bool binaryMode = true);
39
40 int levelUpGame(int level);
41 int updateGame(int * lineList);
42
43 void setGameSeed(int seed);
44 void setGamePunish(bool flag);
45
46 void setGameStandbyMode(bool flag);
47 void setGameInterval(int interval);
48 void setInitInterval(int interval);
49 void setLevelUpInterval(int interval);
50
51 bool startGame(int gameCount);
52 bool stopGame();
53
54 void pauseGame(bool pauseFlag);
55 void continueGame();
56
57 private:
58 void createSingleGames(int gameCount);
59 void deleteSingleGames();
60
61 protected:
62 KBlocksSingleGame** maGameList;
63
64 private:
65 int mGameMax;
66 int mGameCount;
67
68 int mGameSeed;
69 int mPunishFlag;
70
71 bool mStandbyMode;
72 int mGameInterval;
73 int mInitialInterval;
74 int mLevelUpInterval;
75
76 KBlocksGameRecorder * mpGameRecorder;
77 KBlocksGameReplayer * mpGameReplayer;
78};
79
80#endif
81
82