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 KBLOCKSGAMEREPLAYER_H |
11 | #define KBLOCKSGAMEREPLAYER_H |
12 | |
13 | #include "KBlocksDefine.h" |
14 | |
15 | #include <stdio.h> |
16 | #include <string> |
17 | #include <vector> |
18 | #include <list> |
19 | #include <map> |
20 | |
21 | using std::string; |
22 | using std::vector; |
23 | using std::list; |
24 | using std::map; |
25 | |
26 | struct KBlocksReplayData |
27 | { |
28 | int index; |
29 | int type; |
30 | int value; |
31 | int time; |
32 | }; |
33 | |
34 | class KBlocksGameReplayer |
35 | { |
36 | public: |
37 | explicit KBlocksGameReplayer(const char * fileName, bool isBinaryMode = true); |
38 | ~KBlocksGameReplayer(); |
39 | |
40 | public: |
41 | void setStepLength(int stepLen); |
42 | |
43 | int getGameCount(); |
44 | int getGameSeed(); |
45 | bool isSameSeed(); |
46 | |
47 | bool getNextRecords(vector<KBlocksReplayData> * data); |
48 | |
49 | private: |
50 | void loadText(FILE * pFile); |
51 | void loadBinary(FILE * pFile); |
52 | |
53 | private: |
54 | int mGameCount; |
55 | int mGameSeed; |
56 | bool mSameSeed; |
57 | int mStepLength; |
58 | list<KBlocksReplayData> mReplayList; |
59 | map<string, int> mRTMap; |
60 | }; |
61 | |
62 | #endif |
63 | |