]>
git.saurik.com Git - wxWidgets.git/blob - demos/forty/game.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Forty Thieves patience game
4 // Author: Chris Breeze
7 // Copyright: (c) 1993-1998 Chris Breeze
8 // Licence: wxWindows licence
9 //---------------------------------------------------------------------------
10 // Last modified: 22nd July 1998 - ported to wxWidgets 2.0
11 /////////////////////////////////////////////////////////////////////////////
17 const int MaxMoves
= 800;
20 //---------------------------------------//
21 // A class which holds the pack of cards //
22 //---------------------------------------//
23 class Pack
: public Pile
{
27 void Redraw(wxDC
& dc
);
28 void ResetPile() { m_topCard
= NumCards
- 1; }
30 void AddCard(Card
* card
); // Add card
31 void AddCard(wxDC
& dc
, Card
* card
) { AddCard(card
); Redraw(dc
); }
35 //----------------------------------------------------------//
36 // A class which holds a base i.e. the initial 10 x 4 cards //
37 //----------------------------------------------------------//
38 class Base
: public Pile
{
42 bool AcceptCard(Card
* card
);
46 //----------------------------------------------------//
47 // A class which holds a foundation i.e. Ace, 2, 3... //
48 //----------------------------------------------------//
49 class Foundation
: public Pile
{
51 Foundation(int x
, int y
);
52 virtual ~Foundation(){}
53 bool AcceptCard(Card
* card
);
57 //--------------------------------------//
58 // A class which holds the discard pile //
59 //--------------------------------------//
60 class Discard
: public Pile
{
62 Discard(int x
, int y
);
64 void Redraw(wxDC
& dc
);
65 void GetTopCardPos(int& x
, int& y
);
66 Card
* RemoveTopCard(wxDC
& dc
, int m_xOffset
, int m_yOffset
);
72 Game(int wins
, int games
, int score
);
76 void NewPlayer(int wins
, int games
, int score
);
77 void Deal(); // Shuffle and deal a new game
78 bool CanYouGo(int x
, int y
); // can card under (x,y) go somewhere?
79 bool HaveYouWon(); // have you won the game?
81 void Undo(wxDC
& dc
); // Undo the last go
82 void Redo(wxDC
& dc
); // Redo the last go
84 void Redraw(wxDC
& dc
);
85 void DisplayScore(wxDC
& dc
);
86 bool LButtonDown(wxDC
& dc
, int mx
, int my
);
87 void LButtonUp(wxDC
& dc
, int mx
, int my
);
88 void LButtonDblClk(wxDC
& dc
, int mx
, int my
);
89 void MouseMove(wxDC
& dc
, int mx
, int my
);
91 int GetNumWins() const { return m_numWins
; }
92 int GetNumGames() const { return m_numGames
; }
93 int GetScore() const { return m_currentScore
+ m_totalScore
; }
95 bool InPlay() const { return m_inPlay
; }
98 bool DropCard(int x
, int y
, Pile
* pile
, Card
* card
);
99 // can the card at (x, y) be dropped on the pile?
100 Pile
* WhichPile(int x
, int y
); // which pile is (x, y) over?
101 void DoMove(wxDC
& dc
, Pile
* src
, Pile
* dest
);
103 bool m_inPlay
; // flag indicating that the game has started
110 int m_moveIndex
; // current position in undo/redo buffer
111 int m_redoIndex
; // max move index available for redo
113 // the various piles of cards
117 Foundation
* m_foundations
[8];
119 // variables to do with dragging cards
122 int m_xPos
, m_yPos
; // current coords of card being dragged
123 int m_xOffset
, m_yOffset
; // card/mouse offset when dragging a card
126 wxBitmap
* m_bmapCard
;
128 // variables to do with scoring