File indexing completed on 2024-04-14 03:59:23
0001 /****************************************************************************** 0002 * KBlocks, a falling blocks game by KDE * 0003 * SPDX-FileCopyrightText: 2010-2021 Zhongjie Cai <squall.leonhart.cai@gmail.com> * 0004 * Julian Helfferich <julian.helfferich@mailbox.org> * 0005 * * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 ******************************************************************************/ 0008 #ifndef KBLOCKSGAMELOGIC_H 0009 #define KBLOCKSGAMELOGIC_H 0010 0011 #include <stdlib.h> 0012 0013 #include "GameLogicInterface.h" 0014 #include "SingleGameInterface.h" 0015 0016 #include "KBlocksDefine.h" 0017 0018 #include "KBlocksGameRecorder.h" 0019 #include "KBlocksGameReplayer.h" 0020 0021 #include "KBlocksSingleGame.h" 0022 0023 class KBlocksGameLogic : public GameLogicInterface 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 explicit KBlocksGameLogic(int capacity, bool record = false); 0029 explicit KBlocksGameLogic(KBlocksGameReplayer *p); 0030 ~KBlocksGameLogic() override; 0031 0032 public: 0033 int getActiveGameCount(); 0034 KBlocksSingleGame *getSingleGame(int index) override; 0035 0036 bool playRecordOneStep(int *changedPiece); 0037 void saveRecord(const char *fileName, bool binaryMode = true); 0038 0039 int levelUpGame(int level) override; 0040 int updateGame(int *lineList) override; 0041 0042 void setGameSeed(int seed) override; 0043 void setGamePunish(bool flag); 0044 0045 void setGameStandbyMode(bool flag) override; 0046 void setGameInterval(int interval); 0047 void setInitInterval(int interval); 0048 void setLevelUpInterval(int interval); 0049 0050 bool startGame(int gameCount) override; 0051 0052 void pauseGame(bool pauseFlag) override; 0053 void continueGame() override; 0054 0055 /** 0056 * Return whether single games have been created. 0057 */ 0058 bool hasSingleGames() override; 0059 void deleteSingleGames() override; 0060 0061 public Q_SLOTS: 0062 bool stopGame() override; 0063 0064 private: 0065 void createSingleGames(int gameCount); 0066 0067 protected: 0068 KBlocksSingleGame **maGameList; 0069 0070 private: 0071 int mGameMax; 0072 int mGameCount; 0073 0074 int mGameSeed; 0075 int mPunishFlag; 0076 0077 bool mStandbyMode; 0078 int mGameInterval; 0079 int mInitialInterval; 0080 int mLevelUpInterval; 0081 0082 KBlocksGameRecorder *mpGameRecorder = nullptr; 0083 KBlocksGameReplayer *mpGameReplayer = nullptr; 0084 }; 0085 0086 #endif 0087