Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
7.1 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1991, 1992 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. player.h
  7. Aug 92, JimH
  8. May 93, JimH chico port
  9. Header file for class player
  10. hierarchy: player
  11. / \
  12. computer human
  13. / \
  14. local_human remote_human
  15. note: player and human are abstract classes.
  16. pos == 0 implies local human
  17. id == 0 implies gamemeister
  18. Relative to any human player, positions (pos) are arranged like this:
  19. 2
  20. 1 3
  21. 0
  22. If the human is the gamemeister, these are also the id's.
  23. ****************************************************************************/
  24. #include "card.h"
  25. #include "debug.h"
  26. #ifndef PLAYER_INC
  27. #define PLAYER_INC
  28. const int HORZSPACING = 15;
  29. const int VERTSPACING = 15;
  30. const int IDGE = 3; // EDGE was defined as something else
  31. const int MAXCARDSWON = 14;
  32. typedef int SLOT;
  33. enum modetype { STARTING,
  34. SELECTING,
  35. DONE_SELECTING,
  36. WAITING,
  37. ACCEPTING,
  38. PLAYING,
  39. SCORING
  40. };
  41. const int MAXSLOT = 13;
  42. const int ALL = -1;
  43. struct handinfotype {
  44. int playerled; // id of player led
  45. int turn; // whose turn? (0 to 3)
  46. card *cardplayed[4]; // cards in play for each player
  47. BOOL bHeartsBroken; // hearts broken in this hand?
  48. BOOL bQSPlayed; // Queen of Spades played yet?
  49. BOOL bShootingRisk; // someone trying to shoot the moon?
  50. int nMoonShooter; // id of potential shooter
  51. BOOL bHumanShooter; // is nMoonShooter a human player?
  52. };
  53. /* timer callback */
  54. #if defined (MFC1)
  55. UINT FAR PASCAL EXPORT TimerBadMove(HWND hWnd, UINT nMsg, int nIDEvent, DWORD dwTime);
  56. #else
  57. void FAR PASCAL EXPORT TimerBadMove(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime);
  58. #endif
  59. class CMainWindow;
  60. class player {
  61. private:
  62. CString name;
  63. CFont font;
  64. protected:
  65. int id; // position relative to gamemeister
  66. int position; // position relative to you
  67. int score;
  68. card cd[MAXSLOT];
  69. POINT loc; // location of cd[0]
  70. int dx, dy; // offset for rest of cards
  71. POINT playloc; // played cards glided to here
  72. POINT homeloc; // won cards glided to here
  73. POINT dotloc; // location of cd[0] "selected" dot
  74. POINT nameloc; // location of name
  75. modetype mode;
  76. int status;
  77. int cardswon[MAXCARDSWON];
  78. int numcardswon;
  79. public:
  80. player(int n, int pos);
  81. virtual ~player() { } // required for ~local_human
  82. card *Card(int s) { return &(cd[s]); }
  83. void DisplayHeartsWon(CDC &dc);
  84. void DisplayName(CDC &dc);
  85. int EvaluateScore(BOOL &bMoonShot);
  86. BOOL GetCardLoc(SLOT s, POINT& loc);
  87. SLOT GetSlot(int id);
  88. CRect &GetCoverRect(CRect& rect);
  89. int GetID(SLOT slot) { return cd[slot].ID(); }
  90. CRect &GetMarkingRect(CRect& rect);
  91. modetype GetMode() { return mode; }
  92. CString GetName() { return name; }
  93. int GetScore() { return score; }
  94. void GlideToCentre(SLOT s, BOOL bFaceup);
  95. void MarkCardPlayed(SLOT s) { cd[s].Play(); }
  96. void ResetCardsWon(void);
  97. void ResetLoc(void);
  98. void ReturnSelectedCards(int c[]);
  99. void Select(SLOT slot, BOOL bSelect)
  100. { cd[slot].Select(bSelect); }
  101. void SetID(SLOT slot, int id) { cd[slot].SetID(id); }
  102. void SetMode(modetype m) { mode = m; }
  103. void SetName(CString& newname, CDC& dc);
  104. void SetScore(int s) { score = s; }
  105. void SetStatus(int s) { status = s; }
  106. void Sort(void);
  107. void WinCard(CDC &dc, card *c);
  108. virtual void Draw(CDC &dc, BOOL bCheating = FALSE, SLOT slot = ALL);
  109. virtual BOOL IsHuman() { return FALSE; }
  110. virtual void MarkSelectedCards(CDC &dc);
  111. virtual void NotifyEndHand(handinfotype &h) = 0;
  112. virtual void NotifyNewRound(void) = 0;
  113. virtual void ReceiveSelectedCards(int c[]);
  114. virtual void SelectCardsToPass(void) = 0;
  115. virtual void SelectCardToPlay(handinfotype &h, BOOL bCheating) = 0;
  116. virtual void UpdateStatus(void) = 0;
  117. virtual void UpdateStatus(int stringid) = 0;
  118. virtual void UpdateStatus(const TCHAR *string) = 0;
  119. virtual void Quit() { }
  120. virtual BOOL HasQuit() { return FALSE; }
  121. };
  122. class human : public player {
  123. private:
  124. protected:
  125. human(int n, int pos);
  126. public:
  127. virtual BOOL IsHuman() { return TRUE; }
  128. #if defined(_DEBUG)
  129. void DebugMove(SLOT slot) { \
  130. TRACE1("<%d> human decides to ", id); PLAY(slot); TRACE0("\n"); }
  131. #endif
  132. };
  133. class local_human : public human {
  134. #if defined (MFC1)
  135. friend UINT FAR PASCAL EXPORT TimerBadMove(HWND, UINT, int, DWORD);
  136. #else
  137. friend void FAR PASCAL EXPORT TimerBadMove(HWND, UINT, UINT_PTR, DWORD);
  138. #endif
  139. protected:
  140. CBitmap m_bmStretchCard; // bitmap for card + pop length
  141. CStatusBarCtrl *m_pStatusWnd;
  142. int XYToCard(int x, int y);
  143. void StartTimer(card &c);
  144. static BOOL bTimerOn;
  145. static CString m_StatusText;
  146. public:
  147. local_human(int n);
  148. ~local_human();
  149. BOOL IsTimerOn() { return bTimerOn; }
  150. BOOL PlayCard(int x, int y, handinfotype &h, BOOL bCheating,
  151. BOOL bFlash = TRUE);
  152. void PopCard(CBrush &brush, int x, int y);
  153. void SetPlayerId(int n) { id = n; }
  154. void WaitMessage(const TCHAR *name);
  155. virtual void Draw(CDC &dc, BOOL bCheating = FALSE, SLOT slot = ALL);
  156. virtual void MarkSelectedCards(CDC &dc) { return; }
  157. virtual void NotifyEndHand(handinfotype &h) { return; }
  158. virtual void NotifyNewRound(void) { return; }
  159. virtual void ReceiveSelectedCards(int c[]);
  160. virtual void SelectCardsToPass(void);
  161. virtual void SelectCardToPlay(handinfotype &h, BOOL bCheating);
  162. virtual void UpdateStatus(void);
  163. virtual void UpdateStatus(int stringid);
  164. virtual void UpdateStatus(const TCHAR *string);
  165. };
  166. #endif // PLAYER_INC