engine_two.h

Go to the documentation of this file.
00001 #ifndef ENGINE_TWO_H
00002 #define ENGINE_TWO_H
00003 /*
00004    This file is part of the KDE games lskat program
00005    Copyright (c) 2006 Martin Heni <kde@heni-online.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 // Qt includes
00024 #include <QObject>
00025 
00026 
00027 // KDE includes
00028 #include <kdebug.h>
00029 
00030 // Local includes
00031 #include "abstractengine.h"
00032 #include "deck.h"
00033 
00034 // Forward declaration
00035 class DisplayTwo;
00036 
00037 using namespace CardDeck;
00038 
00039 
00042 class EngineTwo : public AbstractEngine
00043 {
00044   Q_OBJECT
00045 
00046   public:
00048     enum MoveState {FirstPlayerTurn=0, SecondPlayerTurn=1};
00049 
00050 
00051   
00057     EngineTwo(QWidget* parent, Deck* deck, DisplayTwo* display);
00058 
00059 
00064     virtual void startGame(Suite trump, int startPlayer);
00065 
00068     virtual void stopGame();
00069 
00073      MoveState currentMovePhase() {return mCurrentMovePhase;}
00074 
00079      int playedCard(int no) {return mCurrentMoveCards[no];}
00080 
00081 
00082   public slots:
00083 
00089     virtual void playerInput(int inputId, int playerNumber, int cardNumber);
00090 
00098     bool isLegalMove(int card1, int card2, int playerNumber);
00099 
00104     int whoWonMove(int card1,int card2);
00105 
00106 
00107   protected slots:
00110     void gameLoopStart();
00111 
00114     void gameLoopFinish();
00115 
00116   protected:
00121     void activatePlayer(int playerNumber);
00122 
00126     bool gameOver();
00127 
00131     int evaluateGame();
00132 
00133   private:
00134     // The display engine
00135     DisplayTwo* mDisplay;
00136     // The card deck
00137     Deck* mDeck;
00138     // Current move cards
00139     int mCurrentMoveCards[2];
00140     // Move phase (1st player or 2nd player)
00141     MoveState mCurrentMovePhase;
00142     // Current move number (counting half moves)
00143     int mMoveNumber;
00144     // Trump color
00145     Suite mTrump;
00146     
00147 };
00148 
00149 #endif

Generated on Tue May 1 09:34:40 2007 for LSkat by  doxygen 1.4.6