]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - dab/board.h
Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
[bsdgames-darwin.git] / dab / board.h
1 /* $NetBSD: board.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
2
3 /*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * board.h: Board functions
41 */
42
43 #ifndef _H_BOARD
44 #define _H_BOARD
45
46 #include <stdlib.h>
47
48 class GAMESCREEN;
49 class PLAYER;
50
51 class BOARD {
52 public:
53 // Constructors and destructor
54 BOARD(size_t y, size_t x, GAMESCREEN* scrn);// For the main screen
55 BOARD(const BOARD& b); // For scratch screens
56 ~BOARD();
57
58 // member access
59 size_t nx(void) const { return _nx; }
60 size_t ny(void) const { return _ny; }
61 size_t tx(void) const { return _tx; }
62 size_t ty(void) const { return _ty; }
63 GAMESCREEN* getScrn(void) const { return _scrn; }
64 int& data(size_t y, size_t x) { return _b[y][x]; }
65
66 // Computing
67 int domove(size_t y, size_t x, int dir, char c); // Play move
68 void init(void); // Initialize a new game
69 int full(void) const; // True if no more moves
70 int bounds(size_t y, size_t x) const; // True if in bounds
71
72 // Screen updates
73 void paint(void) const; // Redraw screen
74 void clean(void) const; // Clear screen
75 void setpos(size_t y, size_t x) const; // move cursor to pos
76 int getmove(void) const; // Return move
77 void bell(void) const; // Beep!
78 void score(size_t i, const PLAYER& p); // Post score
79 void games(size_t i, const PLAYER& p); // Post games
80 void total(size_t i, const PLAYER& p); // Post totals
81 void ties(const PLAYER& p); // Post ties
82 void abort(const char *s, ...) const; // Algorithm error
83
84
85 private:
86 size_t _ty, _tx; // number of symbols in x and y dimension
87 size_t _ny, _nx; // number of boxes in the x and y dimension
88 int** _b; // board array of symbols
89 GAMESCREEN* _scrn; // screen access, if we have one
90 };
91
92 #endif