Console client: Support for additional network packets. Preparing game.
This commit is contained in:
+60
-1
@@ -25,9 +25,68 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
class GameInfo : IdObject
|
class GameInfo : IdObject
|
||||||
{
|
{
|
||||||
public GameInfo(uint id, string name)
|
public enum Mode
|
||||||
|
{
|
||||||
|
Created = 1,
|
||||||
|
Started,
|
||||||
|
Closed
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum State
|
||||||
|
{
|
||||||
|
Preflop = 0,
|
||||||
|
Flop,
|
||||||
|
Turn,
|
||||||
|
River
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameInfo(uint id, string name, Mode mode, List<uint> playerSlots)
|
||||||
: base(id, name)
|
: base(id, name)
|
||||||
{
|
{
|
||||||
|
m_mode = mode;
|
||||||
|
m_mutex = new Object();
|
||||||
|
m_playerSlots = playerSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<uint> PlayerSlots
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_playerSlots)
|
||||||
|
{
|
||||||
|
// returns a copy(!)
|
||||||
|
return new List<uint>(m_playerSlots);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (m_playerSlots)
|
||||||
|
{
|
||||||
|
m_playerSlots = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mode CurrentMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
return m_mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
m_mode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Mode m_mode;
|
||||||
|
Object m_mutex;
|
||||||
|
List<uint> m_playerSlots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,30 @@ namespace pokerth_console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameInfo GetGameInfo(uint id)
|
||||||
|
{
|
||||||
|
lock (m_list)
|
||||||
|
{
|
||||||
|
return m_list[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetGameInfo(uint id, GameInfo info)
|
||||||
|
{
|
||||||
|
lock (m_list)
|
||||||
|
{
|
||||||
|
m_list[id] = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveGameInfo(uint id)
|
||||||
|
{
|
||||||
|
lock (m_list)
|
||||||
|
{
|
||||||
|
m_list.Remove(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string outString = "";
|
string outString = "";
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
// No lock because only read access.
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,6 +44,7 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
// No lock because only read access.
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
m_gameInfoList = new GameInfoList();
|
m_gameInfoList = new GameInfoList();
|
||||||
m_playerInfoList = new PlayerInfoList();
|
m_playerInfoList = new PlayerInfoList();
|
||||||
|
m_mutex = new Object();
|
||||||
|
m_myPlayerId = 0;
|
||||||
|
m_myGameId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameInfoList GameList
|
public GameInfoList GameList
|
||||||
@@ -47,7 +50,46 @@ namespace pokerth_console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint MyPlayerId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
return m_myPlayerId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
m_myPlayerId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint MyGameId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
return m_myGameId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
m_myGameId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private GameInfoList m_gameInfoList;
|
private GameInfoList m_gameInfoList;
|
||||||
private PlayerInfoList m_playerInfoList;
|
private PlayerInfoList m_playerInfoList;
|
||||||
|
private Object m_mutex;
|
||||||
|
private uint m_myPlayerId;
|
||||||
|
private uint m_myGameId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,18 +84,18 @@ namespace pokerth_console
|
|||||||
protected void SendInit()
|
protected void SendInit()
|
||||||
{
|
{
|
||||||
NetPacket init = new NetPacketInit();
|
NetPacket init = new NetPacketInit();
|
||||||
init.Properties.Add(NetPacket.PropertyType.PropRequestedVersionMajor, "4");
|
init.Properties.Add(NetPacket.PropertyType.RequestedVersionMajor, "5");
|
||||||
init.Properties.Add(NetPacket.PropertyType.PropRequestedVersionMinor, "2");
|
init.Properties.Add(NetPacket.PropertyType.RequestedVersionMinor, "0");
|
||||||
init.Properties.Add(NetPacket.PropertyType.PropPlayerName, "Testuser");
|
init.Properties.Add(NetPacket.PropertyType.PlayerName, "Testuser1");
|
||||||
init.Properties.Add(NetPacket.PropertyType.PropPlayerPassword, "");
|
init.Properties.Add(NetPacket.PropertyType.PlayerPassword, "");
|
||||||
m_sender.Send(init);
|
m_sender.Send(init);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SendJoinGame(uint gameId)
|
protected void SendJoinGame(uint gameId)
|
||||||
{
|
{
|
||||||
NetPacket join = new NetPacketJoinGame();
|
NetPacket join = new NetPacketJoinGame();
|
||||||
join.Properties.Add(NetPacket.PropertyType.PropGameId, Convert.ToString(gameId));
|
join.Properties.Add(NetPacket.PropertyType.GameId, Convert.ToString(gameId));
|
||||||
join.Properties.Add(NetPacket.PropertyType.PropGamePassword, ""); // no password for now
|
join.Properties.Add(NetPacket.PropertyType.GamePassword, ""); // no password for now
|
||||||
m_sender.Send(join);
|
m_sender.Send(join);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,18 @@ namespace pokerth_console
|
|||||||
void VisitInit(NetPacketInit p);
|
void VisitInit(NetPacketInit p);
|
||||||
void VisitInitAck(NetPacketInitAck p);
|
void VisitInitAck(NetPacketInitAck p);
|
||||||
void VisitGameListNew(NetPacketGameListNew p);
|
void VisitGameListNew(NetPacketGameListNew p);
|
||||||
|
void VisitGameListUpdate(NetPacketGameListUpdate p);
|
||||||
void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p);
|
void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p);
|
||||||
void VisitPlayerInfo(NetPacketPlayerInfo p);
|
void VisitPlayerInfo(NetPacketPlayerInfo p);
|
||||||
void VisitJoinGame(NetPacketJoinGame p);
|
void VisitJoinGame(NetPacketJoinGame p);
|
||||||
|
void VisitJoinGameAck(NetPacketJoinGameAck p);
|
||||||
void VisitStartEvent(NetPacketStartEvent p);
|
void VisitStartEvent(NetPacketStartEvent p);
|
||||||
void VisitStartEventAck(NetPacketStartEventAck p);
|
void VisitStartEventAck(NetPacketStartEventAck p);
|
||||||
void VisitGameStart(NetPacketGameStart p);
|
void VisitGameStart(NetPacketGameStart p);
|
||||||
|
void VisitHandStart(NetPacketHandStart p);
|
||||||
|
void VisitPlayersTurn(NetPacketPlayersTurn p);
|
||||||
|
void VisitPlayersAction(NetPacketPlayersAction p);
|
||||||
|
void VisitPlayersActionDone(NetPacketPlayersActionDone p);
|
||||||
|
void VisitPlayersActionRejected(NetPacketPlayersActionRejected p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,24 +90,36 @@ namespace pokerth_console
|
|||||||
|
|
||||||
public enum PropertyType
|
public enum PropertyType
|
||||||
{
|
{
|
||||||
PropRequestedVersionMajor,
|
RequestedVersionMajor,
|
||||||
PropRequestedVersionMinor,
|
RequestedVersionMinor,
|
||||||
PropPlayerId,
|
PlayerId,
|
||||||
PropPlayerName,
|
PlayerName,
|
||||||
PropPlayerPassword,
|
PlayerPassword,
|
||||||
PropPlayerFlags,
|
PlayerFlags,
|
||||||
PropLatestGameVersion,
|
PlayerRights,
|
||||||
PropLatestBetaRevision,
|
PlayerAction,
|
||||||
PropSessionId,
|
PlayerBet,
|
||||||
PropGameId,
|
PlayerBetTotal,
|
||||||
PropGameMode,
|
PlayerMoney,
|
||||||
PropGameName,
|
LatestGameVersion,
|
||||||
PropGamePrivacyFlags,
|
LatestBetaRevision,
|
||||||
PropGamePassword,
|
SessionId,
|
||||||
PropAdminPlayerId,
|
GameId,
|
||||||
PropCurNumPlayers,
|
GameMode,
|
||||||
PropStartFlags,
|
GameName,
|
||||||
PropStartDealerPlayerId
|
GamePrivacyFlags,
|
||||||
|
GamePassword,
|
||||||
|
GameState,
|
||||||
|
AdminPlayerId,
|
||||||
|
CurNumPlayers,
|
||||||
|
StartFlags,
|
||||||
|
StartDealerPlayerId,
|
||||||
|
FirstCard,
|
||||||
|
SecondCard,
|
||||||
|
SmallBlind,
|
||||||
|
HighestSet,
|
||||||
|
MinimumRaise,
|
||||||
|
ActionRejectReason,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ListPropertyType
|
public enum ListPropertyType
|
||||||
@@ -121,18 +133,33 @@ namespace pokerth_console
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
// Only consider those packets which are sent by the server.
|
// Only consider those packets which are sent by the server.
|
||||||
case NetTypeInitAck:
|
case NetTypeInitAck :
|
||||||
tmpPacket = new NetPacketInitAck(size, reader);
|
tmpPacket = new NetPacketInitAck(size, reader);
|
||||||
break;
|
break;
|
||||||
case NetTypeGameListNew:
|
case NetTypeGameListNew :
|
||||||
tmpPacket = new NetPacketGameListNew(size, reader);
|
tmpPacket = new NetPacketGameListNew(size, reader);
|
||||||
break;
|
break;
|
||||||
case NetTypePlayerInfo:
|
case NetTypeGameListUpdate :
|
||||||
|
tmpPacket = new NetPacketGameListUpdate(size, reader);
|
||||||
|
break;
|
||||||
|
case NetTypeJoinGameAck :
|
||||||
|
tmpPacket = new NetPacketJoinGameAck(size, reader);
|
||||||
|
break;
|
||||||
|
case NetTypePlayerInfo :
|
||||||
tmpPacket = new NetPacketPlayerInfo(size, reader);
|
tmpPacket = new NetPacketPlayerInfo(size, reader);
|
||||||
break;
|
break;
|
||||||
case NetTypeStartEvent:
|
case NetTypeStartEvent :
|
||||||
tmpPacket = new NetPacketStartEvent(size, reader);
|
tmpPacket = new NetPacketStartEvent(size, reader);
|
||||||
break;
|
break;
|
||||||
|
case NetTypeGameStart :
|
||||||
|
tmpPacket = new NetPacketGameStart(size, reader);
|
||||||
|
break;
|
||||||
|
case NetTypeHandStart :
|
||||||
|
tmpPacket = new NetPacketHandStart(size, reader);
|
||||||
|
break;
|
||||||
|
case NetTypePlayersTurn :
|
||||||
|
tmpPacket = new NetPacketPlayersTurn(size, reader);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -182,7 +209,7 @@ namespace pokerth_console
|
|||||||
|
|
||||||
public abstract byte[] ToByteArray();
|
public abstract byte[] ToByteArray();
|
||||||
|
|
||||||
protected int AddPadding(int size)
|
static protected int AddPadding(int size)
|
||||||
{
|
{
|
||||||
return ((((size) + 3) / 4) * 4);
|
return ((((size) + 3) / 4) * 4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,25 +69,25 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
if (size < 20)
|
if (size < 20)
|
||||||
throw new NetPacketException("NetPacketGameListNew invalid size.");
|
throw new NetPacketException("NetPacketGameListNew invalid size.");
|
||||||
Properties.Add(PropertyType.PropGameId,
|
Properties.Add(PropertyType.GameId,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
Properties.Add(PropertyType.PropAdminPlayerId,
|
Properties.Add(PropertyType.AdminPlayerId,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
Properties.Add(PropertyType.PropGameMode,
|
Properties.Add(PropertyType.GameMode,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
|
||||||
int gameNameLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
int gameNameLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||||
|
|
||||||
int curNumPlayers = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
int curNumPlayers = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||||
Properties.Add(PropertyType.PropCurNumPlayers, Convert.ToString(curNumPlayers));
|
Properties.Add(PropertyType.CurNumPlayers, Convert.ToString(curNumPlayers));
|
||||||
Properties.Add(PropertyType.PropGamePrivacyFlags,
|
Properties.Add(PropertyType.GamePrivacyFlags,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
|
||||||
r.ReadBytes(28); // Skip game info block for now.
|
r.ReadBytes(28); // Skip game info block for now.
|
||||||
|
|
||||||
// Read name of the game.
|
// Read name of the game.
|
||||||
byte[] tmpName = r.ReadBytes(gameNameLen);
|
byte[] tmpName = r.ReadBytes(gameNameLen);
|
||||||
Properties.Add(PropertyType.PropGameName,
|
Properties.Add(PropertyType.GameName,
|
||||||
Encoding.UTF8.GetString(tmpName));
|
Encoding.UTF8.GetString(tmpName));
|
||||||
// Skip the padding.
|
// Skip the padding.
|
||||||
int namePadding = AddPadding(tmpName.Length) - tmpName.Length;
|
int namePadding = AddPadding(tmpName.Length) - tmpName.Length;
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketGameListUpdateData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t gameId;
|
||||||
|
u_int16_t gameMode;
|
||||||
|
u_int16_t reserved;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketGameListUpdate : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketGameListUpdate()
|
||||||
|
: base(NetPacket.NetTypeGameListUpdate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetPacketGameListUpdate(int size, BinaryReader r)
|
||||||
|
: base(NetPacket.NetTypeGameListUpdate)
|
||||||
|
{
|
||||||
|
if (size != 12)
|
||||||
|
throw new NetPacketException("NetPacketGameListUpdate invalid size.");
|
||||||
|
Properties.Add(PropertyType.GameId,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.GameMode,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitGameListUpdate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,14 +44,14 @@ namespace pokerth_console
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NetPacketGameStart(int size, BinaryReader r)
|
public NetPacketGameStart(int size, BinaryReader r)
|
||||||
: base(NetPacket.NetTypeGameListNew)
|
: base(NetPacket.NetTypeGameStart)
|
||||||
{
|
{
|
||||||
if (size < 20)
|
if (size < 20)
|
||||||
throw new NetPacketException("NetPacketGameStart invalid size.");
|
throw new NetPacketException("NetPacketGameStart invalid size.");
|
||||||
Properties.Add(PropertyType.PropStartDealerPlayerId,
|
Properties.Add(PropertyType.StartDealerPlayerId,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
int curNumPlayers = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
int curNumPlayers = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||||
Properties.Add(PropertyType.PropCurNumPlayers, Convert.ToString(curNumPlayers));
|
Properties.Add(PropertyType.CurNumPlayers, Convert.ToString(curNumPlayers));
|
||||||
r.ReadBytes(2); // reserved
|
r.ReadBytes(2); // reserved
|
||||||
|
|
||||||
// Read player ids.
|
// Read player ids.
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketHandStartData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int16_t yourCard1;
|
||||||
|
u_int16_t yourCard2;
|
||||||
|
u_int32_t smallBlind;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketHandStart : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketHandStart()
|
||||||
|
: base(NetPacket.NetTypeHandStart)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetPacketHandStart(int size, BinaryReader r)
|
||||||
|
: base(NetPacket.NetTypeHandStart)
|
||||||
|
{
|
||||||
|
if (size != 12)
|
||||||
|
throw new NetPacketException("NetPacketHandStart invalid size.");
|
||||||
|
Properties.Add(PropertyType.FirstCard,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
Properties.Add(PropertyType.SecondCard,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
Properties.Add(PropertyType.SmallBlind,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt32())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitHandStart(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,10 +56,10 @@ namespace pokerth_console
|
|||||||
MemoryStream memStream = new MemoryStream();
|
MemoryStream memStream = new MemoryStream();
|
||||||
BinaryWriter w = new BinaryWriter(memStream);
|
BinaryWriter w = new BinaryWriter(memStream);
|
||||||
|
|
||||||
string playerPassword = Properties[PropertyType.PropPlayerPassword];
|
string playerPassword = Properties[PropertyType.PlayerPassword];
|
||||||
byte[] tmpPassword = Encoding.UTF8.GetBytes(playerPassword);
|
byte[] tmpPassword = Encoding.UTF8.GetBytes(playerPassword);
|
||||||
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
||||||
string playerName = Properties[PropertyType.PropPlayerName];
|
string playerName = Properties[PropertyType.PlayerName];
|
||||||
byte[] tmpName = Encoding.UTF8.GetBytes(playerName);
|
byte[] tmpName = Encoding.UTF8.GetBytes(playerName);
|
||||||
int nameWithPadding = AddPadding(tmpName.Length);
|
int nameWithPadding = AddPadding(tmpName.Length);
|
||||||
int size = 16 + passwordWithPadding + nameWithPadding;
|
int size = 16 + passwordWithPadding + nameWithPadding;
|
||||||
@@ -67,9 +67,9 @@ namespace pokerth_console
|
|||||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
Convert.ToUInt16(Properties[PropertyType.PropRequestedVersionMajor])));
|
Convert.ToUInt16(Properties[PropertyType.RequestedVersionMajor])));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
Convert.ToUInt16(Properties[PropertyType.PropRequestedVersionMinor])));
|
Convert.ToUInt16(Properties[PropertyType.RequestedVersionMinor])));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)playerPassword.Length));
|
w.Write(IPAddress.HostToNetworkOrder((short)playerPassword.Length));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)playerName.Length));
|
w.Write(IPAddress.HostToNetworkOrder((short)playerName.Length));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Privacy flags.
|
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Privacy flags.
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
if (size != 16)
|
if (size != 16)
|
||||||
throw new NetPacketException("NetPacketInitAck invalid size.");
|
throw new NetPacketException("NetPacketInitAck invalid size.");
|
||||||
Properties.Add(PropertyType.PropLatestGameVersion,
|
Properties.Add(PropertyType.LatestGameVersion,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
Properties.Add(PropertyType.PropLatestBetaRevision,
|
Properties.Add(PropertyType.LatestBetaRevision,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
Properties.Add(PropertyType.PropSessionId,
|
Properties.Add(PropertyType.SessionId,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
Properties.Add(PropertyType.PropPlayerId,
|
Properties.Add(PropertyType.PlayerId,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace pokerth_console
|
|||||||
MemoryStream memStream = new MemoryStream();
|
MemoryStream memStream = new MemoryStream();
|
||||||
BinaryWriter w = new BinaryWriter(memStream);
|
BinaryWriter w = new BinaryWriter(memStream);
|
||||||
|
|
||||||
string gamePassword = Properties[PropertyType.PropGamePassword];
|
string gamePassword = Properties[PropertyType.GamePassword];
|
||||||
byte[] tmpPassword = Encoding.UTF8.GetBytes(gamePassword);
|
byte[] tmpPassword = Encoding.UTF8.GetBytes(gamePassword);
|
||||||
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
||||||
int size = 12 + passwordWithPadding;
|
int size = 12 + passwordWithPadding;
|
||||||
@@ -61,7 +61,7 @@ namespace pokerth_console
|
|||||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
Convert.ToUInt32(Properties[PropertyType.PropGameId])));
|
Convert.ToUInt32(Properties[PropertyType.GameId])));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
|
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Reserved.
|
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketJoinGameAckData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t gameId;
|
||||||
|
u_int16_t playerRights;
|
||||||
|
u_int16_t reserved;
|
||||||
|
GameInfoData gameData;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketJoinGameAck : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketJoinGameAck()
|
||||||
|
: base(NetPacket.NetTypeJoinGameAck)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetPacketJoinGameAck(int size, BinaryReader r)
|
||||||
|
: base(NetPacket.NetTypeJoinGameAck)
|
||||||
|
{
|
||||||
|
if (size < 12)
|
||||||
|
throw new NetPacketException("NetTypeJoinGameAck invalid size.");
|
||||||
|
Properties.Add(PropertyType.GameId,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.PlayerRights,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
|
||||||
|
// skip game info block
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitJoinGameAck(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,17 +52,17 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
if (size < 16)
|
if (size < 16)
|
||||||
throw new NetPacketException("NetPacketPlayerInfo invalid size.");
|
throw new NetPacketException("NetPacketPlayerInfo invalid size.");
|
||||||
Properties.Add(PropertyType.PropPlayerId,
|
Properties.Add(PropertyType.PlayerId,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
int playerFlags = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
int playerFlags = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||||
Properties.Add(PropertyType.PropPlayerFlags, Convert.ToString(playerFlags));
|
Properties.Add(PropertyType.PlayerFlags, Convert.ToString(playerFlags));
|
||||||
int playerNameLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
int playerNameLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||||
r.ReadUInt32(); // reserved
|
r.ReadUInt32(); // reserved
|
||||||
if ((playerFlags & PlayerFlagAvatar) == PlayerFlagAvatar)
|
if ((playerFlags & PlayerFlagAvatar) == PlayerFlagAvatar)
|
||||||
r.ReadBytes(16); // Skip avatar md5.
|
r.ReadBytes(16); // Skip avatar md5.
|
||||||
|
|
||||||
byte[] tmpName = r.ReadBytes(playerNameLen);
|
byte[] tmpName = r.ReadBytes(playerNameLen);
|
||||||
Properties.Add(PropertyType.PropPlayerName,
|
Properties.Add(PropertyType.PlayerName,
|
||||||
Encoding.UTF8.GetString(tmpName));
|
Encoding.UTF8.GetString(tmpName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketPlayersActionData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int16_t gameState;
|
||||||
|
u_int16_t playerAction;
|
||||||
|
u_int32_t playerBet;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketPlayersAction : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketPlayersAction()
|
||||||
|
: base(NetPacket.NetTypePlayersAction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitPlayersAction(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
MemoryStream memStream = new MemoryStream();
|
||||||
|
BinaryWriter w = new BinaryWriter(memStream);
|
||||||
|
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropertyType.GameState])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropertyType.PlayerAction])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
|
Convert.ToUInt32(Properties[PropertyType.PlayerBet])));
|
||||||
|
|
||||||
|
return memStream.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketPlayersActionDoneData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t playerId;
|
||||||
|
u_int16_t gameState;
|
||||||
|
u_int16_t playerAction;
|
||||||
|
u_int32_t totalPlayerBet;
|
||||||
|
u_int32_t playerMoney;
|
||||||
|
u_int32_t highestSet;
|
||||||
|
u_int32_t minimumRaise;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketPlayersActionDone : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketPlayersActionDone()
|
||||||
|
: base(NetPacket.NetTypePlayersActionDone)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetPacketPlayersActionDone(int size, BinaryReader r)
|
||||||
|
: base(NetPacket.NetTypePlayersActionDone)
|
||||||
|
{
|
||||||
|
if (size != 28)
|
||||||
|
throw new NetPacketException("NetPacketPlayersActionDone invalid size.");
|
||||||
|
Properties.Add(PropertyType.PlayerId,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.GameState,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
Properties.Add(PropertyType.PlayerAction,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
Properties.Add(PropertyType.PlayerBetTotal,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.PlayerMoney,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.HighestSet,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.MinimumRaise,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt32())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitPlayersActionDone(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketPlayersActionRejectedData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int16_t gameState;
|
||||||
|
u_int16_t playerAction;
|
||||||
|
u_int32_t playerBet;
|
||||||
|
u_int16_t rejectionReason;
|
||||||
|
u_int16_t reserved;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketPlayersActionRejected : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketPlayersActionRejected()
|
||||||
|
: base(NetPacket.NetTypePlayersActionRejected)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetPacketPlayersActionRejected(int size, BinaryReader r)
|
||||||
|
: base(NetPacket.NetTypePlayersActionRejected)
|
||||||
|
{
|
||||||
|
if (size != 28)
|
||||||
|
throw new NetPacketException("NetPacketPlayersActionRejected invalid size.");
|
||||||
|
Properties.Add(PropertyType.GameState,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
Properties.Add(PropertyType.PlayerAction,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
Properties.Add(PropertyType.PlayerBet,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.ActionRejectReason,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitPlayersActionRejected(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct GCC_PACKED NetPacketPlayersTurnData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t playerId;
|
||||||
|
u_int16_t gameState;
|
||||||
|
u_int16_t reserved;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pokerth_console
|
||||||
|
{
|
||||||
|
class NetPacketPlayersTurn : NetPacket
|
||||||
|
{
|
||||||
|
public NetPacketPlayersTurn()
|
||||||
|
: base(NetPacket.NetTypePlayersTurn)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetPacketPlayersTurn(int size, BinaryReader r)
|
||||||
|
: base(NetPacket.NetTypePlayersTurn)
|
||||||
|
{
|
||||||
|
if (size != 12)
|
||||||
|
throw new NetPacketException("NetPacketPlayersTurn invalid size.");
|
||||||
|
Properties.Add(PropertyType.PlayerId,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
|
Properties.Add(PropertyType.GameState,
|
||||||
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.VisitPlayersTurn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,7 +54,7 @@ namespace pokerth_console
|
|||||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
Convert.ToUInt32(Properties[PropertyType.PropPlayerId])));
|
Convert.ToUInt32(Properties[PropertyType.PlayerId])));
|
||||||
|
|
||||||
return memStream.ToArray();
|
return memStream.ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
if (size != 8)
|
if (size != 8)
|
||||||
throw new NetPacketException("NetTypeStartEvent invalid size.");
|
throw new NetPacketException("NetTypeStartEvent invalid size.");
|
||||||
Properties.Add(PropertyType.PropStartFlags,
|
Properties.Add(PropertyType.StartFlags,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ namespace pokerth_console
|
|||||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
Convert.ToUInt16(Properties[PropertyType.PropStartFlags])));
|
Convert.ToUInt16(Properties[PropertyType.StartFlags])));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // reserved
|
w.Write(IPAddress.HostToNetworkOrder((short)0)); // reserved
|
||||||
|
|
||||||
return memStream.ToArray();
|
return memStream.ToArray();
|
||||||
|
|||||||
@@ -1,4 +1,23 @@
|
|||||||
using System;
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This file is part of pokerth_console. *
|
||||||
|
* pokerth_console is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Affero General Public License *
|
||||||
|
* as published by the Free Software Foundation, either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|||||||
@@ -38,15 +38,30 @@ namespace pokerth_console
|
|||||||
|
|
||||||
public void VisitInitAck(NetPacketInitAck p)
|
public void VisitInitAck(NetPacketInitAck p)
|
||||||
{
|
{
|
||||||
// TODO
|
m_data.MyPlayerId =
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropertyType.PlayerId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitGameListNew(NetPacketGameListNew p)
|
public void VisitGameListNew(NetPacketGameListNew p)
|
||||||
{
|
{
|
||||||
// Add game to list.
|
// Add game to list.
|
||||||
m_data.GameList.AddGameInfo(new GameInfo(
|
m_data.GameList.AddGameInfo(new GameInfo(
|
||||||
Convert.ToUInt32(p.Properties[NetPacket.PropertyType.PropGameId]),
|
Convert.ToUInt32(p.Properties[NetPacket.PropertyType.GameId]),
|
||||||
p.Properties[NetPacket.PropertyType.PropGameName]));
|
p.Properties[NetPacket.PropertyType.GameName],
|
||||||
|
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropertyType.GameMode]),
|
||||||
|
p.ListProperties[NetPacket.ListPropertyType.PropPlayerSlots].
|
||||||
|
ConvertAll<uint>(Convert.ToUInt32)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VisitGameListUpdate(NetPacketGameListUpdate p)
|
||||||
|
{
|
||||||
|
GameInfo.Mode mode =
|
||||||
|
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropertyType.GameMode]);
|
||||||
|
uint id = Convert.ToUInt32(p.Properties[NetPacket.PropertyType.GameId]);
|
||||||
|
if (mode == GameInfo.Mode.Closed) // Remove game if it is has been closed.
|
||||||
|
m_data.GameList.RemoveGameInfo(id);
|
||||||
|
else
|
||||||
|
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p)
|
public void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p)
|
||||||
@@ -58,8 +73,8 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
// Add player to list.
|
// Add player to list.
|
||||||
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
||||||
Convert.ToUInt32(p.Properties[NetPacket.PropertyType.PropPlayerId]),
|
Convert.ToUInt32(p.Properties[NetPacket.PropertyType.PlayerId]),
|
||||||
p.Properties[NetPacket.PropertyType.PropPlayerName]));
|
p.Properties[NetPacket.PropertyType.PlayerName]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitJoinGame(NetPacketJoinGame p)
|
public void VisitJoinGame(NetPacketJoinGame p)
|
||||||
@@ -67,8 +82,25 @@ namespace pokerth_console
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void VisitJoinGameAck(NetPacketJoinGameAck p)
|
||||||
|
{
|
||||||
|
m_data.MyGameId =
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropertyType.GameId]);
|
||||||
|
}
|
||||||
|
|
||||||
public void VisitStartEvent(NetPacketStartEvent p)
|
public void VisitStartEvent(NetPacketStartEvent p)
|
||||||
{
|
{
|
||||||
|
// Request player names for player ids.
|
||||||
|
List<uint> playerSlots = m_data.GameList.GetGameInfo(m_data.MyGameId).PlayerSlots;
|
||||||
|
foreach (uint id in playerSlots)
|
||||||
|
{
|
||||||
|
if (!m_data.PlayerList.HasPlayer(id))
|
||||||
|
{
|
||||||
|
NetPacketRetrievePlayerInfo request = new NetPacketRetrievePlayerInfo();
|
||||||
|
request.Properties.Add(NetPacket.PropertyType.PlayerId, Convert.ToString(id));
|
||||||
|
m_sender.Send(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Acknowledge start event.
|
// Acknowledge start event.
|
||||||
NetPacketStartEventAck ack = new NetPacketStartEventAck();
|
NetPacketStartEventAck ack = new NetPacketStartEventAck();
|
||||||
m_sender.Send(ack);
|
m_sender.Send(ack);
|
||||||
@@ -81,17 +113,38 @@ namespace pokerth_console
|
|||||||
|
|
||||||
public void VisitGameStart(NetPacketGameStart p)
|
public void VisitGameStart(NetPacketGameStart p)
|
||||||
{
|
{
|
||||||
// Request player names for player ids.
|
throw new NotImplementedException();
|
||||||
List<string> playerList = p.ListProperties[NetPacket.ListPropertyType.PropPlayerSlots];
|
// TODO
|
||||||
foreach (string player in playerList)
|
}
|
||||||
{
|
|
||||||
if (!m_data.PlayerList.HasPlayer(Convert.ToUInt32(player)))
|
public void VisitHandStart(NetPacketHandStart p)
|
||||||
{
|
{
|
||||||
NetPacketRetrievePlayerInfo request = new NetPacketRetrievePlayerInfo();
|
throw new NotImplementedException();
|
||||||
request.Properties.Add(NetPacket.PropertyType.PropPlayerId, player);
|
// TODO
|
||||||
m_sender.Send(request);
|
}
|
||||||
}
|
|
||||||
}
|
public void VisitPlayersTurn(NetPacketPlayersTurn p)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VisitPlayersAction(NetPacketPlayersAction p)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VisitPlayersActionDone(NetPacketPlayersActionDone p)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VisitPlayersActionRejected(NetPacketPlayersActionRejected p)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
private PokerTHData m_data;
|
private PokerTHData m_data;
|
||||||
|
|||||||
@@ -636,8 +636,8 @@ Player Action:
|
|||||||
0x05 - Raise
|
0x05 - Raise
|
||||||
0x06 - All in
|
0x06 - All in
|
||||||
Player Bet:
|
Player Bet:
|
||||||
0 (ignored) - states fold, check,
|
0 (ignored) - actions fold, check,
|
||||||
> 0 - states call, bet, raise, all in
|
> 0 - atcions call, bet, raise, all in
|
||||||
|
|
||||||
Server Notification: Player's Action Done
|
Server Notification: Player's Action Done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user