| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009 by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | |
| 23 | /*************************************************************************** |
| 24 | * |
| 25 | * This class is the most important |
| 26 | * It deals with distributing the move (and other commands) requests |
| 27 | * It is subclassed in the different proxies that can be used : local game, |
| 28 | * server game, and computer game |
| 29 | * Its the only class (apart from 'sgf parser') to modify the game tree |
| 30 | * |
| 31 | ***************************************************************************/ |
| 32 | |
| 33 | #ifndef QGOBOARD_H |
| 34 | #define QGOBOARD_H |
| 35 | |
| 36 | #include "defines.h" |
| 37 | |
| 38 | class BoardWindow; |
| 39 | class Tree; |
| 40 | class GameData; |
| 41 | class Move; |
| 42 | class QGtp; |
| 43 | class Sound; |
| 44 | |
| 45 | /* I think its easier to have the computer and normal modes override a few functions to |
| 46 | * null then have review and match provide the same complicated net functionality */ |
| 47 | |
| 48 | |
| 49 | class qGoBoard : public QObject //, public Misc<QString> |
| 50 | { |
| 51 | Q_OBJECT |
| 52 | |
| 53 | public: |
| 54 | qGoBoard(BoardWindow *bw, Tree * t, GameData *gd); |
| 55 | ~qGoBoard(); |
| 56 | virtual void setHandicap(int handicap); |
| 57 | virtual void addStone(StoneColor c, int x, int y); |
| 58 | |
| 59 | virtual void addMark( int x, int y, MarkType t ); |
| 60 | virtual void removeMark( int x, int y); |
| 61 | |
| 62 | // virtual void localMoveRequest(int x, int y)=0; |
| 63 | virtual bool getBlackTurn(bool time = false); |
| 64 | virtual void startGame() {} |
| 65 | virtual void stopTime() {} |
| 66 | virtual void handleMove(class MoveRecord *) {} |
| 67 | virtual void moveControl(QString &) {} |
| 68 | int getMoveNumber(void); |
| 69 | //virtual void set_havegd(bool b) { have_gameData = b; } |
| 70 | virtual void setModified(bool b= true) { isModified = b;} |
| 71 | virtual bool getModified() { return isModified; } |
| 72 | virtual bool getPlaySound() { return playSound;} |
| 73 | |
| 74 | virtual void setResult(class GameResult & ); |
| 75 | virtual void kibitzReceived(const QString& txt); |
| 76 | virtual void setTimerInfo(const QString&, const QString&, const QString&, const QString&) {} |
| 77 | virtual void timerEvent(QTimerEvent*); |
| 78 | class TimeRecord getOurTimeRecord(void); //awkward |
| 79 | class TimeRecord getTheirTimeRecord(void); |
| 80 | virtual void enterScoreMode(); |
| 81 | virtual void leaveScoreMode(); |
| 82 | void toggleGroupAt(int x, int y); |
| 83 | virtual void markDeadStone(int x, int y); |
| 84 | virtual void markLiveStone(int x, int y); |
| 85 | virtual void markDeadArea(int x, int y); |
| 86 | virtual void markLiveArea(int x, int y); |
| 87 | |
| 88 | virtual void setNode(int , StoneColor , int , int ) {} |
| 89 | virtual void requestAdjournDialog(void) {} |
| 90 | virtual void requestCountDialog(void) {} |
| 91 | virtual void requestMatchModeDialog(void) {} |
| 92 | virtual void requestDrawDialog(void) {} |
| 93 | virtual void adjournGame(void) {} |
| 94 | virtual void recvRefuseAdjourn(void) {} |
| 95 | virtual void recvRefuseCount(void) {} |
| 96 | virtual void recvRefuseMatchMode(void) {} |
| 97 | virtual void recvRefuseDraw(void) {} |
| 98 | |
| 99 | // Board |
| 100 | virtual void slotBoardClicked(bool, int, int , Qt::MouseButton ); |
| 101 | virtual void passRequest(); |
| 102 | virtual void slotDonePressed(); |
| 103 | virtual void slotResignPressed(); |
| 104 | virtual void slotReviewPressed() {} |
| 105 | virtual void slotDrawPressed() {} |
| 106 | virtual void slotCountPressed() {} |
| 107 | virtual void slotUndoPressed(); |
| 108 | virtual void slotScoreToggled(bool); |
| 109 | virtual void setPlaySound(bool b) { playSound = b; } |
| 110 | |
| 111 | protected: |
| 112 | BoardWindow *boardwindow; |
| 113 | Tree *tree; |
| 114 | GameData *gameData; |
| 115 | Sound *clickSound; |
| 116 | int boardTimerId; |
| 117 | |
| 118 | bool isModified; |
| 119 | int id; |
| 120 | int stated_mv_count; |
| 121 | Move * lastMoveInGame; |
| 122 | bool playSound; |
| 123 | |
| 124 | /* |
| 125 | * This functions gets the move request (from a board click) |
| 126 | * and displays the resulting stone (if valid) |
| 127 | * The base class implementation is empty because network and local games need completely different hadling. |
| 128 | */ |
| 129 | virtual void localMoveRequest(StoneColor, int, int) {} |
| 130 | virtual void localMarkDeadRequest(int x, int y); |
| 131 | virtual void sendMoveToInterface(StoneColor ,int, int) {} |
| 132 | virtual Move *doMove(StoneColor, int, int) { return NULL; } |
| 133 | virtual void doPass(StoneColor c = stoneNone); // By default the player who is on turn will pass |
| 134 | protected: |
| 135 | bool dontCheckValidity; |
| 136 | }; |
| 137 | #endif |