#ifndef _EIGHTBALL_H #define _EIGHTBALL_H #include #include #include "vector.h" #include "point.h" #include "rules.h" // Forward declarations of our helper classes class TQString; // Possible values of _game_called enum gameCallType {GAME_UNCALLED, GAME_PLAYER1_STRIPES, GAME_PLAYER1_SOLIDS}; class FreePlayFactory : KLibFactory { public: TQObject* createObject(TQObject*, const char*, const char*, const TQStringList &); }; class FreePlay : public TQObject, public KueRulesEngine { Q_OBJECT public: FreePlay(); ~FreePlay(); // Is the game over? bool gameIsOver() { return false; } protected slots: // Called by physics engine when a billiard is sunk void billiardSunk(unsigned int ball, unsigned int pocket); // Called by physics engine when a billiard is struck (by the cue ball or another billiard) void billiardHit(unsigned int ball1, unsigned int ball2); // Called by the physics engine when all billiards have stopped moving void motionStopped(); // Called by the interface when the user has decided on a cue location void cuePlaced(point &location); // Called by the interface when the user is deciding on a cue location void previewCuePlace(point &location); // Called by the interface after the user has decided on a hot void shotTaken(vector &velocity); private: // Ask the interface to start the shot void startShot(bool forward_only); // Ask the interface to place the cue ball void placeCueBall(); // Does a player only have an 8 ball left to shoot at? bool onlyMagicLeft(int player); // Does a player own a given ball? bool ownsBall(int player, unsigned int ball); // Is a ball solid? bool ballIsSolid(unsigned int number); // Is a ball stripped? bool ballIsStripe(unsigned int number); // Is a ball the cue ball? bool ballIsCue(unsigned int number); // Is a ball the magic ball (8)? bool ballIsMagic(unsigned int number); // Handle a player's victory void playerWins(int player); // Is this shot a scratch? bool _scratch; // First ball sunk int _first_sunk; // First ball hit int _first_hit; // The current player int _current_player; // Who's stripes? And who's solids? gameCallType _game_called; }; #endif