summaryrefslogtreecommitdiffstats
path: root/libksirtet/common/board.h
blob: 5f38df9e4c6563c5d815984ad1b2dc6848f22a4e (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef COMMON_BOARD_H
#define COMMON_BOARD_H

#include "base/board.h"

#include "lib/libksirtet_export.h"

class GiftPool;
class AI;

class LIBKSIRTET_EXPORT Board : public BaseBoard
{
 Q_OBJECT
  TQ_OBJECT
 public:
    Board(bool graphic, GiftPool *, TQWidget *tqparent);
    virtual ~Board();

    void setType(bool computer);
    virtual void start(const GTInitData &);
    void unpause();
    void stop();

    virtual uint gift() = 0;
    virtual bool needRemoving() = 0;

    GiftPool *giftPool() const { return _giftPool; }

 public slots:
    void pMoveLeft();
    void pMoveRight();
    void pDropDownStart();
    void pDropDownStop();
    void pOneLineDown();
    void pRotateLeft();
    void pRotateRight();
    void pMoveLeftTotal();
    void pMoveRightTotal();

 private slots:
    bool timeout();

 signals:
    void levelUpdated();

 protected:
    KRandomSequence randomGarbage;

    virtual bool beforeGlue(bool bump, bool first);
    virtual void gluePiece();
    virtual bool afterGlue(bool /*doAll*/, bool /*first*/) { return false; }
    virtual bool afterGift(bool /*first*/) { return false; }
    virtual bool putGift(uint) = 0;

    virtual uint normalTime() const;
    void updateLevel();

    void settingsChanged();

 private:
    uint      _dropHeight;
    GiftPool *_giftPool;
    AI       *aiEngine;

    bool newPiece();
    void pieceDropped(uint dropHeight);
    void _afterGift(bool first);
    void _beforeGlue(bool first);
    void _afterGlue(bool first);
    bool afterAfterRemove();
    bool startTimer();
    void showBoard(bool show);
    void updateLevel(uint newLevel);
};

#endif