ReactOS  0.4.12-dev-36-g472787f
spider.h File Reference
#include <cardlib.h>
#include "resource.h"
Include dependency graph for spider.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DIFFICULTY_ONE_COLOR   1
 
#define DIFFICULTY_TWO_COLORS   2
 
#define DIFFICULTY_FOUR_COLORS   3
 
#define CARDBACK_START   IDC_CARDBACK1
 
#define CARDBACK_END   IDC_CARDBACK12
 
#define NUM_CARDBACKS   (CARDBACK_END - CARDBACK_START + 1)
 
#define CARDBACK_RES_START   53
 
#define CARDBACK_OPTIONS_WIDTH   72
 
#define CARDBACK_OPTIONS_HEIGHT   112
 
#define X_BORDER   5
 
#define Y_BORDER   5
 
#define NUM_STACKS   10
 

Functions

void CreateSpider (void)
 
void NewGame (void)
 
bool CARDLIBPROC RowStackDragProc (CardRegion &stackobj, int iNumCards)
 
bool CARDLIBPROC RowStackDropProc (CardRegion &stackobj, const CardStack &dragcards)
 
void CARDLIBPROC RowStackClickProc (CardRegion &stackobj, int iNumClicked)
 
void CARDLIBPROC DeckClickProc (CardRegion &stackobj, int iNumClicked)
 
void CARDLIBPROC PileDblClickProc (CardRegion &stackobj, int iNumClicked)
 
void CARDLIBPROC PileRemoveProc (CardRegion &stackobj, int iRemoved)
 

Variables

HWND hwndMain
 
CardWindow SpiderWnd
 
TCHAR szAppName []
 
bool fGameStarted
 
int yRowStackCardOffset
 
DWORD dwDifficulty
 
TCHAR MsgDeal []
 
TCHAR MsgWin []
 

Macro Definition Documentation

◆ CARDBACK_END

#define CARDBACK_END   IDC_CARDBACK12

Definition at line 12 of file spider.h.

◆ CARDBACK_OPTIONS_HEIGHT

#define CARDBACK_OPTIONS_HEIGHT   112

Definition at line 16 of file spider.h.

◆ CARDBACK_OPTIONS_WIDTH

#define CARDBACK_OPTIONS_WIDTH   72

Definition at line 15 of file spider.h.

◆ CARDBACK_RES_START

#define CARDBACK_RES_START   53

Definition at line 14 of file spider.h.

◆ CARDBACK_START

#define CARDBACK_START   IDC_CARDBACK1

Definition at line 11 of file spider.h.

◆ DIFFICULTY_FOUR_COLORS

#define DIFFICULTY_FOUR_COLORS   3

Definition at line 10 of file spider.h.

◆ DIFFICULTY_ONE_COLOR

#define DIFFICULTY_ONE_COLOR   1

Definition at line 8 of file spider.h.

◆ DIFFICULTY_TWO_COLORS

#define DIFFICULTY_TWO_COLORS   2

Definition at line 9 of file spider.h.

◆ NUM_CARDBACKS

#define NUM_CARDBACKS   (CARDBACK_END - CARDBACK_START + 1)

Definition at line 13 of file spider.h.

◆ NUM_STACKS

#define NUM_STACKS   10

Definition at line 21 of file spider.h.

Referenced by CreateSpider(), DeckClickProc(), NewGame(), and WndProc().

◆ X_BORDER

#define X_BORDER   5

Definition at line 18 of file spider.h.

◆ Y_BORDER

#define Y_BORDER   5

Definition at line 19 of file spider.h.

Function Documentation

◆ CreateSpider()

void CreateSpider ( void  )

Definition at line 279 of file spigame.cpp.

Referenced by WndProc().

280 {
281  int i, pos;
282 
283  /* Compute the value for yRowStackCardOffset based on the height of the card, so the card number and suite isn't hidden on larger cards except Ace */
285 
286  pDeck = SpiderWnd.CreateRegion(0, true, 0, 0, -15, 0);
293 
294  /* Create the row stacks */
295  for (i = 0; i < NUM_STACKS; i++)
296  {
297  pStack[i] = SpiderWnd.CreateRegion(NUM_STACKS+i, true, 0, Y_BORDER, 0, yRowStackCardOffset);
299  pos = i - NUM_STACKS/2;
301  pos * (__cardwidth + X_BORDER) + 6 * (X_BORDER + 1) + 3, 0);
306  }
307 }
#define Y_BORDER
Definition: solitaire.h:53
void SetFaceDirection(UINT uDirType, int nOption)
Definition: cardregion.cpp:258
CardRegion * pDeck
Definition: spigame.cpp:20
CardWindow SpiderWnd
Definition: spider.cpp:27
#define X_BORDER
Definition: solitaire.h:49
void SetClickReleaseProc(pClickProc proc)
Definition: cardregion.cpp:187
#define CS_XJUST_RIGHT
Definition: cardlib.h:38
#define CS_DRAG_NONE
Definition: cardlib.h:28
#define CS_DRAG_CALLBACK
Definition: cardlib.h:31
#define CS_EI_SUNK
Definition: cardlib.h:19
void SetPlacement(UINT xJustify, UINT yJustify, int xAdjust, int yAdjust)
Definition: cardregion.cpp:250
void CARDLIBPROC StackAddProc(CardRegion &stackobj, const CardStack &added)
Definition: spigame.cpp:212
void SetEmptyImage(UINT uImage)
Definition: cardregion.cpp:366
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define CS_EI_CIRC
Definition: cardlib.h:20
bool CARDLIBPROC StackDragProc(CardRegion &stackobj, int numDragCards)
Definition: spigame.cpp:169
bool SetDragRule(UINT uDragType, pCanDragProc proc=0)
Definition: cardregion.cpp:146
#define CS_XJUST_CENTER
Definition: cardlib.h:39
void CARDLIBPROC DeckClickProc(CardRegion &stackobj, int NumDragCards)
Definition: spigame.cpp:126
#define CS_FACE_DOWN
Definition: cardlib.h:52
#define CS_DROP_NONE
Definition: cardlib.h:33
CardRegion * CreateRegion(int id, bool fVisible, int x, int y, int xoffset, int yoffset)
Definition: cardregion.cpp:104
bool CARDLIBPROC StackDropProc(CardRegion &stackobj, CardStack &dragcards)
Definition: spigame.cpp:221
int __cardwidth
Definition: cardlib.cpp:25
#define CS_DROP_CALLBACK
Definition: cardlib.h:35
#define CS_YJUST_BOTTOM
Definition: cardlib.h:42
int yRowStackCardOffset
Definition: spigame.cpp:23
CardRegion * pStack[NUM_STACKS]
Definition: spigame.cpp:21
void SetAddCardProc(pAddProc proc)
Definition: cardregion.cpp:197
bool SetDropRule(UINT uDropType, pCanDropProc proc=0)
Definition: cardregion.cpp:164
int __cardheight
Definition: cardlib.cpp:26
#define NUM_STACKS
Definition: spider.h:21
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ DeckClickProc()

void CARDLIBPROC DeckClickProc ( CardRegion stackobj,
int  iNumClicked 
)

Definition at line 482 of file solgame.cpp.

Referenced by CreateSol(), and CreateSpider().

483 {
484  TRACE("ENTER DeckClickProc()\n");
485 
486  SetPlayTimer();
487 
488  CardStack cardstack = stackobj.GetCardStack();
489  CardStack pile = pPile->GetCardStack();
490 
491  fGameStarted = true;
492  SetPlayTimer();
493 
494  //reset the face-up pile to represent 3 cards
497 
498  if(cardstack.NumCards() == 0)
499  {
500  if (GetScoreMode() == SCORE_VEGAS)
501  {
503  {
504  pile.Clear();
505 
507  cardstack.Push(activepile);
508  activepile.Clear();
509  }
510  }
511  else if (GetScoreMode() == SCORE_STD)
512  {
513  if ((dwWasteCount >= dwWasteTreshold) && (activepile.NumCards() != 0))
514  {
515  if (dwOptions & OPTION_THREE_CARDS)
516  lScore = lScore >= 20 ? lScore - 20 : 0;
517  else
518  lScore = lScore >= 100 ? lScore - 100 : 0;
519  }
520 
521  pile.Clear();
522 
524  cardstack.Push(activepile);
525  activepile.Clear();
526 
527  UpdateStatusBar();
528  }
529  else
530  {
531  pile.Clear();
532 
534  cardstack.Push(activepile);
535  activepile.Clear();
536  }
537 
538  dwWasteCount++;
539  }
540  else
541  {
542  int numcards = min((dwOptions & OPTION_THREE_CARDS) ? 3 : 1, cardstack.NumCards());
543 
544  //make a "visible" copy of these cards
545  CardStack temp;
546  temp = cardstack.Pop(numcards);
547  temp.Reverse();
548 
549  if(dwOptions & OPTION_THREE_CARDS)
550  pile.Clear();
551 
552  pile.Push(temp);
553 
554  //remove the top 3 from deck
555  activepile.Push(temp);
556  }
557 
558  activepile.Print();
559 
560  pDeck->SetCardStack(cardstack);
561  pPile->SetCardStack(pile);
562 
563  SolWnd.Redraw();
564  TRACE("EXIT DeckClickProc()\n");
565 }
void Print()
Definition: cardstack.cpp:222
DWORD dwOptions
Definition: solitaire.cpp:23
long lScore
Definition: solitaire.cpp:29
const CardStack & GetCardStack()
Definition: cardregion.cpp:399
void Clear()
Definition: cardstack.cpp:37
void Push(const Card card)
Definition: cardstack.cpp:83
CardRegion * pDeck
Definition: solcreate.cpp:3
void Redraw(void)
Definition: cardwindow.cpp:553
int GetScoreMode(void)
Definition: solitaire.cpp:128
void Reverse()
Definition: cardstack.cpp:73
#define TRACE(s)
Definition: solgame.cpp:4
void SetPlayTimer(void)
Definition: solitaire.cpp:170
#define CS_DEFXOFF
Definition: cardlib.h:23
Card Pop()
Definition: cardstack.cpp:127
#define OPTION_THREE_CARDS
Definition: solitaire.h:11
CardStack activepile
Definition: solgame.cpp:12
static stack_node_t temp
Definition: rpn.c:18
void SetCardStack(const CardStack &cs)
Definition: cardregion.cpp:390
void SetOffsets(int x, int y)
Definition: cardregion.cpp:228
bool fGameStarted
Definition: solgame.cpp:14
#define min(a, b)
Definition: monoChain.cc:55
VOID UpdateStatusBar(WCHAR wch)
Definition: charmap.c:262
DWORD dwWasteCount
Definition: solitaire.cpp:26
#define SCORE_STD
Definition: solitaire.h:45
#define SCORE_VEGAS
Definition: solitaire.h:46
int NumCards() const
Definition: cardstack.h:14
DWORD dwWasteTreshold
Definition: solitaire.cpp:27
CardWindow SolWnd
Definition: solitaire.cpp:32
CardRegion * pPile
Definition: solcreate.cpp:4

◆ NewGame()

void NewGame ( void  )

Definition at line 17 of file solgame.cpp.

Referenced by DifficultyDlgProc(), GameFinished(), ShowGameOptionsDlg(), SuitStackAddProc(), and WndProc().

18 {
19  TRACE("ENTER NewGame()\n");
20  int i, j;
21 
22  if (GetScoreMode() == SCORE_VEGAS)
23  {
25  lScore = lScore - 52;
26  else
27  lScore = -52;
28 
30  dwWasteTreshold = 2;
31  else
32  dwWasteTreshold = 0;
33 
34  }
35  else
36  {
38  dwWasteTreshold = 3;
39  else
40  dwWasteTreshold = 0;
41 
42  lScore = 0;
43  }
44 
45  dwTime = 0;
46  dwWasteCount = 0;
47  LastId = 0;
48 
50 
51  //create a new card-stack
53  deck.NewDeck();
54  deck.Shuffle();
55  activepile.Clear();
56 
57  //deal to each row stack..
58  for(i = 0; i < NUM_ROW_STACKS; i++)
59  {
61  temp.Clear();
62 
64 
65  for(j = 0; j <= i; j++)
66  {
67  temp.Push(deck.Pop());
68  }
69 
70  pRowStack[i]->SetCardStack(temp);
71  }
72 
73  //put the other cards onto the deck
74  pDeck->SetCardStack(deck);
75  pDeck->Update();
76 
77  // For the 1-card-mode, all cards need to be completely overlapped
79  pPile->SetOffsets(0, 0);
80 
81  SolWnd.Redraw();
82 
83  fGameStarted = false;
84 
86 
88 
89  TRACE("EXIT NewGame()\n");
90 
91 }
DWORD dwOptions
Definition: solitaire.cpp:23
#define OPTION_KEEP_SCORE
Definition: solitaire.h:13
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
void SetFaceDirection(UINT uDirType, int nOption)
Definition: cardregion.cpp:258
long lScore
Definition: solitaire.cpp:29
void EmptyStacks(void)
Definition: cardwindow.cpp:607
void Clear()
Definition: cardstack.cpp:37
void Push(const Card card)
Definition: cardstack.cpp:83
CardRegion * pDeck
Definition: solcreate.cpp:3
void Redraw(void)
Definition: cardwindow.cpp:553
int GetScoreMode(void)
Definition: solitaire.cpp:128
void NewDeck()
Definition: cardstack.cpp:42
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void Update()
Definition: cardregion.cpp:207
DWORD dwTime
Definition: solitaire.cpp:25
#define NUM_ROW_STACKS
Definition: solitaire.h:38
#define TRACE(s)
Definition: solgame.cpp:4
void Shuffle()
Definition: cardstack.cpp:50
DWORD dwPrevMode
Definition: solitaire.cpp:28
Card Pop()
Definition: cardstack.cpp:127
#define OPTION_THREE_CARDS
Definition: solitaire.h:11
CardStack activepile
Definition: solgame.cpp:12
static stack_node_t temp
Definition: rpn.c:18
int LastId
Definition: solgame.cpp:13
void SetCardStack(const CardStack &cs)
Definition: cardregion.cpp:390
void SetOffsets(int x, int y)
Definition: cardregion.cpp:228
bool fGameStarted
Definition: solgame.cpp:14
#define CS_FACE_DOWNUP
Definition: cardlib.h:53
CardStack deck
Definition: spigame.cpp:18
VOID UpdateStatusBar(WCHAR wch)
Definition: charmap.c:262
DWORD dwWasteCount
Definition: solitaire.cpp:26
#define SCORE_VEGAS
Definition: solitaire.h:46
CardRegion * pRowStack[NUM_ROW_STACKS]
Definition: solcreate.cpp:6
DWORD dwWasteTreshold
Definition: solitaire.cpp:27
CardWindow SolWnd
Definition: solitaire.cpp:32
CardRegion * pPile
Definition: solcreate.cpp:4

◆ PileDblClickProc()

void CARDLIBPROC PileDblClickProc ( CardRegion stackobj,
int  iNumClicked 
)

Definition at line 443 of file solgame.cpp.

Referenced by CreateSol().

444 {
445  TRACE("ENTER PileDblClickProc()\n");
446 
447  SetPlayTimer();
448 
449  RowStackDblClickProc(stackobj, iNumClicked);
450  TRACE("EXIT PileDblClickProc()\n");
451 }
#define TRACE(s)
Definition: solgame.cpp:4
void CARDLIBPROC RowStackDblClickProc(CardRegion &stackobj, int iNumClicked)
Definition: solgame.cpp:394
void SetPlayTimer(void)
Definition: solitaire.cpp:170

◆ PileRemoveProc()

void CARDLIBPROC PileRemoveProc ( CardRegion stackobj,
int  iRemoved 
)

Definition at line 456 of file solgame.cpp.

Referenced by CreateSol().

457 {
458  TRACE("ENTER PileRemoveProc()\n");
459 
460  SetPlayTimer();
461 
462  //modify our "virtual" pile by removing the same card
463  //that was removed from the physical card stack
464  activepile.Pop(iItems);
465 
466  //if there is just 1 card left, then modify the
467  //stack to contain ALL the face-up cards..the effect
468  //will be, the next time a card is dragged, all the
469  //previous card-triplets will be available underneath
470  if(stackobj.NumCards() == 1)
471  {
472  stackobj.SetOffsets(0,0);
473  stackobj.SetCardStack(activepile);
474  }
475  TRACE("EXIT PileRemoveProc()\n");
476 }
#define TRACE(s)
Definition: solgame.cpp:4
void SetPlayTimer(void)
Definition: solitaire.cpp:170
int NumCards() const
Definition: cardregion.cpp:544
Card Pop()
Definition: cardstack.cpp:127
CardStack activepile
Definition: solgame.cpp:12
void SetCardStack(const CardStack &cs)
Definition: cardregion.cpp:390
void SetOffsets(int x, int y)
Definition: cardregion.cpp:228

◆ RowStackClickProc()

void CARDLIBPROC RowStackClickProc ( CardRegion stackobj,
int  iNumClicked 
)

Definition at line 284 of file solgame.cpp.

Referenced by CreateSol().

285 {
286  TRACE("ENTER RowStackClickProc()\n");
287  int numfacedown;
288 
289  stackobj.GetFaceDirection(&numfacedown);
290 
291  //if all face-down, then make top card face-up
292  if(stackobj.NumCards() == numfacedown)
293  {
294  if(numfacedown > 0) numfacedown--;
295  stackobj.SetFaceDirection(CS_FACE_DOWNUP, numfacedown);
296  stackobj.Redraw();
297 
298  if (GetScoreMode() == SCORE_STD)
299  {
300  lScore = lScore + 5;
301  UpdateStatusBar();
302  }
303  }
304 
305  LastId = stackobj.Id();
306 
307  fGameStarted = true;
308 
309  TRACE("EXIT RowStackClickProc()\n");
310 }
void SetFaceDirection(UINT uDirType, int nOption)
Definition: cardregion.cpp:258
long lScore
Definition: solitaire.cpp:29
void Redraw()
int GetScoreMode(void)
Definition: solitaire.cpp:128
#define TRACE(s)
Definition: solgame.cpp:4
int NumCards() const
Definition: cardregion.cpp:544
int LastId
Definition: solgame.cpp:13
bool fGameStarted
Definition: solgame.cpp:14
#define CS_FACE_DOWNUP
Definition: cardlib.h:53
VOID UpdateStatusBar(WCHAR wch)
Definition: charmap.c:262
#define SCORE_STD
Definition: solitaire.h:45
UINT GetFaceDirection(int *pnOption)
Definition: cardregion.cpp:273

◆ RowStackDragProc()

bool CARDLIBPROC RowStackDragProc ( CardRegion stackobj,
int  iNumCards 
)

Definition at line 101 of file solgame.cpp.

Referenced by CreateSol().

102 {
103  TRACE("ENTER RowStackDragProc()\n");
104  int numfacedown;
105  int numcards;
106 
107  SetPlayTimer();
108 
109  stackobj.GetFaceDirection(&numfacedown);
110 
111  numcards = stackobj.NumCards();
112 
113  TRACE("EXIT RowStackDragProc()\n");
114  if(iNumDragCards <= numcards-numfacedown)
115  return true;
116  else
117  return false;
118 
119 }
#define TRACE(s)
Definition: solgame.cpp:4
void SetPlayTimer(void)
Definition: solitaire.cpp:170
int NumCards() const
Definition: cardregion.cpp:544
UINT GetFaceDirection(int *pnOption)
Definition: cardregion.cpp:273

◆ RowStackDropProc()

bool CARDLIBPROC RowStackDropProc ( CardRegion stackobj,
const CardStack dragcards 
)

Variable Documentation

◆ dwDifficulty

DWORD dwDifficulty

Definition at line 25 of file spider.cpp.

Referenced by CreatePlayDeck(), DifficultyDlgProc(), and WndProc().

◆ fGameStarted

◆ hwndMain

◆ MsgDeal

TCHAR MsgDeal[]

Definition at line 22 of file solitaire.cpp.

◆ MsgWin

TCHAR MsgWin[]

Definition at line 21 of file solitaire.cpp.

◆ SpiderWnd

CardWindow SpiderWnd

Definition at line 27 of file spider.cpp.

Referenced by CreateSpider(), DeckClickProc(), GameFinished(), and NewGame().

◆ szAppName

TCHAR szAppName[]

Definition at line 16 of file solitaire.cpp.

◆ yRowStackCardOffset

int yRowStackCardOffset

Definition at line 12 of file solcreate.cpp.

Referenced by CreateSol(), CreateSpider(), and WndProc().