Sync usage with man page.
[netbsd-mini2440.git] / games / dab / board.h
blobe52e4c1f023c6d519f71b54b4490fb8e4f84f303
1 /* $NetBSD: board.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
3 /*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * board.h: Board functions
36 #ifndef _H_BOARD
37 #define _H_BOARD
39 #include <stdlib.h>
41 class GAMESCREEN;
42 class PLAYER;
44 class BOARD {
45 public:
46 // Constructors and destructor
47 BOARD(size_t y, size_t x, GAMESCREEN* scrn);// For the main screen
48 BOARD(const BOARD& b); // For scratch screens
49 ~BOARD();
51 // member access
52 size_t nx(void) const { return _nx; }
53 size_t ny(void) const { return _ny; }
54 size_t tx(void) const { return _tx; }
55 size_t ty(void) const { return _ty; }
56 GAMESCREEN* getScrn(void) const { return _scrn; }
57 int& data(size_t y, size_t x) { return _b[y][x]; }
59 // Computing
60 int domove(size_t y, size_t x, int dir, char c); // Play move
61 void init(void); // Initialize a new game
62 int full(void) const; // True if no more moves
63 int bounds(size_t y, size_t x) const; // True if in bounds
65 // Screen updates
66 void paint(void) const; // Redraw screen
67 void clean(void) const; // Clear screen
68 void setpos(size_t y, size_t x) const; // move cursor to pos
69 int getmove(void) const; // Return move
70 void bell(void) const; // Beep!
71 void score(size_t i, const PLAYER& p); // Post score
72 void games(size_t i, const PLAYER& p); // Post games
73 void total(size_t i, const PLAYER& p); // Post totals
74 void ties(const PLAYER& p); // Post ties
75 void abort(const char *s, ...) const; // Algorithm error
78 private:
79 size_t _ty, _tx; // number of symbols in x and y dimension
80 size_t _ny, _nx; // number of boxes in the x and y dimension
81 int** _b; // board array of symbols
82 GAMESCREEN* _scrn; // screen access, if we have one
85 #endif