Debian Codegraph @

src/game_interfaces/qgoboard_review.cpp

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2006 by EB *
3 * *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21
22 #include "qgoboard_net.h"
23 #include "tree.h"
24 #include "move.h"
25 #include "gamedata.h"
26 #include "boardwindow.h"
27 #include "board.h"
28
29 #include <QMessageBox>
30
31 qGoBoardReviewInterface::qGoBoardReviewInterface(BoardWindow *bw, Tree * t, GameData *gd) : qGoBoardNetworkInterface(bw, t, gd) //, QObject(bw)
32 {
33 game_Id = QString::number(gd->number);
34
35 boardwindow->clearData();
36
37 QSettings settings;
38 // value 1 = no sound, 0 all games, 2 my games
39 playSound = (settings.value("SOUND") != 1);
40
41 tree->slotNavFirst();
42 }
43
44
45 /*
46 * local move request to be sent to the server
47 */
48 void qGoBoardReviewInterface::localMoveRequest(StoneColor c, int x, int y)
49 {
50 // if (doMove(c,x,y))
51 // FIXME : this should be made in a better way : wait for the interface to acknowledge before adding the move to the tree
52 // {
53 // boardwindow->getBoardHandler()->updateMove(tree->getCurrent());
54 sendMoveToInterface(c,x,y);
55 // }
56
57 }
58
59 /* This is like a special set_move and should be more clear */
60 /*
61 * A node is incoming from the interface (server)
62 */
63 void qGoBoardReviewInterface::setNode(int node_nr, StoneColor sc, int x, int y)
64 {
65 Move *m = tree->findNode(tree->getRoot(), node_nr);
66
67 if (m)
68 //node found, we go there
69 tree->setCurrent(m);
70 else
71 // no node found, we create one from the current move
72 {
73 if (doMove(sc, x,y))
74 tree->getCurrent()->setNodeIndex(node_nr);
75 else
76 QMessageBox::warning(boardwindow, tr("Invalid Move"), tr("The incoming move %1,%2 seems to be invalid").arg(x).arg(y));
77 }
78 }
79
80
81
82 #ifdef OLD
83 /*
84 * A move string is incoming from the interface (server)
85 * TODO : code duplicate : make sure we can't send this to qgoboard
86 */
87 void qGoBoardReviewInterface::set_move(StoneColor sc, QString pt, QString mv_nr)
88 {
89
90 }
91
92 /*
93 * sends a "pass" move to the server
94 */
95 void qGoBoardReviewInterface::sendPassToInterface(StoneColor /*c*/)
96 {
97 /* What really is this doing in the review interface ??? */
98 emit signal_sendCommandFromBoard("pass", false);
99 boardwindow->getBoardDispatch()->sendMove(new MoveRecord(MoveRecord::PASS));
100 }
101 #endif //OLD
102
103 /*
104 * sends a move to the server
105 */
106 #ifdef OLD
107 void qGoBoardReviewInterface::sendMoveToInterface(StoneColor c, int x, int y)
108 {
109
110 if (x > 8)
111 x++;
112
113 char c1 = x - 1 + 'A';
114 //int c2 = gd.size + 1 - y;
115 int c2 = boardwindow->getBoardSize() + 1 - y;
116
117 // if (ExtendedTeachingGame && IamPupil)
118 // emit signal_sendcommand("kibitz " + QString::number(id) + " " + QString(c1) + QString::number(c2), false);
119 QString id = "";
120
121 // if (gsName == IGS)
122 id = game_Id;
123 /* Where and why would we get the number here, is 0 okay for now ??? FIXME */
124
125 boardwindow->getBoardDispatch()->sendMove(new MoveRecord(0, x, y, c));
126
127 emit signal_sendCommandFromBoard(QString(c1) + QString::number(c2) + " " + id, false);
128
129
130
131 }
132 #endif //OLD
133
134 /*
135 * 'undo' button pressed
136 */
137 void qGoBoardReviewInterface::slotUndoPressed()
138 {
139
140 }