summaryrefslogtreecommitdiffstats
path: root/kfouleggs/piece.h
blob: e7b23e1e6b5c7faaee3b061422b5403e1c087483 (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 PIECE_H
#define PIECE_H

#include "base/piece.h"


class FEPieceInfo : public GPieceInfo
{
 public:
    FEPieceInfo() {}

    virtual uint nbBlocks() const { return NB_BLOCKS; }
    virtual uint nbForms()  const { return 1; }
    virtual uint nbTypes()  const
        { return NB_NORM_BLOCK_TYPES * NB_NORM_BLOCK_TYPES; }

    virtual const int *i(uint, uint rot) const { return FORM.i[rot]; }
    virtual const int *j(uint, uint rot) const { return FORM.j[rot]; }
    virtual uint value(uint type, uint n) const
        { return (n%2 ? type/4 : type%4); }
    virtual uint form(uint) const               { return 0; }
    virtual uint nbConfigurations(uint type) const
        { return ((type%4)==(type/4) ? 2 : 4);}

    virtual uint nbNormalBlockTypes() const  { return NB_NORM_BLOCK_TYPES; }
    virtual uint nbGarbageBlockTypes() const { return 1; }
    virtual uint nbBlockModes() const        { return NB_BLOCK_MODES; }

    virtual uint nbColors() const { return NB_NORM_BLOCK_TYPES + 1; }
    virtual TQString colorLabel(uint i) const;
    virtual TQColor defaultColor(uint i) const;

 private:
    void draw(TQPixmap *, uint blockType, uint blockMode, bool lighted) const;
    void setMask(TQPixmap *, uint blockMode) const;

    enum { NB_BLOCKS = 2,
           NB_NORM_BLOCK_TYPES = 4,
           NB_BLOCK_MODES = 1+4+6+4+1 };  // all possible connections

    struct Form {
        int i[4][NB_BLOCKS];
        int j[4][NB_BLOCKS];
    };
    static const Form FORM;

    static const char *DEFAULT_COLORS[NB_NORM_BLOCK_TYPES + 1];
};

#endif