| 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 | #include "displayboard.h" |
| 24 | #include "stone.h" |
| 25 | #include "mark.h" |
| 26 | #include "board.h" |
| 27 | #include "imagehandler.h" |
| 28 | |
| 29 | #include <QtWidgets> |
| 30 | |
| 31 | DisplayBoard::DisplayBoard(QWidget *parent, QGraphicsScene *c) |
| 32 | : Board(parent,c) |
| 33 | { |
| 34 | isDisplayBoard = true; |
| 35 | showCoords = false; |
| 36 | imageHandler->setDisplay(true); |
| 37 | } |
| 38 | |
| 39 | DisplayBoard::~DisplayBoard() |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | /* Used by file browse display */ |
| 44 | void DisplayBoard::displayHandicap(int handicap) |
| 45 | { |
| 46 | int size = 19; |
| 47 | int edge_dist = (size > 12 ? 4 : 3); |
| 48 | int low = edge_dist; |
| 49 | int middle = (size + 1) / 2; |
| 50 | int high = size + 1 - edge_dist; |
| 51 | |
| 52 | |
| 53 | switch (handicap) |
| 54 | { |
| 55 | case 9: |
| 56 | updateStone(stoneBlack, middle, middle); |
| 57 | case 8: |
| 58 | case 7: |
| 59 | if (handicap >= 8) |
| 60 | { |
| 61 | updateStone(stoneBlack, middle, low); |
| 62 | updateStone(stoneBlack, middle, high); |
| 63 | } |
| 64 | else |
| 65 | updateStone(stoneBlack, middle, middle); |
| 66 | case 6: |
| 67 | case 5: |
| 68 | if (handicap >= 6) |
| 69 | { |
| 70 | updateStone(stoneBlack, low, middle); |
| 71 | updateStone(stoneBlack, high, middle); |
| 72 | } |
| 73 | else |
| 74 | updateStone(stoneBlack, middle, middle); |
| 75 | case 4: |
| 76 | updateStone(stoneBlack, high, high); |
| 77 | case 3: |
| 78 | updateStone(stoneBlack, low, low); |
| 79 | case 2: |
| 80 | updateStone(stoneBlack, high, low); |
| 81 | updateStone(stoneBlack, low, high); |
| 82 | default: |
| 83 | break; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | } |
| 88 |