///////////////////////////////////////////////////////////////////////////// // Name: seats.h // tag: Seat types and inline functions. // Author: David Roundy // Modified by: // Created: 1/2002 // Copyright: (c) 2002 David Roundy // Licence: GPL /* 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ///////////////////////////////////////////////////////////////////////////// #ifndef _SEATS_H_ #define _SEATS_H_ enum Seat { SOUTH=0, WEST=1, NORTH=2, EAST=3 }; inline wxString Seat2String(Seat seat) { if (seat == NORTH) return "North"; if (seat == SOUTH) return "South"; if (seat == EAST) return "East"; if (seat == WEST) return "West"; return "Error"; }; inline wxString Seat2Char(Seat seat) { if (seat == NORTH) return "N"; if (seat == SOUTH) return "S"; if (seat == EAST) return "E"; if (seat == WEST) return "W"; return "Error"; }; inline bool IsNS(Seat seat) { return !(seat & 1); } inline Seat String2Seat(wxString str) { str.MakeUpper(); if (str.StartsWith("N")) return NORTH; if (str.StartsWith("S")) return SOUTH; if (str.StartsWith("E")) return EAST; if (str.StartsWith("W")) return WEST; printf("Bad string '%s' in String2Seat\n", str.c_str()); return SOUTH; }; inline bool IsStringSeat(wxString str) { str.MakeUpper(); if (str.StartsWith("N")) return true; if (str.StartsWith("S")) return true; if (str.StartsWith("E")) return true; if (str.StartsWith("W")) return true; return false; }; inline Seat RotateSeat(Seat seat) { return (Seat)((seat + 1) % 4); }; inline Seat AcrossFrom(Seat seat) { return (Seat)(seat^2); }; #endif