]>
git.saurik.com Git - wxWidgets.git/blob - demos/forty/game.h
a8fb4e5aafae56cd44346e24d3b2f4f6a6659f02
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Forty Thieves patience game
4 // Author: Chris Breeze
8 // Copyright: (c) 1993-1998 Chris Breeze
9 // Licence: wxWindows licence
10 //---------------------------------------------------------------------------
11 // Last modified: 22nd July 1998 - ported to wxWidgets 2.0
12 /////////////////////////////////////////////////////////////////////////////
18 const int MaxMoves
= 800;
21 //---------------------------------------//
22 // A class which holds the pack of cards //
23 //---------------------------------------//
24 class Pack
: public Pile
{
28 void Redraw(wxDC
& dc
);
29 void ResetPile() { m_topCard
= NumCards
- 1; }
31 void AddCard(Card
* card
); // Add card
32 void AddCard(wxDC
& dc
, Card
* card
) { AddCard(card
); Redraw(dc
); }
36 //----------------------------------------------------------//
37 // A class which holds a base i.e. the initial 10 x 4 cards //
38 //----------------------------------------------------------//
39 class Base
: public Pile
{
43 bool AcceptCard(Card
* card
);
47 //----------------------------------------------------//
48 // A class which holds a foundation i.e. Ace, 2, 3... //
49 //----------------------------------------------------//
50 class Foundation
: public Pile
{
52 Foundation(int x
, int y
);
54 bool AcceptCard(Card
* card
);
58 //--------------------------------------//
59 // A class which holds the discard pile //
60 //--------------------------------------//
61 class Discard
: public Pile
{
63 Discard(int x
, int y
);
65 void Redraw(wxDC
& dc
);
66 void GetTopCardPos(int& x
, int& y
);
67 Card
* RemoveTopCard(wxDC
& dc
, int m_xOffset
, int m_yOffset
);
73 Game(int wins
, int games
, int score
);
77 void NewPlayer(int wins
, int games
, int score
);
78 void Deal(); // Shuffle and deal a new game
79 bool CanYouGo(int x
, int y
); // can card under (x,y) go somewhere?
80 bool HaveYouWon(); // have you won the game?
82 void Undo(wxDC
& dc
); // Undo the last go
83 void Redo(wxDC
& dc
); // Redo the last go
85 void Redraw(wxDC
& dc
);
86 void DisplayScore(wxDC
& dc
);
87 bool LButtonDown(wxDC
& dc
, int mx
, int my
); //
88 void LButtonUp(wxDC
& dc
, int mx
, int my
);
89 void LButtonDblClk(wxDC
& dc
, int mx
, int my
);
90 void MouseMove(wxDC
& dc
, int mx
, int my
);
92 int GetNumWins() const { return m_numWins
; }
93 int GetNumGames() const { return m_numGames
; }
94 int GetScore() const { return m_currentScore
+ m_totalScore
; }
96 bool InPlay() const { return m_inPlay
; }
99 bool DropCard(int x
, int y
, Pile
* pile
, Card
* card
);
100 // can the card at (x, y) be dropped on the pile?
101 Pile
* WhichPile(int x
, int y
); // which pile is (x, y) over?
102 void DoMove(wxDC
& dc
, Pile
* src
, Pile
* dest
);
104 bool m_inPlay
; // flag indicating that the game has started
111 int m_moveIndex
; // current position in undo/redo buffer
112 int m_redoIndex
; // max move index available for redo
114 // the various piles of cards
118 Foundation
* m_foundations
[8];
120 // variables to do with dragging cards
123 int m_xPos
, m_yPos
; // current coords of card being dragged
124 int m_xOffset
, m_yOffset
; // card/mouse offset when dragging a card
127 wxBitmap
* m_bmapCard
;
129 // variables to do with scoring