00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef DEALER_H
00017 #define DEALER_H
00018
00019
00020 #include <e32base.h>
00021 #include <in_sock.h>
00022 #include "gameconstants.h"
00023 #include "cardgamedealer.h"
00024
00025
00026
00027
00034 class CScabbyQueenDealer : public CCardGameDealer
00035 {
00036 public:
00037 static CScabbyQueenDealer* NewL(CConsoleBase& aConsole,
00038 RArray<TInetAddr>& aRemoteNames,
00039 RSocket& aSocket);
00040 ~CScabbyQueenDealer();
00041
00042 virtual void SendComplete(TInt aError);
00043 virtual void RecvComplete(TInetAddr aRecvAddr,TInt aError);
00044 virtual void TimerComplete();
00045 void StartTheGame();
00046 void DealDeckL();
00047 void ShowDeckL();
00048 void SendPlayerNumbers();
00049
00050 private:
00051 void InformReceivingPlayer();
00052 void InformSendingPlayer();
00053 void InformStaticPlayers();
00054 void RecvOfCardComplete();
00055 void RecvOfFinishNotify();
00056 void CheckPlayerStatus();
00057 void DealWithGameStatus(TGameStatus aGameStatus);
00058 void RecvCard();
00059 void ReceivingPlayerInformed(TInt aError);
00060 void StaticPlayersInformed(TInt aError);
00061 void CardSent();
00062 void SendReadyInquiry();
00063 void SendPlayerUpdate();
00064 void PlayerUpdateSent(TInt aError);
00065 void SendOfCheckStatusComplete(TInt aError);
00066 void ReadyInquirySent(TInt aError);
00067 void DealWithStatusFromRecv();
00068 void DealWithStatusFromSender();
00069 void ReceiveCardNum();
00070 void SendHandSize();
00071 void SendCardNumber();
00072 void RecvHandSize(TInt aError);
00073 void SendCompleted(TInt aError);
00074 void RecvOfAckComplete();
00075 void TimerCompleted();
00076 void SentGameOverMessage();
00077 void InformNextGameOver();
00078 void InformStaticPlayersProcess();
00079
00080
00081
00082 protected:
00083 CScabbyQueenDealer(CConsoleBase& aConsole, RArray<TInetAddr>& aRemoteNames, RSocket& aSocket);
00084 void ConstructL();
00085
00086 public:
00087 TBool iGameOver;
00088 TPckgBuf<TGameStatus> iGameStatus;
00089 TPckgBuf<TInt> iPlayerNum;
00090 TInt iCount;
00091 TInt iPlayerToken;
00092 TInt iSender;
00093 TInt iPlayerCount;
00094 TInt iResendCount;
00095 TBuf8<20> iPlayerUpdate;
00096 TBuf8<20> iOldPlayerUpdate;
00097 TPckgBuf<TInt> iUpdateSize;
00098 TPckgBuf<TInt> iSenderHandSize;
00099 TPckgBuf<TInt> iCardNum;
00100 TPckgBuf<TInt> iAck;
00101 TPckgBuf<TInt> iGameOverBuffer;
00102 RArray<TInt> iLostPlayers;
00103
00104 private:
00105
00106 enum TDealerSendMode
00107 {
00108 ESendPlayerNum,
00109 ESendRecvToken,
00110 ESendSendToken,
00111 ESendWaitToken,
00112 ESendCard,
00113 ESendCheckRecvStatus,
00114 ESendCheckSenderStatus,
00115 ESendReadyInquiry,
00116 ESendPlayerUpdate,
00117 ESendHandSize,
00118 ESendPlayerCardNumber,
00119 ESendGameOver
00120 };
00121
00122 enum TDealerRecvMode
00123 {
00124 ERecvSuccess,
00125 ERecvCardNotification,
00126 EDealerRecvCard,
00127 ERecvStatusRecv,
00128 ERecvStatusSender,
00129 ERecvReadyResult,
00130 ERecvUpdateResult,
00131 EDealerRecvHandSize,
00132 EDealerRecvCardNum,
00133 EDealerRecvAck
00134 };
00135
00136 CConsoleBase& iConsole;
00137 TDealerRecvMode iRecvMode;
00138 TDealerSendMode iSendMode;
00139 HBufC8* iFullDeck;
00140 RBuf8 iCheckSize;
00141 TUint iRandom;
00142 TBuf8<KDeckBufferLength> iTempBuffer;
00143 TPckgBuf<TPlayerStatus> iStatusBuffer;
00144 TPckgBuf<TInt> iSuccess;
00145
00146 TInetAddr iSenderAddr;
00147 RArray<TInt> iFinishedPlayers;
00148 RArray<TInt> iCurrentPlayers;
00149 TInt iResponseCount;
00150 TInt iWaitingPlayerCount;
00151 TBuf8<KCardLength> iReceivedCard;
00152 };
00153
00154
00155 #endif // DEALER_H