#ifndef WABBITH #define WABBITH #include "game.h" class wabbit { game *const g; unsigned x, y; const char c; //move calls these functions to decide who eats who. wabbit w1 will eat //wabbit w2 if w1.hungry() > w2.bitter(), i.e., if w1's hunger is //stronger than w2's bitterness. virtual bool maskable() const {return false;} //some wabbits can move over ("mask") others //move calls this function to decide which direction to move in. virtual void decide(int *dx, int *dy) const = 0; //move calls this function if this wabbit tries to move off the screen, //or bumps into another wabbit that it can neither eat nor be eaten by. //(Will also be called by manual::decide.) virtual void punish() const {} wabbit(const wabbit& another); //deliberately undefined wabbit& operator=(const wabbit& another); //ditto protected: char key() const {return g->term.key();} //called by wolf::decide //called by avoidance::decide which doesn't know its coordinates, //just the offsets it should test char get(int dx, int dy) const {return g->term.get(x+dx,y+dy);} void beep() const {g->term.beep();} //called by wolf::punish //for subclass visionary friend void difference(const wabbit *w1, const wabbit *w2, int *dx, int *dy); //used by visionary::decide typedef game::master_t::const_iterator const_iterator; const_iterator begin() const {return g->master.begin();} const_iterator end() const {return g->master.end();} public: wabbit(game *initial_g, unsigned initial_x, unsigned initial_y, char initial_c); virtual ~wabbit(); //these functions are now used by visionary::decide and its other //derived types so they must be public virtual int hungry() const = 0; virtual int bitter() const = 0; bool move(int *value, char *collisionObj); char id() const {return c;} //so game can id wabbit virtual int value() const {return 0;} //for keeping score unsigned xcord() const {return x;} unsigned ycord() const {return y;} //Functions that use the x/y or c private data members of class wabbit. friend game::master_t::value_type game::get(unsigned x, unsigned y) const; friend game::master_t::value_type game::get(unsigned x, unsigned y, unsigned* i) const; friend game::master_t::size_type game::count(char c) const; }; #endif