~ubuntu-branches/ubuntu/maverick/qgo/maverick

« back to all changes in this revision

Viewing changes to src/stonehandler.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin A. Godisch
  • Date: 2005-01-01 23:07:10 UTC
  • Revision ID: james.westby@ubuntu.com-20050101230710-fhng6yidm47xlb2i
Tags: upstream-1.0.0-r2
ImportĀ upstreamĀ versionĀ 1.0.0-r2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* stonehandler.h
 
3
*/
 
4
 
 
5
#ifndef STONEHANDLER_H
 
6
#define STONEHANDLER_H
 
7
 
 
8
#include <qintdict.h>
 
9
#include <qvaluelist.h>
 
10
#include "defines.h"
 
11
#include "matrix.h"
 
12
#include "stone.h"
 
13
#include <qptrlist.h>
 
14
 
 
15
class Group;
 
16
class BoardHandler;
 
17
 
 
18
class StoneHandler
 
19
{
 
20
public:
 
21
        StoneHandler(BoardHandler *bh);
 
22
        ~StoneHandler();
 
23
        void clearData();
 
24
        void toggleWorking(bool toggle) { workingOnNewMove = toggle; }
 
25
//  bool addStone(Stone *stone, bool toAdd=true, bool toCheck=true);  
 
26
        bool addStone(Stone *stone, bool toAdd=true, bool toCheck=true, Matrix *m=NULL); //SL added eb 8
 
27
        bool removeStone(int x, int y, bool hide=false);
 
28
        int hasStone(int x, int y);
 
29
        Stone* getStoneAt(int x, int y) { return stones->find(Matrix::coordsToKey(x, y)); }
 
30
        QIntDict<Stone>* getAllStones() const { return stones; }
 
31
        bool updateAll(Matrix *m, bool toDraw=true);
 
32
        void checkAllPositions();
 
33
        bool removeDeadGroup(int x, int y, int &caps, StoneColor &col, bool &dead);
 
34
        bool markSekiGroup(int x, int y, int &caps, StoneColor &col, bool &seki);
 
35
        void removeDeadMarks();
 
36
        void updateDeadMarks(int &black, int &white);
 
37
        bool checkFalseEye(Matrix *m, int x, int y, int col);
 
38
        int numStones() const { return stones->count(); } // TODO: For debugging only currently.
 
39
        // Needed later?
 
40
#ifndef NO_DEBUG
 
41
        void debug();
 
42
#endif
 
43
        
 
44
protected:
 
45
//  bool checkPosition(Stone *stone);
 
46
        bool checkPosition(Stone *stone,Matrix *m);       //SL added eb 8
 
47
        Group* assembleGroup(Stone *stone,Matrix *m);     //SL added eb 8
 
48
//  Group* assembleGroup(Stone *stone);
 
49
        Group* checkNeighbour(int x, int y, StoneColor color, Group *group,Matrix *m);
 
50
        Group* checkNeighbour(int x, int y, StoneColor color, Group *group);
 
51
        int countLiberties(Group *group, Matrix *m);      //SL added eb 8
 
52
        int countLibertiesOnMatrix(Group *group, Matrix *m);
 
53
        void checkNeighbourLiberty(int x, int y, QValueList<int> &libCounted, int &liberties, Matrix *m);
 
54
        void checkNeighbourLibertyOnMatrix(int x, int y, QValueList<int> &libCounted, int &liberties, Matrix *m);
 
55
        
 
56
private:
 
57
        QIntDict<Stone> *stones;
 
58
        QPtrList<Group> *groups;
 
59
        bool workingOnNewMove;
 
60
        BoardHandler *boardHandler;
 
61
};
 
62
 
 
63
#endif