// This may look like C code, but it is -*- C++ -*-
//
//  Copyright (c) University of Aizu 1994
//
//  [# Edit, Date, User, Module #]


// Wrappers protect against including  more than once

#ifndef Base_h
#define Base_h 1


#include <bool.h>


enum IOstatus {
  ok,         // We have read in a well-formed object.
  endOfFile,  // We reached the end of file.
  wrongObject,// We found something unexpected
              // and unread it. Try again.
  wrongData   // The data cannot possibly 
              // be an object. Something's wrong.
};

IOstatus write(IOstatus s);

//  Rudimentary error handling:
//  die a terrible death when weird things happen...
void die(char *errorlocation); 

//  die a different death when reading weird data...
void expected(char *something); 

//  Boolean type 
typedef bool Bool;
IOstatus read(Bool &b);
IOstatus write(Bool const b);

typedef int Attempts; //  jail escape attempts
typedef int Price;    //  prices
typedef int Steps;    //  steps on the board
typedef int Remaining;//  remaining houses

IOstatus read(int &i);
IOstatus write(int const i);

//  further text IO utilities.
IOstatus read(char * &word);
char *newString(char const *word);

IOstatus write(char const *word);
IOstatus writeln(char const *word = 0);
IOstatus writeEnd(void);

//  Number of houses on a property
enum Houses {none, oneHouse, twoHouses, threeHouses, fourHouses, hotel};
IOstatus read(Houses &h);
IOstatus write(Houses const h);

//  Size of monopolies, meaning properties 
//  owned by the same player
enum GroupSize {all, one, two, three};
IOstatus read(GroupSize &g);
IOstatus write(GroupSize const g);

//  Account states
enum AccountStatus {creditor, debitor};
IOstatus write(AccountStatus s);

//  Types of event cards
enum Deck {chance, community};
IOstatus read(Deck &t);
IOstatus write(Deck const t);

//  The "expect" function reads a word from the
//  inputstream, compares it to the argument, and
//  if equal, returns "ok", otherwise "unreads" the
//  word and returns "wrongObject".

IOstatus expect(char const *something);
IOstatus expectEnd(void);

class Game;

class Base {
public:
  Base(void) {}
  Base(Game* game);
  virtual ~Base(void) {}

  IOstatus read(void);
  IOstatus write(void);

  virtual IOstatus readContents(void) = 0;
  virtual IOstatus writeContents(void) = 0;
  virtual char *classname(void) = 0;

  Bool is(char* name);
  void typeCheck(Base& aBase);

protected:
  static Game* theGame;
};

#endif
// End of file

