]> git.saurik.com Git - wxWidgets.git/blame - demos/forty/game.h
Do not waste time for USE_ODBC=0.
[wxWidgets.git] / demos / forty / game.h
CommitLineData
63cafd27
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: game.h
3// Purpose: Forty Thieves patience game
4// Author: Chris Breeze
5// Modified by:
6// Created: 21/07/97
7// RCS-ID: $Id$
8// Copyright: (c) 1993-1998 Chris Breeze
010216e3 9// Licence: wxWindows licence
63cafd27 10//---------------------------------------------------------------------------
be5a51fb 11// Last modified: 22nd July 1998 - ported to wxWidgets 2.0
63cafd27
JS
12/////////////////////////////////////////////////////////////////////////////
13#ifndef _GAME_H_
14#define _GAME_H_
15#include "card.h"
16#include "pile.h"
17
18const int MaxMoves = 800;
19
20
21//---------------------------------------//
22// A class which holds the pack of cards //
23//---------------------------------------//
24class Pack : public Pile {
25public:
010216e3
WS
26 Pack(int x, int y);
27 ~Pack();
28 void Redraw(wxDC& dc);
29 void ResetPile() { m_topCard = NumCards - 1; }
30 void Shuffle();
31 void AddCard(Card* card); // Add card
32 void AddCard(wxDC& dc, Card* card) { AddCard(card); Redraw(dc); }
63cafd27
JS
33};
34
35
36//----------------------------------------------------------//
37// A class which holds a base i.e. the initial 10 x 4 cards //
38//----------------------------------------------------------//
39class Base : public Pile {
40public:
010216e3 41 Base(int x, int y);
254a2129 42 ~Base(){};
010216e3 43 bool AcceptCard(Card* card);
63cafd27
JS
44};
45
46
47//----------------------------------------------------//
48// A class which holds a foundation i.e. Ace, 2, 3... //
49//----------------------------------------------------//
50class Foundation : public Pile {
51public:
010216e3 52 Foundation(int x, int y);
254a2129 53 ~Foundation(){};
010216e3 54 bool AcceptCard(Card* card);
63cafd27
JS
55};
56
57
58//--------------------------------------//
59// A class which holds the discard pile //
60//--------------------------------------//
61class Discard : public Pile {
62public:
010216e3 63 Discard(int x, int y);
254a2129 64 ~Discard(){};
010216e3
WS
65 void Redraw(wxDC& dc);
66 void GetTopCardPos(int& x, int& y);
67 Card* RemoveTopCard(wxDC& dc, int m_xOffset, int m_yOffset);
63cafd27
JS
68};
69
70
71class Game {
72public:
010216e3
WS
73 Game(int wins, int games, int score);
74 virtual ~Game();
63cafd27 75
010216e3
WS
76 void Layout();
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?
63cafd27 81
010216e3
WS
82 void Undo(wxDC& dc); // Undo the last go
83 void Redo(wxDC& dc); // Redo the last go
63cafd27 84
010216e3
WS
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);
63cafd27 91
010216e3
WS
92 int GetNumWins() const { return m_numWins; }
93 int GetNumGames() const { return m_numGames; }
94 int GetScore() const { return m_currentScore + m_totalScore; }
63cafd27 95
010216e3 96 bool InPlay() const { return m_inPlay; }
63cafd27
JS
97
98private:
010216e3
WS
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);
103
104 bool m_inPlay; // flag indicating that the game has started
105
106 // undo buffer
107 struct {
108 Pile* src;
109 Pile* dest;
110 } m_moves[MaxMoves];
111 int m_moveIndex; // current position in undo/redo buffer
112 int m_redoIndex; // max move index available for redo
113
114 // the various piles of cards
115 Pack* m_pack;
116 Discard* m_discard;
117 Base* m_bases[10];
118 Foundation* m_foundations[8];
119
120 // variables to do with dragging cards
121 Pile* m_srcPile;
122 Card* m_liftedCard;
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
125
126 wxBitmap* m_bmap;
127 wxBitmap* m_bmapCard;
128
129 // variables to do with scoring
130 int m_numGames;
131 int m_numWins;
132 int m_totalScore;
133 int m_currentScore;
63cafd27
JS
134};
135
136#endif // _GAME_H_