summaryrefslogtreecommitdiffstats
path: root/ksirtet/ksirtet/board.h
blob: 45ec0f26a7fc8baf17ae659f3c7d7626ecacb549 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef KS_BOARD_H
#define KS_BOARD_H

#include "common/board.h"


class KSBoard : public Board
{
 Q_OBJECT
 public:
	KSBoard(bool graphic, TQWidget *parent);
	void copy(const GenericTetris &);

	void start(const GTInitData &);
    enum Constants { Width = 10, Nb_Stages = 6 };
    uint nbRemovedLines(uint i) const { return linesRemoved[i]; }
    uint lastRemoved() const { return _lastRemoved; }

 private:
    TQMemArray<uint> filled;
    TQMemArray<uint> linesRemoved;
	uint            addRemoved;
    uint _lastRemoved;

    struct StageData {
        uint todo, speed;
        bool hasPattern;
        uint pattern[Width];
    };
    static const StageData STAGE_DATA[Nb_Stages];

    void init();
	uint gift();
	bool putGift(uint nb);
	bool _putGift(uint nb);
	bool needRemoving();
    void remove();
    bool toBeRemoved(const KGrid2D::Coord &) const;
    bool toFall(const KGrid2D::Coord &) const;
    void computeInfos();
    void setGarbageBlock(const KGrid2D::Coord &);

    const StageData &stageData() const { return STAGE_DATA[arcadeStage()]; }
    uint normalTime() const;
    uint arcadeTodo() const { return stageData().todo; }
    uint arcadeDone() const { return nbRemoved(); }
    void arcadePrepare();
};

#endif