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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/*
* Copyright (C) 2003 Holger Bochnig <hbgg@gmx.net>
* Copyright (C) 2003-2008 the AUTHORS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* $Id: boarddim.h,v 1.15 2013/06/16 02:16:10 mdpetch Exp $
*/
#ifndef BOARDDIM_H
#define BOARDDIM_H
/* fundamental constants */
#define CHEQUER_WIDTH 6
#define DIE_WIDTH 7
#define CUBE_WIDTH 6
#define ARROW_WIDTH 3
#define HINGE_HEIGHT 12
#define HINGE_WIDTH 2
/* additional space (beyond one chequer's worth) between two points
* with 5 chequers */
#define EXTRA_HEIGHT 10
/* derived constants */
#define CHEQUER_HEIGHT CHEQUER_WIDTH
#define DIE_HEIGHT DIE_WIDTH
#define CUBE_HEIGHT CUBE_WIDTH
#define ARROW_HEIGHT ARROW_WIDTH
#define BORDER_HEIGHT (CHEQUER_HEIGHT / 2)
#define BORDER_WIDTH (CHEQUER_WIDTH / 2)
#define BAR_WIDTH (2 * CHEQUER_WIDTH)
#define BEAROFF_INSIDE CHEQUER_WIDTH
#define BEAROFF_WIDTH (BEAROFF_INSIDE + 2 * BORDER_WIDTH)
#define BOARD_WIDTH (12 * CHEQUER_WIDTH + 2 * BEAROFF_WIDTH + BAR_WIDTH)
#define BEAROFF_DIVIDER_HEIGHT CHEQUER_HEIGHT
/* the following is technically wrong - it should be 10 chequers, die/cube
* and two borders - there may be undisplayable positions otherwise */
#define BOARD_MIN_HEIGHT (11 * CHEQUER_HEIGHT + 2 * BORDER_HEIGHT)
#define BOARD_HEIGHT (BOARD_MIN_HEIGHT + EXTRA_HEIGHT)
/* more derived constants */
#define CUBE_LABEL_WIDTH (CUBE_WIDTH - 2)
#define CUBE_LABEL_HEIGHT (CUBE_HEIGHT - 2)
#define RESIGN_WIDTH CUBE_WIDTH
#define RESIGN_HEIGHT CUBE_HEIGHT
#define RESIGN_LABEL_WIDTH CUBE_LABEL_WIDTH
#define RESIGN_LABEL_HEIGHT CUBE_LABEL_HEIGHT
#define CHEQUER_LABEL_WIDTH (CHEQUER_WIDTH - 2)
#define CHEQUER_LABEL_HEIGHT (CHEQUER_HEIGHT - 2)
#define POINT_WIDTH CHEQUER_WIDTH
/* for a tall enough board, let the points extend past a stack of 5 chequers */
#if (EXTRA_HEIGHT >= (CHEQUER_HEIGHT + 4))
#define DISPLAY_POINT_EXTRA 4
#elif (EXTRA_HEIGHT >= (CHEQUER_HEIGHT + 3))
#define DISPLAY_POINT_EXTRA 3
#elif (EXTRA_HEIGHT >= (CHEQUER_HEIGHT + 2))
#define DISPLAY_POINT_EXTRA 2
#elif (EXTRA_HEIGHT >= (CHEQUER_HEIGHT + 1))
#define DISPLAY_POINT_EXTRA 1
#else
#define DISPLAY_POINT_EXTRA 0
#endif
#define DISPLAY_POINT_HEIGHT (5 * CHEQUER_HEIGHT + DISPLAY_POINT_EXTRA)
/* for HTML */
#define BEAROFF_HEIGHT (5 * CHEQUER_HEIGHT)
#define POINT_HEIGHT (5 * CHEQUER_HEIGHT)
#define BOARD_CENTER_WIDTH (6 * CHEQUER_WIDTH)
#define BOARD_CENTER_HEIGHT (BOARD_HEIGHT - 2 * (BORDER_HEIGHT + POINT_HEIGHT))
#define DISPLAY_BEAROFF_HEIGHT ((BOARD_HEIGHT - BEAROFF_DIVIDER_HEIGHT) / 2 - \
BORDER_HEIGHT)
/* where to place a chequer on the bar - x */
#define BAR_X ((BOARD_WIDTH - CHEQUER_WIDTH) / 2)
/* where to place the first player 0 chequer on the bar - y */
#define BAR_Y_0 (BOARD_HEIGHT / 2 - 16)
/* and where to place the first player 1 chequer on the bar - y */
#define BAR_Y_1 (BOARD_HEIGHT / 2 + 9)
/* where to start point x, x = 1..13 */
#define POINT_X(n) ((n < 7) ? (BOARD_WIDTH - BEAROFF_WIDTH - \
n * CHEQUER_WIDTH) : \
(n < 13) ? ((BOARD_WIDTH - BAR_WIDTH) / 2 - \
(n - 6) * CHEQUER_WIDTH) : \
(n < 19) ? (BEAROFF_WIDTH + \
(n - 13) * CHEQUER_WIDTH) : \
(BOARD_WIDTH + BAR_WIDTH) / 2 + (n - 19) * CHEQUER_WIDTH)
/* top and bottom y co-ordinates of chequers */
#define TOP_POINT_Y (BOARD_HEIGHT - BORDER_HEIGHT - CHEQUER_HEIGHT)
#define BOT_POINT_Y (BORDER_HEIGHT)
/* left and right bearoff tray coordinates */
#define BEAROFF_RIGHT_X (BOARD_WIDTH - BORDER_WIDTH - CHEQUER_WIDTH)
#define BEAROFF_LEFT_X (BORDER_WIDTH)
/* x and y coordinates of cube when not available/doubling/owned/centred */
#define NO_CUBE -32768
/* width of board between tray and bar */
#define PLAY_WIDTH (((BOARD_WIDTH - (2 * BEAROFF_WIDTH)) - BAR_WIDTH) / 2)
#define CUBE_RIGHT_X (BEAROFF_WIDTH + (PLAY_WIDTH - CUBE_WIDTH) / 2)
#define CUBE_LEFT_X (BOARD_WIDTH - (CUBE_RIGHT_X))
#define CUBE_TRAY_X (BEAROFF_LEFT_X + (BEAROFF_INSIDE - CUBE_WIDTH) / 2)
#define PLAY_HEIGHT (BOARD_HEIGHT - 2 * BORDER_HEIGHT )
#define CUBE_CENTRE_Y (BORDER_HEIGHT + (PLAY_HEIGHT - CUBE_HEIGHT) / 2)
#define CUBE_OWN_1_Y (BOARD_HEIGHT - (CUBE_HEIGHT + BORDER_HEIGHT))
#define CUBE_OWN_0_Y (BORDER_HEIGHT)
#define CUBE_RESIGN_LEFT_X (CUBE_LEFT_X - CHEQUER_WIDTH)
#define CUBE_RESIGN_RIGHT_X (CUBE_RIGHT_X + CHEQUER_WIDTH)
/* where the hinges begin - y */
#define HINGE_BOT_Y ((BOARD_HEIGHT - CUBE_HEIGHT) / 2 - \
2 * CHEQUER_HEIGHT - HINGE_HEIGHT - 1)
#define HINGE_TOP_Y ((BOARD_HEIGHT + CUBE_HEIGHT) / 2 + \
2 * CHEQUER_HEIGHT + 1)
#endif /* BOARDDIM_H */
|