Mobile.h
00001 #include <iostream>
00002 #include <iomanip>
00003 #include <string>
00004 #include "Grid.h"
00005 
00006 using namespace std;
00007 
00008 #ifndef MOBILE_H
00009 #define MOBILE_H
00010 
00011 // forward definition for friend
00012 class Hunter;
00013 class Gridhunt;
00014 
00018 class Mobile {
00020     friend ostream& operator<< (ostream&, const Mobile&);
00021 
00022 public:
00028     Mobile(const string& name = "Some Mobile", char decal = 'x');
00030     enum Direction {
00031         N = 1, NE, E, SE, S, SW, W, NW
00032     };
00033     
00035     void say(const string&) const;
00036 
00038     bool pay(int);
00040     Coord getPosition();
00042     bool teleport();
00044     bool move(Direction);
00048     virtual void makeMove() =0;
00049 
00050     Die* getDie() const { return die; }
00051     string getName() const { return name; }
00052     int getWins() const { return wins; }
00053     char getDecal() const { return decal; }
00054     int getPoints() const { return points; }
00055     Grid* getGrid() const { return grid; }
00057     int getRound() const { return round; }
00058 
00060     static const string directionName[];
00061 
00062 private:
00063     Coord position;
00064     string name;
00065     char decal;
00066     int points;
00067     int wins;
00068     Grid *grid;
00069     Die *die;
00070     int round;
00071 
00072     void won();
00073     void resetPosition();
00074     Coord getPositionForFree() const;
00075     
00076     string getLongName() const;
00077 
00078     bool doMove(int, int);
00079 
00080     void setPoints(int points) { this->points = points; }
00081     void setGrid(Grid* grid) { this->grid = grid; }
00082     void setDie(Die* die) { this->die = die; }
00083     void setRound(int round) { this->round = round; }
00084 
00085 
00086     // Gridhunt is a friend
00087     friend class Gridhunt;
00088     // player can look at the position sometimes directly
00089     //friend int Hunter::distanceToMonster();
00090     //friend Coord Hunter::positionOfMonster();
00091     friend class Hunter;
00092 
00093 };
00094 #endif
 All Classes Files Functions Variables Enumerations Friends