//****************************************************************// // // // Copyright (c) 1997. // // Dr. Michael A. Redmond // // // // This software may not be distributed further without permission from // // Dr Michael A. Redmond. // // // // This software is distributed WITHOUT ANY WARRANTY. No claims are made // // as to its functionality or purpose. // // // // Title: Tw_Game.h // Description: abstraction for twixt Game, includes board, player names, // number moves so far, whose turn it is, and how the player // moves (human or program) // Author: Dr Michael A. Redmond // // Date: 4/10/97 // // // // //****************************************************************// // tw-game.h: declaration of Tw_Game ADT // conditional compilation to avoid trying to include same thing twice #ifndef TW_GAME_H #define TW_GAME_H #include #include "point.h" #include "tw-color.h" #include "tw-peg.h" #include "tw-link.h" #include "tw-board.h" const int name_len = 20; enum play_typ {human, program}; // Tw_Game ADT: class description // Defines class and its interface to the world // implementation is in tw-game.cpp class Tw_Game { // private (by default) - put up here so compiler knows static const int max_board_size = 30; // public interface can be used by anybody public: // member functions // constructors - // first - 0 or 1 args - starts a game with a new board // unknown player names Tw_Game(int size = 20); // second - 2 or 3 args - starts a game with a new board // known player names Tw_Game(char player1[], char player2[], const int size = 20); // third - 4 args - game in progress - board known w/ // pegs, black links and white links, and board size // player names specified, along with number of moves // so far Tw_Game(Tw_Board& gameboard, char player1[], char player2[], int num_moves_so_far); // inspectors // mutators - establish new values of attributes (data members) // facilitators // run the game Tw_Color Play(); // some stream facilitators // protected interface can be used by objects that are in class, // and objects that are in a subtype class (derived class) protected: // inspectors // report if there is any winner Tw_Color WhoWon() const; // show a player name ostream& DisplayPlayerName(const int playnum, ostream& sout) const; // report whose turn it is int WhoseTurn() const; Tw_Color WhichColorsTurn() const; // report who just took a turn int WhoJustMoved() const; // mutators // increment number of moves taken so far int IncrNumMoves(); // facilitators // greet players at beginning of game void Welcome() const; // sign off at end of game void GoodBye() const; // congratulate winner void Congrats() const; // ask player for peg Tw_Peg PromptForPeg() const; // ask player if they want to place a link which has just // been made a possibility bool PromptForLinkYN(const Tw_Link& potent_link) const; // ask player for link Tw_Link PromptForLink() const; // display current situation void Display() const; // private members can only be used by other member functions and // operators of this class // typically all attributes (data members) go here private: // data members Tw_Board board; // char play1name[name_len]; // char play2name[name_len]; char * play1name; char * play2name; int num_moves_so_far; play_typ play1typ; play_typ play2typ; int max_width_search; int max_depth_search; }; // dont think I need these for Game // below overloads standard c++ operators so that they can be used // with tw_game class objects, so syntax is like with ints floats etc // // Tw_Game ADT: auxiliary operator description // // ostream& operator<<(ostream &sout, const Tw_Board &s); // istream& operator>>(istream &sin, Tw_Board &r); #endif