00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef PLAYER_H
00017 #define PLAYER_H
00018
00019
00020 #include <e32base.h>
00021 #include <es_sock.h>
00022 #include <in_sock.h>
00023 #include "gameconstants.h"
00024 #include "cardgameplayer.h"
00025
00026
00035 class CScabbyQueenPlayer : public CCardGamePlayer
00036 {
00037 public:
00038 static CScabbyQueenPlayer* NewL(CConsoleBase& aConsole, RSocket& aSocket);
00039 ~CScabbyQueenPlayer();
00040
00041 virtual void SendComplete(TInt aError);
00042 virtual void RecvComplete(TInetAddr aRecvAddr,TInt aError);
00043 virtual void TimerComplete();
00044 void ShowHandL();
00045 void GetRightHandPlayerCard();
00046 TInt SendCardNum(TInt aCardNum);
00047
00048 private:
00049 void RecvOfHandComplete();
00050 void RecvOfPlayerNumComplete();
00051 void FindPairsAndRemove();
00052 void RecvOfPlayTokenComplete();
00053 void SendOfCardComplete();
00054 void RecvOfCardComplete();
00055 void SendCard();
00056 void ReceiveNextRole();
00057 void SendGameStatus();
00058 void RecvUpdate();
00059 void SendReadyForUpdateComplete();
00060 void SentTokenRecvSuccess();
00061 void SentCardRecvNotification();
00062 void SentGameStatus();
00063 void SentReadyForToken();
00064 void SendOfCardNumberComplete();
00065 void SentHandSize();
00066 void RecvHandSize();
00067 void SendCardComplete();
00068 void SendAck();
00069 void SendAckAfterRecvCard();
00070 void SendHandSize();
00071 void SendOfHandSizeComplete();
00072 void PrepareToSendCard();
00073 void AckSentAfterRecvWait(TInt aError);
00074
00075 protected:
00076 CScabbyQueenPlayer(CConsoleBase& aConsole, RSocket& aSocket);
00077 void ConstructL();
00078 private:
00079
00080 enum TPlayerSendMode
00081 {
00082 ESendPlayerCard,
00083 ESendReadyForUpdate,
00084 ESendRecvTokenSuccess,
00085 ESendCardRecvNotification,
00086 ESendGameStatus,
00087 ESendReadyForToken,
00088 ESendCardNumber,
00089 ESendOwnHandSize,
00090 EPlayerSendAckSendCard,
00091 EPlayerSendAckRecvHandSize,
00092 EPlayerSendAckRecvCard,
00093 EPlayerSendAckRecvWait
00094 };
00095
00096 enum TPlayerRecvMode
00097 {
00098 EPlayerRecvNum,
00099 EPlayerRecvHand,
00100 EPlayerRecvStatus,
00101 EGameStatus,
00102 EPlayerUpdate,
00103 EDealerReady,
00104 ERecvHandSize,
00105 ERecvCardNum,
00106 ERecvCard
00107 };
00108 CConsoleBase& iConsole;
00109
00110 TSockXfrLength iHandLength;
00111 TPckgBuf<TInt> iSuccess;
00112 TInt iCurrentStatus;
00113 TBool iRecvTimerSet;
00114 RBuf8 iCheckSize;
00115 public:
00116 TInt iResendCount;
00117 TBool iGameOver;
00118 RBuf8 iHand;
00119 TBool iCurrentPlayer;
00120 TPckgBuf<TPlayerStatus> iStatusBuffer;
00121 TPckgBuf<TGameStatus> iGameStatus;
00122 TBool iSendingPlayer;
00123 TBool iFinished;
00124 TBuf8<KCardLength> iReceivedCard;
00125 TBuf8<20> iPlayerUpdate;
00126
00127 TPlayerSendMode iSendMode;
00128 TPlayerRecvMode iRecvMode;
00129
00130 TPckgBuf<TInt> iPlayerNum;
00131 TPckgBuf<TInt> iUpdateSize;
00132 TPckgBuf<TInt> iPeerHandSize;
00133 TPckgBuf<TInt> iCardNum;
00134 TPckgBuf<TInt> iOwnHandSize;
00135 TPckgBuf<TInt> iAck;
00136 TPckgBuf<TInt> iGameOverBuffer;
00137
00138 };
00139
00140
00141 #endif // PLAYER_H