summaryrefslogtreecommitdiffstats
path: root/kue/modules/8ball/8ball.h
diff options
context:
space:
mode:
Diffstat (limited to 'kue/modules/8ball/8ball.h')
-rw-r--r--kue/modules/8ball/8ball.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/kue/modules/8ball/8ball.h b/kue/modules/8ball/8ball.h
new file mode 100644
index 00000000..73ee3864
--- /dev/null
+++ b/kue/modules/8ball/8ball.h
@@ -0,0 +1,88 @@
+#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;
+
+// Possible values of _game_called
+enum gameCallType {GAME_UNCALLED, GAME_PLAYER1_STRIPES, GAME_PLAYER1_SOLIDS};
+
+
+class EightBallFactory : KLibFactory {
+ public:
+ TQObject* createObject(TQObject*, const char*, const char*, const TQStringList &);
+};
+
+class EightBall : public KueRulesEngine {
+ TQ_OBJECT
+ public:
+ EightBall(TQObject *parent, const char *name);
+ ~EightBall();
+
+ 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();
+
+ // 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
+ KuePlayer *_current_player;
+ // The current team
+ int _current_team;
+ // Who's stripes? And who's solids?
+ gameCallType _game_called;
+
+ // Have we had a successful break?
+ bool _broke;
+
+ TQString sideString();
+};
+
+
+#endif