summaryrefslogtreecommitdiffstats
path: root/kue/modules/9ball/9ball.h
diff options
context:
space:
mode:
Diffstat (limited to 'kue/modules/9ball/9ball.h')
-rw-r--r--kue/modules/9ball/9ball.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/kue/modules/9ball/9ball.h b/kue/modules/9ball/9ball.h
new file mode 100644
index 00000000..25a1774e
--- /dev/null
+++ b/kue/modules/9ball/9ball.h
@@ -0,0 +1,71 @@
+#ifndef _EIGHTBALL_H
+#define _EIGHTBALL_H
+
+#include <tqobject.h>
+#include <klibloader.h>
+
+#include "vector.h"
+#include "point.h"
+#include "rules.h"
+
+
+// Forward declarations of our helper classes
+class TQString;
+class KuePlayer;
+
+class NineBallFactory : KLibFactory {
+ public:
+ TQObject* createObject(TQObject*, const char*, const char*, const TQStringList &);
+};
+
+class NineBall : public KueRulesEngine {
+ TQ_OBJECT
+ public:
+ NineBall(TQObject *parent, const char *name);
+ ~NineBall();
+
+ void start();
+
+ 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();
+
+ void cuePlaced();
+ void shotTaken();
+
+ private:
+ // Ask the interface to start the shot
+ TQString startShotMessage();
+ // Ask the interface to place the cue ball
+ TQString placeCueBallMessage();
+
+ // Is a ball the cue ball?
+ bool ballIsCue(unsigned int number);
+ // Is a ball the magic ball (8)?
+ bool ballIsLowest(unsigned int number);
+
+ // Handle a player's victory
+ void playerWins();
+
+ // Is this shot a scratch?
+ bool _foul;
+ // First ball sunk
+ int _first_sunk;
+ // First ball hit
+ int _first_hit;
+
+ // The current player
+ KuePlayer *_current_player;
+ // The current team
+ int _current_team;
+
+ // Have we had a successful break?
+ bool _broke;
+};
+
+
+#endif