summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bitmap.cpp9
-rw-r--r--bitmap.h48
-rw-r--r--deck.cpp8
-rw-r--r--deck.h70
-rw-r--r--game.cpp37
-rw-r--r--game.h106
-rw-r--r--heap.cpp12
-rw-r--r--heap.h212
-rw-r--r--history.cpp12
-rw-r--r--history.h184
-rw-r--r--i18n.cpp4
-rw-r--r--i18n.h11
-rw-r--r--setup.cpp31
-rw-r--r--setup.h59
-rw-r--r--spider.cpp102
-rw-r--r--spider.h273
-rw-r--r--tableau.cpp6
-rw-r--r--tableau.h122
18 files changed, 730 insertions, 576 deletions
diff --git a/bitmap.cpp b/bitmap.cpp
index 998d5d8..ee0a444 100644
--- a/bitmap.cpp
+++ b/bitmap.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: bitmap.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: bitmap.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "bitmap.h"
@@ -26,8 +26,10 @@
#include <vdr/osd.h>
#include <ctype.h>
+using namespace SpiderPlugin;
-/** --- class Bitmap ------------------------------------------------------- **/
+
+//--- class SpiderPlugin::Bitmap -----------------------------------------------
/** Constructor */
Bitmap::Bitmap(int width, int height) :
@@ -36,7 +38,8 @@ Bitmap::Bitmap(int width, int height) :
}
/** Constructor for a bitmap with frame */
-Bitmap::Bitmap(int width, int height, tColor frameColor, tColor backgroundColor) :
+Bitmap::Bitmap(int width, int height, tColor frameColor,
+ tColor backgroundColor) :
cBitmap(width, height, 4)
{
DrawRectangle(0, 0, width - 1, height - 1, backgroundColor);
diff --git a/bitmap.h b/bitmap.h
index a7cfa97..dd3a8c3 100644
--- a/bitmap.h
+++ b/bitmap.h
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: bitmap.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: bitmap.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_BITMAP_H
@@ -29,33 +29,39 @@
#include <vdr/osd.h>
-/** --- class Bitmap ------------------------------------------------------- **/
-
-class Bitmap : public cBitmap
+namespace SpiderPlugin
{
-public:
- /** Constructor */
- Bitmap(int width, int height);
+ //--- class SpiderPlugin::Bitmap ---------------------------------------------
+
+ /** Plugin-specific version of the bitmap class */
+ class Bitmap : public cBitmap
+ {
+ public:
+
+ /** Constructor */
+ Bitmap(int width, int height);
+
+ /** Constructor for a bitmap with frame */
+ Bitmap(int width, int height, tColor frameColor, tColor backgroundColor);
- /** Constructor for a bitmap with frame */
- Bitmap(int width, int height, tColor frameColor, tColor backgroundColor);
+ /** Constructor for a bitmap read from an xpm file */
+ Bitmap(int width, int height, const char* dir, const char* name);
- /** Constructor for a bitmap read from an xpm file */
- Bitmap(int width, int height, const char* dir, const char* name);
+ /** Constructor for a card bitmap read from an xpm file */
+ Bitmap(int width, int height, const char* dir,
+ const char* suit, const char* rank);
- /** Constructor for a card bitmap read from an xpm file */
- Bitmap(int width, int height, const char* dir,
- const char* suit, const char* rank);
+ /** Write a text into the bitmap */
+ void text(const char* text, bool centered = true);
- /** Write a text into the bitmap */
- void text(const char* text, bool centered = true);
+ /** Draw a frame into the bitmap */
+ void frame(int x1, int y1, int x2, int y2, tColor frameColor);
- /** Draw a frame into the bitmap */
- void frame(int x1, int y1, int x2, int y2, tColor frameColor);
+ /** Load a bitmap from an xpm file - taken from ElchiAIO4d patch */
+ bool loadXpm(const char* FileName, tColor NoneColor = clrTransparent);
+ };
- /** Load a bitmap from an xpm file - taken from ElchiAIO4d patch */
- bool loadXpm(const char* FileName, tColor NoneColor = clrTransparent);
-};
+} // namespace SpiderPlugin
#endif // VDR_SPIDER_BITMAP_H
diff --git a/deck.cpp b/deck.cpp
index 0537ee9..05b6e35 100644
--- a/deck.cpp
+++ b/deck.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: deck.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: deck.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "deck.h"
@@ -25,6 +25,8 @@
#include <vdr/tools.h>
#include <stdlib.h>
+using namespace Spider;
+
/** Random number 0 .. max-1 */
unsigned int rand(unsigned int max)
@@ -34,7 +36,7 @@ unsigned int rand(unsigned int max)
}
-/** --- class Deck --------------------------------------------------------- **/
+//--- class Spider::Deck -------------------------------------------------------
/** Constructor */
Deck::Deck(int cards, int suits, int decks) :
@@ -73,7 +75,7 @@ void Deck::shuffle()
}
-/** --- class Card --------------------------------------------------------- **/
+//--- class Spider::Card -------------------------------------------------------
/** Constructor */
Card::Card(int s, int r)
diff --git a/deck.h b/deck.h
index bd2d6db..5d0ea68 100644
--- a/deck.h
+++ b/deck.h
@@ -17,55 +17,61 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: deck.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: deck.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_DECK_H
#define VDR_SPIDER_DECK_H
#include "spider.h"
-class Card;
-typedef Array<Card> Cards;
-/** --- class Deck --------------------------------------------------------- **/
-
-class Deck
+namespace Spider
{
-protected:
- Cards allCards;
-public:
- int cardsInSuit;
- int suitCount;
- int deckCount;
+ class Card;
+ typedef Array<Card> Cards;
- /** Constructor */
- Deck(int cards, int suits, int decks);
- /** Current count of cards */
- int count() const;
+ //--- class Spider::Deck -----------------------------------------------------
- /** Card in deck */
- const Card& card(int position) const;
+ class Deck
+ {
+ protected:
+ Cards allCards;
+ public:
+ int cardsInSuit;
+ int suitCount;
+ int deckCount;
- /** Shuffle the deck */
- void shuffle();
-};
+ /** Constructor */
+ Deck(int cards, int suits, int decks);
+ /** Current count of cards */
+ int count() const;
-/** --- class Card --------------------------------------------------------- **/
+ /** Card in deck */
+ const Card& card(int position) const;
-class Card
-{
-public:
- int suit;
- int rank;
+ /** Shuffle the deck */
+ void shuffle();
+ };
+
+
+ //--- class Spider::Card -----------------------------------------------------
+
+ class Card
+ {
+ public:
+ int suit;
+ int rank;
+
+ /** Constructor */
+ Card(int s = -1, int r = -1);
- /** Constructor */
- Card(int s = -1, int r = -1);
+ /** Matches this card to an other card? */
+ bool matchesTo(const Card& other) const;
+ };
- /** Matches this card to an other card? */
- bool matchesTo(const Card& other) const;
-};
+} // namespace Spider
#endif // VDR_SPIDER_DECK_H
diff --git a/game.cpp b/game.cpp
index 61ba151..3eafd69 100644
--- a/game.cpp
+++ b/game.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: game.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: game.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "game.h"
@@ -31,8 +31,11 @@
#include <vdr/osdbase.h>
#include <vdr/osd.h>
+using namespace SpiderPlugin;
+using namespace Spider;
-// Defintions for bitmaps
+
+// Definitions for bitmaps
const int cursorWidth = 16;
const int cursorHeight = 22;
const int cardWidth = 71;
@@ -53,10 +56,10 @@ Bitmap* frame = NULL;
Bitmap* cards[suitCount][rankCount];
-/** --- class SpiderGame --------------------------------------------------- **/
+//--- class SpiderPlugin::Game -------------------------------------------------
/** Constructor */
-SpiderGame::SpiderGame(const SpiderSetup& setup, const char* confdir) :
+Game::Game(const SetupData& setup, const char* confdir) :
cOsdObject(true), setup(setup), confdir(confdir)
{
width = 504;
@@ -75,7 +78,7 @@ SpiderGame::SpiderGame(const SpiderSetup& setup, const char* confdir) :
}
/** Destructor */
-SpiderGame::~SpiderGame()
+Game::~Game()
{
delete deck;
delete tableau;
@@ -91,7 +94,7 @@ SpiderGame::~SpiderGame()
}
/** Display the game on the OSD */
-void SpiderGame::Show()
+void Game::Show()
{
osd = cOsdProvider::NewOsd(0, 0);
if (osd)
@@ -104,7 +107,7 @@ void SpiderGame::Show()
}
/** Process user events */
-eOSState SpiderGame::ProcessKey(eKeys key)
+eOSState Game::ProcessKey(eKeys key)
{
eOSState state = cOsdObject::ProcessKey(key);
if (state == osUnknown)
@@ -232,7 +235,7 @@ eOSState SpiderGame::ProcessKey(eKeys key)
}
/** Start a new game */
-void SpiderGame::start()
+void Game::start()
{
// Load bitmaps
if (cursor == NULL)
@@ -254,7 +257,7 @@ void SpiderGame::start()
int deckCount, dealCount, pileCount;
- if (setup.variation == SpiderSetup::Mini)
+ if (setup.variation == SetupData::Mini)
{
deckCount = 1;
dealCount = 4;
@@ -276,7 +279,7 @@ void SpiderGame::start()
}
/** Paint all pieces of the game */
-void SpiderGame::paint()
+void Game::paint()
{
int x1 = xPos;
int x2 = xPos + width - 1;
@@ -322,7 +325,7 @@ void SpiderGame::paint()
}
/** Paint the pack */
-void SpiderGame::paintPack()
+void Game::paintPack()
{
int packX = xPos + 1;
int packY = yPos + 1;
@@ -335,7 +338,7 @@ void SpiderGame::paintPack()
}
/** Paint a final heap */
-void SpiderGame::paintFinal(unsigned int f)
+void Game::paintFinal(unsigned int f)
{
int offset = tableau->piles.size() - tableau->finals.size();
int finalX = xPos + 1 + (f + offset) * (cardWidth + xDist);
@@ -347,7 +350,7 @@ void SpiderGame::paintFinal(unsigned int f)
}
/** Paint a pile */
-void SpiderGame::paintPile(unsigned int p)
+void Game::paintPile(unsigned int p)
{
int pileX = xPos + 1 + p * (cardWidth + xDist);
int pileY = yPos + 1 + cardHeight + 1;
@@ -376,7 +379,7 @@ void SpiderGame::paintPile(unsigned int p)
}
/** Paint the cursor onto a card */
-void SpiderGame::paintCursor(int x, int y)
+void Game::paintCursor(int x, int y)
{
int x0 = x + (cardWidth - cursorWidth) / 2;
int y0 = y + (cardHeight - cursorHeight) / 2;
@@ -390,19 +393,19 @@ void SpiderGame::paintCursor(int x, int y)
}
/** Paint an empty card frame */
-void SpiderGame::paintFrame(int x, int y)
+void Game::paintFrame(int x, int y)
{
osd->DrawBitmap(x, y, *frame);
}
/** Paint a card back */
-void SpiderGame::paintBack(int x, int y)
+void Game::paintBack(int x, int y)
{
osd->DrawBitmap(x, y, *back);
}
/** Paint a card */
-void SpiderGame::paintCard(int x, int y, const Card& card)
+void Game::paintCard(int x, int y, const Card& card)
{
osd->DrawBitmap(x, y, *cards[card.suit][card.rank]);
}
diff --git a/game.h b/game.h
index 84a18d4..ec054bb 100644
--- a/game.h
+++ b/game.h
@@ -17,81 +17,87 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: game.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: game.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_GAME_H
#define VDR_SPIDER_GAME_H
#include "spider.h"
-class SpiderSetup;
-class Deck;
-class Tableau;
-class Card;
-class Bitmap;
+namespace Spider { class Deck; class Tableau; class Card; }
#include <vdr/config.h>
#include <vdr/osdbase.h>
#include <vdr/osd.h>
-/** --- class SpiderGame --------------------------------------------------- **/
-
-class SpiderGame : public cOsdObject
+namespace SpiderPlugin
{
-private:
- const SpiderSetup& setup;
- const char* confdir;
- int width, height;
- int xPos, yPos;
- int xDist, yDist;
- cOsd* osd;
- Bitmap* info;
- const char* infoText;
- Deck* deck;
- Tableau* tableau;
- unsigned int currentPile;
- enum { cursorOnPile, selectedPile, cursorOnPack, gameOver } status;
+ class SetupData;
+ class Bitmap;
+
+
+ //--- class SpiderPlugin::Game -----------------------------------------------
+
+ /** Main menu of the plugin */
+ class Game : public cOsdObject
+ {
+ const SetupData& setup;
+ const char* confdir;
+ int width, height;
+ int xPos, yPos;
+ int xDist, yDist;
+ cOsd* osd;
+ Bitmap* info;
+ const char* infoText;
+ Spider::Deck* deck;
+ Spider::Tableau* tableau;
+ unsigned int currentPile;
+ enum { cursorOnPile, selectedPile, cursorOnPack, gameOver } status;
+
+ public:
+
+ /** Constructor */
+ Game(const SetupData& setup, const char* confdir);
- /** Start a new game */
- void start();
+ /** Destructor */
+ virtual ~Game();
- /** Paint all pieces of the game */
- void paint();
+ /** Display the game on the OSD */
+ virtual void Show();
- /** Paint the cursor onto a card */
- void paintCursor(int x, int y);
+ /** Process user events */
+ virtual eOSState ProcessKey(eKeys key);
- /** Paint the pack */
- void paintPack();
+ private:
- /** Paint a final heap */
- void paintFinal(unsigned int f);
+ /** Start a new game */
+ void start();
- /** Paint a pile */
- void paintPile(unsigned int p);
+ /** Paint all pieces of the game */
+ void paint();
- /** Paint an empty card frame */
- void paintFrame(int x, int y);
+ /** Paint the cursor onto a card */
+ void paintCursor(int x, int y);
- /** Paint a card back */
- void paintBack(int x, int y);
+ /** Paint the pack */
+ void paintPack();
- /** Paint a card */
- void paintCard(int x, int y, const Card& card);
+ /** Paint a final heap */
+ void paintFinal(unsigned int f);
-public:
+ /** Paint a pile */
+ void paintPile(unsigned int p);
- /** Constructor */
- SpiderGame(const SpiderSetup& setup, const char* confdir);
+ /** Paint an empty card frame */
+ void paintFrame(int x, int y);
- /** Destructor */
- virtual ~SpiderGame();
+ /** Paint a card back */
+ void paintBack(int x, int y);
- /** Display the game on the OSD */
- virtual void Show();
+ /** Paint a card */
+ void paintCard(int x, int y, const Spider::Card& card);
+ };
- /** Process user events */
- virtual eOSState ProcessKey(eKeys key);
-};
+} // namespace SpiderPlugin
#endif // VDR_SPIDER_GAME_H
diff --git a/heap.cpp b/heap.cpp
index d15b9c5..9a61084 100644
--- a/heap.cpp
+++ b/heap.cpp
@@ -17,14 +17,16 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: heap.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: heap.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "heap.h"
#include "deck.h"
+using namespace Spider;
-/** --- base class Heap ---------------------------------------------------- **/
+
+//--- virtual base class Spider::Heap ------------------------------------------
/** Constructor */
Heap::Heap(unsigned int maxCards)
@@ -106,7 +108,7 @@ void Heap::resetChanged()
}
-/** --- class Pack --------------------------------------------------------- **/
+//--- class Spider::Pack -------------------------------------------------------
/** Constructor */
Pack::Pack(const Deck& deck) :
@@ -149,7 +151,7 @@ void Pack::takeBackDeal(Piles& piles)
}
-/** --- class Pile --------------------------------------------------------- **/
+//--- class Spider::Pile -------------------------------------------------------
/** Constructor */
Pile::Pile(const Deck& deck) :
@@ -294,7 +296,7 @@ int Pile::cardsChanged() const
}
-/** --- class FinalHeap ---------------------------------------------------- **/
+//--- class Spider::FinalHeap --------------------------------------------------
/** Constructor */
FinalHeap::FinalHeap(const Deck& deck) :
diff --git a/heap.h b/heap.h
index a5f4700..1ed5f66 100644
--- a/heap.h
+++ b/heap.h
@@ -17,162 +17,168 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: heap.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: heap.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_HEAP_H
#define VDR_SPIDER_HEAP_H
#include "spider.h"
-class Card;
-typedef Vector<Card> CardStack;
-class Deck;
-class Pile;
-typedef Array<Pile*> Piles;
-/** --- base class Heap ---------------------------------------------------- **/
-
-class Heap
+namespace Spider
{
-protected:
- CardStack allCards;
- unsigned int maxCount;
- bool emptyChanged;
+ class Card;
+ typedef Vector<Card> CardStack;
+ class Deck;
+ class Pile;
+ typedef Array<Pile*> Piles;
- /** Constructor */
- Heap(unsigned int maxCards);
- /** Destructor */
- virtual ~Heap();
+ //--- virtual base class Spider::Heap ----------------------------------------
-public:
+ class Heap
+ {
+ protected:
+ CardStack allCards;
+ unsigned int maxCount;
+ bool emptyChanged;
- /** Current count of cards */
- int count() const;
+ /** Constructor */
+ Heap(unsigned int maxCards);
- /** Card in heap */
- const Card& card(int position) const;
+ /** Destructor */
+ virtual ~Heap();
- /** Top card of the heap */
- const Card& top() const;
+ public:
- /** Add a new card */
- virtual void add(const Card& card);
+ /** Current count of cards */
+ int count() const;
- /** Remove the top card */
- virtual void remove();
+ /** Card in heap */
+ const Card& card(int position) const;
- /** Move some matching cards to an other heap */
- void moveTo(Heap* other, int countToMove);
+ /** Top card of the heap */
+ const Card& top() const;
- /** Is the heap empty? */
- bool empty() const;
+ /** Add a new card */
+ virtual void add(const Card& card);
- /** Is the heap changed? */
- bool changed() const;
+ /** Remove the top card */
+ virtual void remove();
- /** Reset changed property */
- void resetChanged();
-};
+ /** Move some matching cards to an other heap */
+ void moveTo(Heap* other, int countToMove);
+ /** Is the heap empty? */
+ bool empty() const;
-/** --- class Pack --------------------------------------------------------- **/
+ /** Is the heap changed? */
+ bool changed() const;
-class Pack : public Heap
-{
-public:
+ /** Reset changed property */
+ void resetChanged();
+ };
- /** Constructor */
- Pack(const Deck& deck);
- /** First initial deal of a game */
- void initialDeal(Piles& piles, int rows, Piles& extra);
+ //--- class Spider::Pack -----------------------------------------------------
- /** Deal one row to the piles */
- void deal(Piles& piles);
+ class Pack : public Heap
+ {
+ public:
- /** Cancel the deal */
- void takeBackDeal(Piles& piles);
-};
+ /** Constructor */
+ Pack(const Deck& deck);
+ /** First initial deal of a game */
+ void initialDeal(Piles& piles, int rows, Piles& extra);
-/** --- class Pile --------------------------------------------------------- **/
+ /** Deal one row to the piles */
+ void deal(Piles& piles);
-class Pile : public Heap
-{
-protected:
- int currentOpen;
- int currentMatching;
- int currentSelected;
- int currentChanged;
+ /** Cancel the deal */
+ void takeBackDeal(Piles& piles);
+ };
-public:
- /** Constructor */
- Pile(const Deck& deck);
+ //--- class Spider::Pile -----------------------------------------------------
- /** Add a new card */
- void add(const Card& card);
+ class Pile : public Heap
+ {
+ protected:
+ int currentOpen;
+ int currentMatching;
+ int currentSelected;
+ int currentChanged;
- /** Remove top card from pile */
- void remove();
+ public:
- /** Turn all open top cards or rather open the top card */
- void turn();
+ /** Constructor */
+ Pile(const Deck& deck);
- /** Current count of open cards */
- int open() const;
+ /** Add a new card */
+ void add(const Card& card);
- /** Current count of matching cards */
- int getMatching() const;
+ /** Remove top card from pile */
+ void remove();
- /** The two open top cards are matching */
- bool topCardsMatches() const;
+ /** Turn all open top cards or rather open the top card */
+ void turn();
- /** Current count of selected cards */
- int selected() const;
+ /** Current count of open cards */
+ int open() const;
- /** Select up to max matching cards on the end of this pile */
- void select(int max = 0);
+ /** Current count of matching cards */
+ int getMatching() const;
- /** Unselect this pile */
- void unselect();
+ /** The two open top cards are matching */
+ bool topCardsMatches() const;
- /** Adapt the selection to match an other pile */
- void adaptSelectionTo(const Pile* other);
+ /** Current count of selected cards */
+ int selected() const;
- /** Matches the selection to an other pile? */
- bool selectionMatchesTo(const Pile* other, bool matchSuit = false) const;
+ /** Select up to max matching cards on the end of this pile */
+ void select(int max = 0);
- /** Is the heap changed? */
- bool changed() const;
+ /** Unselect this pile */
+ void unselect();
- /** Reset changed property */
- void resetChanged();
+ /** Adapt the selection to match an other pile */
+ void adaptSelectionTo(const Pile* other);
- /** How many cards are changed? */
- int cardsChanged() const;
-};
+ /** Matches the selection to an other pile? */
+ bool selectionMatchesTo(const Pile* other, bool matchSuit = false) const;
+ /** Is the heap changed? */
+ bool changed() const;
-/** --- class FinalHeap ---------------------------------------------------- **/
+ /** Reset changed property */
+ void resetChanged();
-class FinalHeap : public Heap
-{
-private:
- bool bonus;
+ /** How many cards are changed? */
+ int cardsChanged() const;
+ };
+
+
+ //--- class Spider::FinalHeap ------------------------------------------------
+
+ class FinalHeap : public Heap
+ {
+ private:
+ bool bonus;
+
+ public:
-public:
+ /** Constructor */
+ FinalHeap(const Deck& deck);
- /** Constructor */
- FinalHeap(const Deck& deck);
+ /** Set bonus of the final heap */
+ void setBonus(bool newBonus);
- /** Set bonus of the final heap */
- void setBonus(bool newBonus);
+ /** Has this final heap bonus? */
+ bool getBonus() const;
+ };
- /** Has this final heap bonus? */
- bool getBonus() const;
-};
+} // namespace Spider
#endif // VDR_SPIDER_HEAP_H
diff --git a/history.cpp b/history.cpp
index 745dc3e..aee51bf 100644
--- a/history.cpp
+++ b/history.cpp
@@ -17,15 +17,17 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: history.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: history.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "history.h"
#include "deck.h"
#include "heap.h"
+using namespace Spider;
-/** --- class History ------------------------------------------------------ **/
+
+//--- class Spider::History ----------------------------------------------------
/** Constructor */
History::History()
@@ -90,7 +92,7 @@ bool History::movesToExecute()
}
-/** --- class DealMove ----------------------------------------------------- **/
+//--- class Spider::DealMove ---------------------------------------------------
/** Constructor */
DealMove::DealMove(Pack* s, Piles& d) :
@@ -111,7 +113,7 @@ void DealMove::takeBack()
}
-/** --- class NormalMove --------------------------------------------------- **/
+//--- class Spider::NormalMove -------------------------------------------------
/** Constructor */
NormalMove::NormalMove(Pile* s, Pile* d, int c, bool t) :
@@ -136,7 +138,7 @@ void NormalMove::takeBack()
}
-/** --- class FinalMove ---------------------------------------------------- **/
+//--- class Spider::FinalMove --------------------------------------------------
/** Constructor */
FinalMove::FinalMove(Pile* s, FinalHeap* d, int c, bool t, bool b) :
diff --git a/history.h b/history.h
index 68c755d..18ac64f 100644
--- a/history.h
+++ b/history.h
@@ -17,139 +17,145 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: history.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: history.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_HISTORY_H
#define VDR_SPIDER_HISTORY_H
#include "spider.h"
-class Pack;
-class Pile;
-typedef Array<Pile*> Piles;
-class FinalHeap;
-class Move;
-typedef Vector<Move*> Moves;
-/** --- class History ------------------------------------------------------ **/
-
-class History
+namespace Spider
{
-private:
- Moves history;
- unsigned int executed;
+ class Pack;
+ class Pile;
+ typedef Array<Pile*> Piles;
+ class FinalHeap;
+ class Move;
+ typedef Vector<Move*> Moves;
-public:
- /** Constructor */
- History();
+ //--- class Spider::History --------------------------------------------------
- /** Destructor */
- ~History();
+ class History
+ {
+ private:
+ Moves history;
+ unsigned int executed;
- /** Current move in the history */
- Move* current();
+ public:
- /** Add a new move */
- void add(Move* move);
+ /** Constructor */
+ History();
- /** Set previous move as current */
- void backward();
+ /** Destructor */
+ ~History();
- /** Set next move as current */
- void forward();
+ /** Current move in the history */
+ Move* current();
- /** Are there executed moves in the history */
- bool movesExecuted();
+ /** Add a new move */
+ void add(Move* move);
- /** Are there moves to execute in the history */
- bool movesToExecute();
-};
+ /** Set previous move as current */
+ void backward();
+ /** Set next move as current */
+ void forward();
-/** --- base class Move ---------------------------------------------------- **/
+ /** Are there executed moves in the history */
+ bool movesExecuted();
-class Move
-{
-public:
+ /** Are there moves to execute in the history */
+ bool movesToExecute();
+ };
- /** Destructor */
- virtual ~Move() {};
- /** Do the move */
- virtual void execute() = 0;
+ //--- class Spider::Move -----------------------------------------------------
- /** Redo the move */
- virtual void takeBack() = 0;
-};
+ class Move
+ {
+ public:
+ /** Destructor */
+ virtual ~Move() {};
-/** --- class DealMove ----------------------------------------------------- **/
+ /** Do the move */
+ virtual void execute() = 0;
-class DealMove : public Move
-{
-private:
- Pack* source;
- Piles& destination;
+ /** Redo the move */
+ virtual void takeBack() = 0;
+ };
-public:
- /** Constructor */
- DealMove(Pack* s, Piles& d);
+ //--- class Spider::DealMove -------------------------------------------------
- /** Do the move */
- void execute();
+ class DealMove : public Move
+ {
+ private:
+ Pack* source;
+ Piles& destination;
- /** Redo the move */
- void takeBack();
-};
+ public:
+ /** Constructor */
+ DealMove(Pack* s, Piles& d);
-/** --- class NormalMove --------------------------------------------------- **/
+ /** Do the move */
+ void execute();
-class NormalMove : public Move
-{
-private:
- Pile* source;
- Pile* destination;
- int count;
- bool turn;
+ /** Redo the move */
+ void takeBack();
+ };
-public:
- /** Constructor */
- NormalMove(Pile* s, Pile* d, int c, bool t);
+ //--- class Spider::NormalMove -----------------------------------------------
- /** Do the move */
- void execute();
+ class NormalMove : public Move
+ {
+ private:
+ Pile* source;
+ Pile* destination;
+ int count;
+ bool turn;
- /** Redo the move */
- void takeBack();
-};
+ public:
+ /** Constructor */
+ NormalMove(Pile* s, Pile* d, int c, bool t);
-/** --- class FinalMove ---------------------------------------------------- **/
+ /** Do the move */
+ void execute();
-class FinalMove : public Move
-{
-private:
- Pile* source;
- FinalHeap* destination;
- int count;
- bool turn;
- bool bonus;
+ /** Redo the move */
+ void takeBack();
+ };
+
+
+ //--- class Spider::FinalMove ------------------------------------------------
+
+ class FinalMove : public Move
+ {
+ private:
+ Pile* source;
+ FinalHeap* destination;
+ int count;
+ bool turn;
+ bool bonus;
+
+ public:
-public:
+ /** Constructor */
+ FinalMove(Pile* s, FinalHeap* d, int c, bool t, bool b);
- /** Constructor */
- FinalMove(Pile* s, FinalHeap* d, int c, bool t, bool b);
+ /** Do the move */
+ void execute();
- /** Do the move */
- void execute();
+ /** Redo the move */
+ void takeBack();
+ };
- /** Redo the move */
- void takeBack();
-};
+} // namespace Spider
#endif // VDR_SPIDER_HISTORY_H
diff --git a/i18n.cpp b/i18n.cpp
index d90e538..cfcf1e3 100644
--- a/i18n.cpp
+++ b/i18n.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: i18n.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: i18n.cpp 95 2007-09-21 23:01:10Z tom $
*
*
* Translations provided by:
@@ -30,7 +30,7 @@
#include <vdr/config.h>
-const tI18nPhrase Phrases[] = {
+const tI18nPhrase SpiderPlugin::Phrases[] = {
{ "Spider Arachnid", // English
"Spider Arachnid", // Deutsch / German
"", // Slovenski / Slovenian
diff --git a/i18n.h b/i18n.h
index 13b28ce..8f47922 100644
--- a/i18n.h
+++ b/i18n.h
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: i18n.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: i18n.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_I18N_H
@@ -25,7 +25,14 @@
#include "spider.h"
#include <vdr/i18n.h>
+#include <vdr/config.h>
-extern const tI18nPhrase Phrases[];
+
+namespace SpiderPlugin
+{
+
+ extern const tI18nPhrase Phrases[];
+
+} // namespace SpiderPlugin
#endif // VDR_SPIDER_I18N_H
diff --git a/setup.cpp b/setup.cpp
index f59ca5d..672e782 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -17,22 +17,33 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: setup.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: setup.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "setup.h"
#include "i18n.h"
#include <strings.h>
+using namespace SpiderPlugin;
-/** --- class SpiderSetup -------------------------------------------------- **/
-SpiderSetup::SpiderSetup()
+//--- class SpiderPlugin::SetupData --------------------------------------------
+
+/** Constructor
+ *
+ * Initialize the setup parameters of the plugin with standard values.
+ */
+SetupData::SetupData()
{
variation = Mini;
}
-bool SpiderSetup::parse(const char* name, const char* value)
+/** Parse the setup parameters of the plugin.
+ *
+ * This method is called for each setup parameter the plugin has previously
+ * stored in the global setup data.
+ */
+bool SetupData::parse(const char* name, const char* value)
{
if (!strcasecmp(name, "Variation"))
variation = atoi(value);
@@ -42,9 +53,10 @@ bool SpiderSetup::parse(const char* name, const char* value)
}
-/** --- class SpiderSetupMenu ---------------------------------------------- **/
+//--- class SpiderPlugin::SetupPage --------------------------------------------
-SpiderSetupMenu::SpiderSetupMenu(SpiderSetup& setup) :
+/** Constructor */
+SetupPage::SetupPage(SetupData& setup) :
setup(setup), data(setup)
{
variationTexts[0] = tr("Mini (one deck)");
@@ -53,7 +65,12 @@ SpiderSetupMenu::SpiderSetupMenu(SpiderSetup& setup) :
2, variationTexts));
}
-void SpiderSetupMenu::Store()
+/** Store the setup parameters of the plugin.
+ *
+ * The setup parameters of the plugin are stored into the global setup data
+ * file.
+ */
+void SetupPage::Store()
{
setup = data;
SetupStore("Variation", setup.variation);
diff --git a/setup.h b/setup.h
index b032508..0f3bf2b 100644
--- a/setup.h
+++ b/setup.h
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: setup.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: setup.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_SETUP_H
@@ -27,31 +27,46 @@
#include <vdr/menuitems.h>
-/** --- class SpiderSetup -------------------------------------------------- **/
-
-class SpiderSetup
+namespace SpiderPlugin
{
-public:
- typedef enum { Mini, Normal } Variations;
- int variation;
- SpiderSetup();
- bool parse(const char* name, const char* value);
-};
+ //--- class SpiderPlugin::SetupData ------------------------------------------
+ /** Setup parameters of the plugin */
+ class SetupData
+ {
+ public:
+ typedef enum { Mini, Normal } Variations;
+ int variation;
-/** --- class SpiderSetupMenu ---------------------------------------------- **/
+ /** Constructor */
+ SetupData();
-class SpiderSetupMenu : public cMenuSetupPage
-{
-private:
- const char* variationTexts[2];
- SpiderSetup& setup;
- SpiderSetup data;
-protected:
- virtual void Store();
-public:
- SpiderSetupMenu(SpiderSetup& setup);
-};
+ /** Parse the setup parameters of the plugin. */
+ bool parse(const char* name, const char* value);
+ };
+
+
+ //--- class SpiderPlugin::SetupPage ------------------------------------------
+
+ /** Setup menu page to adjust the setup parameters of the plugin */
+ class SetupPage : public cMenuSetupPage
+ {
+ const char* variationTexts[2];
+ SetupData& setup;
+ SetupData data;
+
+ public:
+
+ /** Constructor */
+ SetupPage(SetupData& setup);
+
+ protected:
+
+ /** Store the setup parameters of the plugin. */
+ virtual void Store();
+ };
+
+} // namespace SpiderPlugin
#endif // VDR_SPIDER_SETUP_H
diff --git a/spider.cpp b/spider.cpp
index 0c8be2b..75e6d53 100644
--- a/spider.cpp
+++ b/spider.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: spider.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: spider.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "spider.h"
@@ -27,46 +27,96 @@
#include <vdr/plugin.h>
-static const char* VERSION = "0.1.4";
-static const char* DESCRIPTION = "Spider Arachnid - the best patience game";
-static const char* MAINMENUENTRY = "Spider Arachnid";
+/** 'Spider Arachnid' is a VDR plugin implementation of a patience game. */
+namespace SpiderPlugin
+{
+ /** Version number of the plugin */
+ static const char* VERSION = "0.1.4";
-/** --- class SpiderPlugin ------------------------------------------------- **/
+ /** Short description of the plugin's purpose */
+ static const char* DESCRIPTION = "Spider Arachnid - the best patience game";
-class SpiderPlugin : public cPlugin
-{
-private:
- SpiderSetup setup;
-public:
- virtual const char* Version() { return VERSION; }
- virtual const char* Description() { return tr(DESCRIPTION); }
- virtual bool Start();
- virtual const char* MainMenuEntry() { return tr(MAINMENUENTRY); }
- virtual cOsdObject* MainMenuAction();
- virtual cMenuSetupPage* SetupMenu();
- virtual bool SetupParse(const char* name, const char* value);
-};
-
-bool SpiderPlugin::Start()
+ /** Name of the entry in VDR's main menu */
+ static const char* MAINMENUENTRY = "Spider Arachnid";
+
+
+ //--- class SpiderPlugin::Plugin ---------------------------------------------
+
+ /** Main class of the VDR plugin 'Spider' */
+ class Plugin : public cPlugin
+ {
+ SetupData setup;
+
+ public:
+
+ /** Version number of the plugin */
+ virtual const char* Version() { return VERSION; }
+
+ /** Localized short description of the plugin's purpose */
+ virtual const char* Description() { return tr(DESCRIPTION); }
+
+ /** Perform the startup actions of the plugin. */
+ virtual bool Start();
+
+ /** Localized name of the entry in VDR's main menu */
+ virtual const char* MainMenuEntry() { return tr(MAINMENUENTRY); }
+
+ /** OSD object that shows the plugin's main menu */
+ virtual cOsdObject* MainMenuAction();
+
+ /** Setup menu page to adjust the setup parameters of the plugin */
+ virtual cMenuSetupPage* SetupMenu();
+
+ /** Parse the setup parameters of the plugin. */
+ virtual bool SetupParse(const char* name, const char* value);
+ };
+
+} // namespace SpiderPlugin
+
+
+using namespace SpiderPlugin;
+
+
+//--- class SpiderPlugin::Plugin -----------------------------------------------
+
+/** Perform the startup actions of the plugin.
+ *
+ * This method is called once at VDR's startup.
+ */
+bool Plugin::Start()
{
RegisterI18n(Phrases);
return true;
}
-cOsdObject* SpiderPlugin::MainMenuAction()
+/** OSD object that shows the plugin's main menu
+ *
+ * This method is called every time the plugin's main menu entry is selected.
+ */
+cOsdObject* Plugin::MainMenuAction()
{
- return new SpiderGame(setup, ConfigDirectory(Name()));
+ return new Game(setup, ConfigDirectory(Name()));
}
-cMenuSetupPage* SpiderPlugin::SetupMenu()
+/** Setup menu page to adjust the setup parameters of the plugin
+ *
+ * This method is called every time the plugin's setup menu entry is selected.
+ */
+cMenuSetupPage* Plugin::SetupMenu()
{
- return new SpiderSetupMenu(setup);
+ return new SetupPage(setup);
}
-bool SpiderPlugin::SetupParse(const char* name, const char* value)
+/** Parse the setup parameters of the plugin.
+ *
+ * This method is called for each setup parameter the plugin has previously
+ * stored in the global setup data.
+ */
+bool Plugin::SetupParse(const char* name, const char* value)
{
return setup.parse(name, value);
}
-VDRPLUGINCREATOR(SpiderPlugin); // Don't touch this!
+/** "Magic" hook that allows VDR to load the plugin into its memory */
+VDRPLUGINCREATOR(Plugin); // Don't touch this!
diff --git a/spider.h b/spider.h
index 8228fae..c4c4c9c 100644
--- a/spider.h
+++ b/spider.h
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: spider.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: spider.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_H
@@ -28,164 +28,179 @@
#ifdef USE_TEMPLATES_FROM_STL
#include <vector>
-template <class T>
-class Array : public std::vector<T>
+
+namespace Spider
{
-public:
- Array(int length) : std::vector<T>(length) {}
-};
-template <class T> class Vector : public std::vector<T> {};
+ //--- template class Array ---------------------------------------------------
-#else // use own templates
+ template <class T>
+ class Array : public std::vector<T>
+ {
+ public:
+ Array(int length) : std::vector<T>(length) {}
+ };
+
+ //--- template class Vector --------------------------------------------------
-/** --- template class Array ----------------------------------------------- **/
+ template <class T> class Vector : public std::vector<T> {};
-template <class T>
-class Array
+} // namespace Spider
+
+#else // use own templates
+
+namespace Spider
{
-protected:
- T* array;
- int count;
-public:
+ //--- template class Array ---------------------------------------------------
- /** Constructor */
- Array(int length)
+ template <class T>
+ class Array
{
- array = new T[length];
- count = length;
- }
+ protected:
+ T* array;
+ int count;
+ public:
- /** Destructor */
- ~Array()
- {
- delete[] array;
- }
+ /** Constructor */
+ Array(int length)
+ {
+ array = new T[length];
+ count = length;
+ }
- /** Reference to an item of the array */
- T& operator[](int p)
- {
- return array[p];
- }
+ /** Destructor */
+ ~Array()
+ {
+ delete[] array;
+ }
- /** Reference to an item of the array */
- const T& operator[](int p) const
- {
- return array[p];
- }
+ /** Reference to an item of the array */
+ T& operator[](int p)
+ {
+ return array[p];
+ }
- /** Length of the array */
- unsigned int size() const
- {
- return count;
- }
+ /** Reference to an item of the array */
+ const T& operator[](int p) const
+ {
+ return array[p];
+ }
- /** Is the array empty? */
- bool empty() const
- {
- return count == 0;
- }
-};
+ /** Length of the array */
+ unsigned int size() const
+ {
+ return count;
+ }
+ /** Is the array empty? */
+ bool empty() const
+ {
+ return count == 0;
+ }
+ };
-/** --- template class Vector ---------------------------------------------- **/
-template <class T>
-class Vector
-{
-protected:
- T* vector;
- int max;
- int count;
- int steps;
-
- /** Resize the vector to the new length */
- void resize(int m)
+ //--- template class Vector --------------------------------------------------
+
+ template <class T>
+ class Vector
{
- if (m < steps)
- m = steps;
- else
- m = ((m - 1) / steps + 1) * steps;
- if (m != max)
- {
- T* v = new T[m];
- for (int i = 0; i < count; ++i)
- v[i] = vector[i];
- delete[] vector;
- vector = v;
- max = m;
+ protected:
+ T* vector;
+ int max;
+ int count;
+ int steps;
+
+ /** Resize the vector to the new length */
+ void resize(int m)
+ {
+ if (m < steps)
+ m = steps;
+ else
+ m = ((m - 1) / steps + 1) * steps;
+ if (m != max)
+ {
+ T* v = new T[m];
+ for (int i = 0; i < count; ++i)
+ v[i] = vector[i];
+ delete[] vector;
+ vector = v;
+ max = m;
+ }
}
- }
-public:
+ public:
- /** Contructor */
- Vector(int stepCount = 10)
- {
- vector = new T[stepCount];
- max = steps = stepCount;
- count = 0;
- }
+ /** Contructor */
+ Vector(int stepCount = 10)
+ {
+ vector = new T[stepCount];
+ max = steps = stepCount;
+ count = 0;
+ }
- /** Destructor */
- ~Vector()
- {
- delete[] vector;
- }
+ /** Destructor */
+ ~Vector()
+ {
+ delete[] vector;
+ }
- /** Reference to an item of the vector */
- T& operator[](int p)
- {
- return vector[p];
- }
+ /** Reference to an item of the vector */
+ T& operator[](int p)
+ {
+ return vector[p];
+ }
- /** Reference to an item of the vector */
- const T& operator[](int p) const
- {
- return vector[p];
- }
+ /** Reference to an item of the vector */
+ const T& operator[](int p) const
+ {
+ return vector[p];
+ }
- /** Reference to an item of the vector */
- T& back()
- {
- return vector[count - 1];
- }
+ /** Reference to an item of the vector */
+ T& back()
+ {
+ return vector[count - 1];
+ }
- /** Reference to an item of the vector */
- const T& back() const
- {
- return vector[count - 1];
- }
+ /** Reference to an item of the vector */
+ const T& back() const
+ {
+ return vector[count - 1];
+ }
- /** Current length of the vector */
- unsigned int size() const
- {
- return count;
- }
+ /** Current length of the vector */
+ unsigned int size() const
+ {
+ return count;
+ }
- /** Is the vector empty? */
- bool empty() const
- {
- return count == 0;
- }
+ /** Is the vector empty? */
+ bool empty() const
+ {
+ return count == 0;
+ }
- /** Add an item to the end of the vector */
- void push_back(const T& item)
- {
- resize(count + 1);
- vector[count] = item;
- ++count;
- }
+ /** Add an item to the end of the vector */
+ void push_back(const T& item)
+ {
+ resize(count + 1);
+ vector[count] = item;
+ ++count;
+ }
- /** Remove an item from the end of the vector */
- void pop_back()
- {
- if (count > 0)
+ /** Remove an item from the end of the vector */
+ void pop_back()
{
- --count;
- resize(count);
+ if (count > 0)
+ {
+ --count;
+ resize(count);
+ }
}
- }
-};
+ };
+
+} // namespace Spider
+
#endif
#endif // VDR_SPIDER_H
diff --git a/tableau.cpp b/tableau.cpp
index a53f4d8..07a50fd 100644
--- a/tableau.cpp
+++ b/tableau.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: tableau.cpp 94 2007-09-20 23:43:48Z tom $
+ * $Id: tableau.cpp 95 2007-09-21 23:01:10Z tom $
*/
#include "tableau.h"
@@ -25,8 +25,10 @@
#include "heap.h"
#include "history.h"
+using namespace Spider;
-/** --- class Tableau ------------------------------------------------------ **/
+
+//--- class Spider::Tableau ----------------------------------------------------
/** Constructor */
Tableau::Tableau(Deck& deck, int pileCount, int finalCount, int deals) :
diff --git a/tableau.h b/tableau.h
index b2ab3fc..d09797e 100644
--- a/tableau.h
+++ b/tableau.h
@@ -17,90 +17,96 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: tableau.h 87 2007-06-22 22:37:36Z tom $
+ * $Id: tableau.h 95 2007-09-21 23:01:10Z tom $
*/
#ifndef VDR_SPIDER_TABLEAU_H
#define VDR_SPIDER_TABLEAU_H
#include "spider.h"
-class Deck;
-class Card;
-class Pack;
-class Pile;
-typedef Array<Pile*> Piles;
-class FinalHeap;
-typedef Array<FinalHeap*> Finals;
-class History;
-/** --- class Tableau ------------------------------------------------------ **/
-
-class Tableau
+namespace Spider
{
-private:
- int dealCount;
- int cardsToOpen;
- Deck& deck;
+ class Deck;
+ class Card;
+ class Pack;
+ class Pile;
+ typedef Array<Pile*> Piles;
+ class FinalHeap;
+ typedef Array<FinalHeap*> Finals;
+ class History;
+
+
+ //--- class Spider::Tableau --------------------------------------------------
+
+ class Tableau
+ {
+ private:
+ int dealCount;
+ int cardsToOpen;
+ Deck& deck;
+
+ public:
+ Pack* pack;
+ Piles piles;
+ Finals finals;
+ Pile* selected;
+ bool changed;
+ History* history;
-public:
- Pack* pack;
- Piles piles;
- Finals finals;
- Pile* selected;
- bool changed;
- History* history;
+ /** Constructor */
+ Tableau(Deck& deck, int pileCount, int finalCount, int deals);
- /** Constructor */
- Tableau(Deck& deck, int pileCount, int finalCount, int deals);
+ /** Destructor */
+ ~Tableau();
- /** Destructor */
- ~Tableau();
+ /** Current count of deals */
+ int deals();
- /** Current count of deals */
- int deals();
+ /** Current count of points */
+ int points();
- /** Current count of points */
- int points();
+ /** Is no pile empty? */
+ bool noPileEmpty();
- /** Is no pile empty? */
- bool noPileEmpty();
+ /** Matches all cards in all piles? */
+ bool allCardsMatches();
- /** Matches all cards in all piles? */
- bool allCardsMatches();
+ /** Is the game over? */
+ bool gameOver();
- /** Is the game over? */
- bool gameOver();
+ /** Select p-th pile by selecting up to max matching cards on its end */
+ void select(int p, int max = 0);
- /** Select p-th pile by selecting up to max matching cards on its end */
- void select(int p, int max = 0);
+ /** Unselect the selected pile */
+ void unselect();
- /** Unselect the selected pile */
- void unselect();
+ /** Move cards from selected pile to p-th pile */
+ void move(int p);
- /** Move cards from selected pile to p-th pile */
- void move(int p);
+ /** Search move from p-th pile to the next left pile, return destination */
+ int autoMoveLeft(int p);
- /** Search move from p-th pile to the next left pile, return destination */
- int autoMoveLeft(int p);
+ /** Search move from p-th pile to the next right pile, return destination */
+ int autoMoveRight(int p);
- /** Search move from p-th pile to the next right pile, return destination */
- int autoMoveRight(int p);
+ /** Search best move from p-th pile, return destination */
+ int autoMove(int p);
- /** Search best move from p-th pile, return destination */
- int autoMove(int p);
+ /** Deal one row */
+ void deal();
- /** Deal one row */
- void deal();
+ /** Remove one suit of cards from selected pile to the final heaps */
+ void remove();
- /** Remove one suit of cards from selected pile to the final heaps */
- void remove();
+ /** Go one move backward in the history */
+ void backward();
- /** Go one move backward in the history */
- void backward();
+ /** Go one move forward in the history */
+ void forward();
+ };
- /** Go one move forward in the history */
- void forward();
-};
+} // namespace Spider
#endif // VDR_SPIDER_TABLEAU_H