⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hearts.h

📁 一个扑克牌游戏集合的源码,包含了很多基本c-c++语言应用
💻 H
字号:
#ifndef HEARTS_H#define HEARTS_H//$Id: Hearts.h,v 1.28 2006/08/03 23:25:54 markus Rel $// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#include <vector>#include <gtkmm/label.h>#include <CardSet.h>#include <CardPile.h>#include <Game.h>class ScoreDlg;// Class to handle the Hearts cardgameclass Hearts : public Game {   friend class Settings;   friend class CardgameAppl;   friend class CardgameCollection; public:   Hearts (Gtk::Box& parent, Gtk::Statusbar& statusbar, CardSet& cardset,           const std::vector<Player*>& player, unsigned int posPlayer,           YGP::Mutex& mxSerialize);   virtual ~Hearts ();   virtual void start ();   virtual void clean ();   virtual void playOpen (bool open);   virtual const char* name () { return "Hearts"; }   virtual void changeNames (const std::vector<Player*>& newPlayer);   virtual bool handleMessage (unsigned int player, const std::string& message) throw (YGP::ParseError, YGP::CommError); protected:   virtual ICardPile* getPileOfPlayer (unsigned int player, unsigned int pile); private:   enum Status { EXCHANGE = Game::LAST };   static void getPositionOfColours (ICardPile& pile, int result[4]);   // Protected manager functions   Hearts (const Hearts& other);   const Hearts& operator= (const Hearts& other);   //@Section Event handling   void cardSelected (unsigned int iCard);   void takeCard (unsigned int iCard);   //@Section Virtual methods   virtual int makeMove (unsigned int player);   virtual bool enableHuman ();   //@Section Helper methods   bool moveSelectedCardToPlayed (unsigned int player, unsigned int card);   unsigned int  calcNextPlayer (unsigned int player);   unsigned int  check4Winner ();   void exchangeCards ();   bool cardsExchanged (unsigned int cards);   static unsigned int numberOfCards (const int aPositions[4], CardWidget::COLOURS colour);   static unsigned int pointsOfPile (ICardPile& pile);   //@Section Computer player   unsigned int findPos2Play (unsigned int player);   unsigned int findWorstCard (const ICardPile& pile, const int aPositions[4]);   unsigned int findLowerCard (const ICardPile& pile, const int aPositions[4]);   void startPlaying ();   virtual void addMenus (Glib::RefPtr<Gtk::UIManager> mgrUI);   virtual void removeMenus (Glib::RefPtr<Gtk::UIManager> mgrUI);   static const unsigned int NUM_PLAYERS = 4;              // Number of players   bool playedSQ;               // Flag, if the queen of spades has been played   unsigned int aPlayed[4];        // Array holding played cars for each colour   unsigned int player2Exchange;  // ID of (next) player to exchange cards with   ICardPile aExchange[NUM_PLAYERS];        // Cards the players are exchanging   struct {      ICardPile*  hand;                       // For players: Cards in the hand      ICardPile*  won;                                             // Won cards      Gtk::Label name;   } players[NUM_PLAYERS];   CardHPile played;   ScoreDlg* pScoreDlg;   Gtk::UIManager::ui_merge_id idMrg;   static const unsigned int COLS_PLAYER[NUM_PLAYERS];   static const unsigned int ROWS_PLAYER[NUM_PLAYERS];   static unsigned int ENDPOINTS;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -