1998-07-24 15:43:32 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: game.h
|
|
|
|
// Purpose: Forty Thieves patience game
|
|
|
|
// Author: Chris Breeze
|
|
|
|
// Modified by:
|
|
|
|
// Created: 21/07/97
|
|
|
|
// Copyright: (c) 1993-1998 Chris Breeze
|
2004-06-02 05:14:59 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-07-24 15:43:32 -04:00
|
|
|
//---------------------------------------------------------------------------
|
2004-05-25 07:20:37 -04:00
|
|
|
// Last modified: 22nd July 1998 - ported to wxWidgets 2.0
|
1998-07-24 15:43:32 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _GAME_H_
|
|
|
|
#define _GAME_H_
|
|
|
|
#include "card.h"
|
|
|
|
#include "pile.h"
|
|
|
|
|
|
|
|
const int MaxMoves = 800;
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------//
|
|
|
|
// A class which holds the pack of cards //
|
|
|
|
//---------------------------------------//
|
|
|
|
class Pack : public Pile {
|
|
|
|
public:
|
2004-06-02 05:14:59 -04:00
|
|
|
Pack(int x, int y);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~Pack();
|
2018-09-21 13:46:49 -04:00
|
|
|
void Redraw(wxDC& dc) wxOVERRIDE;
|
|
|
|
void ResetPile() wxOVERRIDE { m_topCard = NumCards - 1; }
|
2004-06-02 05:14:59 -04:00
|
|
|
void Shuffle();
|
2018-09-21 13:46:49 -04:00
|
|
|
void AddCard(Card* card) wxOVERRIDE; // Add card
|
|
|
|
void AddCard(wxDC& dc, Card* card) wxOVERRIDE { AddCard(card); Redraw(dc); }
|
1998-07-24 15:43:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------//
|
|
|
|
// A class which holds a base i.e. the initial 10 x 4 cards //
|
|
|
|
//----------------------------------------------------------//
|
|
|
|
class Base : public Pile {
|
|
|
|
public:
|
2004-06-02 05:14:59 -04:00
|
|
|
Base(int x, int y);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~Base(){}
|
2018-09-21 13:46:49 -04:00
|
|
|
bool AcceptCard(Card* card) wxOVERRIDE;
|
1998-07-24 15:43:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------//
|
|
|
|
// A class which holds a foundation i.e. Ace, 2, 3... //
|
|
|
|
//----------------------------------------------------//
|
|
|
|
class Foundation : public Pile {
|
|
|
|
public:
|
2004-06-02 05:14:59 -04:00
|
|
|
Foundation(int x, int y);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~Foundation(){}
|
2018-09-21 13:46:49 -04:00
|
|
|
bool AcceptCard(Card* card) wxOVERRIDE;
|
1998-07-24 15:43:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------//
|
|
|
|
// A class which holds the discard pile //
|
|
|
|
//--------------------------------------//
|
|
|
|
class Discard : public Pile {
|
|
|
|
public:
|
2004-06-02 05:14:59 -04:00
|
|
|
Discard(int x, int y);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~Discard(){}
|
2018-09-21 13:46:49 -04:00
|
|
|
void Redraw(wxDC& dc) wxOVERRIDE;
|
|
|
|
void GetTopCardPos(int& x, int& y) wxOVERRIDE;
|
|
|
|
Card* RemoveTopCard(wxDC& dc, int m_xOffset, int m_yOffset) wxOVERRIDE;
|
1998-07-24 15:43:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Game {
|
|
|
|
public:
|
2004-06-02 05:14:59 -04:00
|
|
|
Game(int wins, int games, int score);
|
|
|
|
virtual ~Game();
|
1998-07-24 15:43:32 -04:00
|
|
|
|
2004-06-02 05:14:59 -04:00
|
|
|
void Layout();
|
|
|
|
void NewPlayer(int wins, int games, int score);
|
|
|
|
void Deal(); // Shuffle and deal a new game
|
|
|
|
bool CanYouGo(int x, int y); // can card under (x,y) go somewhere?
|
|
|
|
bool HaveYouWon(); // have you won the game?
|
1998-07-24 15:43:32 -04:00
|
|
|
|
2004-06-02 05:14:59 -04:00
|
|
|
void Undo(wxDC& dc); // Undo the last go
|
|
|
|
void Redo(wxDC& dc); // Redo the last go
|
1998-07-24 15:43:32 -04:00
|
|
|
|
2004-06-02 05:14:59 -04:00
|
|
|
void Redraw(wxDC& dc);
|
|
|
|
void DisplayScore(wxDC& dc);
|
|
|
|
bool LButtonDown(wxDC& dc, int mx, int my);
|
|
|
|
void LButtonUp(wxDC& dc, int mx, int my);
|
|
|
|
void LButtonDblClk(wxDC& dc, int mx, int my);
|
|
|
|
void MouseMove(wxDC& dc, int mx, int my);
|
1998-07-24 15:43:32 -04:00
|
|
|
|
2004-06-02 05:14:59 -04:00
|
|
|
int GetNumWins() const { return m_numWins; }
|
|
|
|
int GetNumGames() const { return m_numGames; }
|
|
|
|
int GetScore() const { return m_currentScore + m_totalScore; }
|
1998-07-24 15:43:32 -04:00
|
|
|
|
2004-06-02 05:14:59 -04:00
|
|
|
bool InPlay() const { return m_inPlay; }
|
1998-07-24 15:43:32 -04:00
|
|
|
|
|
|
|
private:
|
2004-06-02 05:14:59 -04:00
|
|
|
bool DropCard(int x, int y, Pile* pile, Card* card);
|
|
|
|
// can the card at (x, y) be dropped on the pile?
|
|
|
|
Pile* WhichPile(int x, int y); // which pile is (x, y) over?
|
|
|
|
void DoMove(wxDC& dc, Pile* src, Pile* dest);
|
|
|
|
|
|
|
|
bool m_inPlay; // flag indicating that the game has started
|
|
|
|
|
|
|
|
// undo buffer
|
|
|
|
struct {
|
|
|
|
Pile* src;
|
|
|
|
Pile* dest;
|
|
|
|
} m_moves[MaxMoves];
|
|
|
|
int m_moveIndex; // current position in undo/redo buffer
|
|
|
|
int m_redoIndex; // max move index available for redo
|
|
|
|
|
|
|
|
// the various piles of cards
|
|
|
|
Pack* m_pack;
|
|
|
|
Discard* m_discard;
|
|
|
|
Base* m_bases[10];
|
|
|
|
Foundation* m_foundations[8];
|
|
|
|
|
|
|
|
// variables to do with dragging cards
|
|
|
|
Pile* m_srcPile;
|
|
|
|
Card* m_liftedCard;
|
|
|
|
int m_xPos, m_yPos; // current coords of card being dragged
|
|
|
|
int m_xOffset, m_yOffset; // card/mouse offset when dragging a card
|
|
|
|
|
|
|
|
wxBitmap* m_bmap;
|
|
|
|
wxBitmap* m_bmapCard;
|
|
|
|
|
|
|
|
// variables to do with scoring
|
|
|
|
int m_numGames;
|
|
|
|
int m_numWins;
|
|
|
|
int m_totalScore;
|
|
|
|
int m_currentScore;
|
1998-07-24 15:43:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _GAME_H_
|