Console client: Print player action.
This commit is contained in:
@@ -56,6 +56,27 @@ namespace pokerth_console
|
|||||||
h.Players[h.MyPlayerId].Money);
|
h.Players[h.MyPlayerId].Money);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MyTurn(Hand.State state)
|
||||||
|
{
|
||||||
|
Console.WriteLine("--> {0}: Your turn.",
|
||||||
|
Log.StateToString(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayersTurn(Hand.State state, string player)
|
||||||
|
{
|
||||||
|
Console.WriteLine("{0}: {1}'s turn.",
|
||||||
|
Log.StateToString(state),
|
||||||
|
player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ActionDone(string name, Hand.Action action, uint totalBet, uint money, uint highestSet, uint minimumRaise)
|
||||||
|
{
|
||||||
|
Console.WriteLine("{0} acts: {1}. Total bet: {2}. Money left: {3}",
|
||||||
|
name, Log.ActionToString(action), totalBet, money);
|
||||||
|
Console.WriteLine("Highest set: {0}. Minimum raise: {1}",
|
||||||
|
highestSet, minimumRaise);
|
||||||
|
}
|
||||||
|
|
||||||
public void Error(string message)
|
public void Error(string message)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error: " + message);
|
Console.WriteLine("Error: " + message);
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ namespace pokerth_lib
|
|||||||
River
|
River
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Action
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Fold,
|
||||||
|
Check,
|
||||||
|
Call,
|
||||||
|
Bet,
|
||||||
|
Raise,
|
||||||
|
AllIn
|
||||||
|
}
|
||||||
|
|
||||||
public Hand(Dictionary<uint, Player> players, uint myPlayerId, uint smallBlind)
|
public Hand(Dictionary<uint, Player> players, uint myPlayerId, uint smallBlind)
|
||||||
{
|
{
|
||||||
m_mutex = new Object();
|
m_mutex = new Object();
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ namespace pokerth_lib
|
|||||||
void JoinedGame(string name);
|
void JoinedGame(string name);
|
||||||
void GameStarted(List<string> players);
|
void GameStarted(List<string> players);
|
||||||
void HandStarted(Hand h);
|
void HandStarted(Hand h);
|
||||||
|
void MyTurn(Hand.State state);
|
||||||
|
void PlayersTurn(Hand.State state, string player);
|
||||||
|
void ActionDone(string name, Hand.Action action, uint totalBet, uint money, uint highestSet, uint minimumRaise);
|
||||||
void Error(string message);
|
void Error(string message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,5 +77,65 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
return cardString;
|
return cardString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string StateToString(Hand.State state)
|
||||||
|
{
|
||||||
|
string stateString;
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case Hand.State.Preflop :
|
||||||
|
stateString = "Preflop";
|
||||||
|
break;
|
||||||
|
case Hand.State.Flop :
|
||||||
|
stateString = "Flop";
|
||||||
|
break;
|
||||||
|
case Hand.State.Turn :
|
||||||
|
stateString = "Turn";
|
||||||
|
break;
|
||||||
|
case Hand.State.River :
|
||||||
|
stateString = "River";
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
stateString = "Invalid state";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ActionToString(Hand.Action action)
|
||||||
|
{
|
||||||
|
string actionString;
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case Hand.Action.None:
|
||||||
|
actionString = "None";
|
||||||
|
break;
|
||||||
|
case Hand.Action.Fold:
|
||||||
|
actionString = "Fold";
|
||||||
|
break;
|
||||||
|
case Hand.Action.Check:
|
||||||
|
actionString = "Check";
|
||||||
|
break;
|
||||||
|
case Hand.Action.Call:
|
||||||
|
actionString = "Call";
|
||||||
|
break;
|
||||||
|
case Hand.Action.Bet:
|
||||||
|
actionString = "Bet";
|
||||||
|
break;
|
||||||
|
case Hand.Action.Raise:
|
||||||
|
actionString = "Raise";
|
||||||
|
break;
|
||||||
|
case Hand.Action.AllIn:
|
||||||
|
actionString = "All in";
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
actionString = "Unknown action";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return actionString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace pokerth_lib
|
|||||||
public Player()
|
public Player()
|
||||||
{
|
{
|
||||||
m_mutex = new Object();
|
m_mutex = new Object();
|
||||||
|
m_curAction = Hand.Action.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] Cards
|
public int[] Cards
|
||||||
@@ -30,6 +31,24 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hand.Action CurAction
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
return m_curAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
m_curAction = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public uint Money
|
public uint Money
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -48,7 +67,7 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint TotalBet
|
public uint TotalBet
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -68,6 +87,7 @@ namespace pokerth_lib
|
|||||||
|
|
||||||
private Object m_mutex;
|
private Object m_mutex;
|
||||||
private int[] m_cards;
|
private int[] m_cards;
|
||||||
|
private Hand.Action m_curAction;
|
||||||
private uint m_money;
|
private uint m_money;
|
||||||
private uint m_totalBet;
|
private uint m_totalBet;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,23 +23,24 @@ using System.Text;
|
|||||||
|
|
||||||
namespace pokerth_lib
|
namespace pokerth_lib
|
||||||
{
|
{
|
||||||
interface INetPacketVisitor
|
public interface INetPacketVisitor
|
||||||
{
|
{
|
||||||
void VisitInit(NetPacketInit p);
|
void VisitInit(NetPacket p);
|
||||||
void VisitInitAck(NetPacketInitAck p);
|
void VisitInitAck(NetPacket p);
|
||||||
void VisitGameListNew(NetPacketGameListNew p);
|
void VisitGameListNew(NetPacket p);
|
||||||
void VisitGameListUpdate(NetPacketGameListUpdate p);
|
void VisitGameListUpdate(NetPacket p);
|
||||||
void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p);
|
void VisitRetrievePlayerInfo(NetPacket p);
|
||||||
void VisitPlayerInfo(NetPacketPlayerInfo p);
|
void VisitPlayerInfo(NetPacket p);
|
||||||
void VisitJoinGame(NetPacketJoinGame p);
|
void VisitCreateGame(NetPacket p);
|
||||||
void VisitJoinGameAck(NetPacketJoinGameAck p);
|
void VisitJoinGame(NetPacket p);
|
||||||
void VisitStartEvent(NetPacketStartEvent p);
|
void VisitJoinGameAck(NetPacket p);
|
||||||
void VisitStartEventAck(NetPacketStartEventAck p);
|
void VisitStartEvent(NetPacket p);
|
||||||
void VisitGameStart(NetPacketGameStart p);
|
void VisitStartEventAck(NetPacket p);
|
||||||
void VisitHandStart(NetPacketHandStart p);
|
void VisitGameStart(NetPacket p);
|
||||||
void VisitPlayersTurn(NetPacketPlayersTurn p);
|
void VisitHandStart(NetPacket p);
|
||||||
void VisitPlayersAction(NetPacketPlayersAction p);
|
void VisitPlayersTurn(NetPacket p);
|
||||||
void VisitPlayersActionDone(NetPacketPlayersActionDone p);
|
void VisitPlayersAction(NetPacket p);
|
||||||
void VisitPlayersActionRejected(NetPacketPlayersActionRejected p);
|
void VisitPlayersActionDone(NetPacket p);
|
||||||
|
void VisitPlayersActionRejected(NetPacket p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ using System.IO;
|
|||||||
|
|
||||||
namespace pokerth_lib
|
namespace pokerth_lib
|
||||||
{
|
{
|
||||||
abstract class NetPacket
|
public abstract class NetPacket
|
||||||
{
|
{
|
||||||
public const int NetTypeInit = 0x0001;
|
public const int NetTypeInit = 0x0001;
|
||||||
public const int NetTypeInitAck = 0x0002;
|
public const int NetTypeInitAck = 0x0002;
|
||||||
@@ -133,7 +133,7 @@ namespace pokerth_lib
|
|||||||
ActionRejectReason,
|
ActionRejectReason,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ListPropertyType
|
public enum ListPropType
|
||||||
{
|
{
|
||||||
PlayerSlots,
|
PlayerSlots,
|
||||||
ManualBlindSlots,
|
ManualBlindSlots,
|
||||||
@@ -172,13 +172,16 @@ namespace pokerth_lib
|
|||||||
case NetTypePlayersTurn :
|
case NetTypePlayersTurn :
|
||||||
tmpPacket = new NetPacketPlayersTurn(size, reader);
|
tmpPacket = new NetPacketPlayersTurn(size, reader);
|
||||||
break;
|
break;
|
||||||
|
case NetTypePlayersActionDone :
|
||||||
|
tmpPacket = new NetPacketPlayersActionDone(size, reader);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return tmpPacket;
|
return tmpPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScanGameInfoBlock(BinaryReader r)
|
protected void ScanGameInfoBlock(BinaryReader r)
|
||||||
{
|
{
|
||||||
Properties.Add(PropType.MaxNumPlayers,
|
Properties.Add(PropType.MaxNumPlayers,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
@@ -206,14 +209,46 @@ namespace pokerth_lib
|
|||||||
List<string> blindSlots = new List<string>();
|
List<string> blindSlots = new List<string>();
|
||||||
for (int i = 0; i < numManualBlinds; i++)
|
for (int i = 0; i < numManualBlinds; i++)
|
||||||
blindSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
blindSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
ListProperties.Add(ListPropertyType.ManualBlindSlots, blindSlots);
|
ListProperties.Add(ListPropType.ManualBlindSlots, blindSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void WriteGameInfoBlock(BinaryWriter w)
|
||||||
|
{
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.MaxNumPlayers])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.RaiseIntervalMode])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.RaiseSmallBlindInterval])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.RaiseMode])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.EndRaiseMode])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
ListProperties[ListPropType.ManualBlindSlots].Count));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.ProposedGuiSpeed])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
Convert.ToUInt16(Properties[PropType.PlayerActionTimeout])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
|
Convert.ToUInt32(Properties[PropType.FirstSmallBlind])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
|
Convert.ToUInt32(Properties[PropType.EndRaiseSmallBlindValue])));
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
|
Convert.ToUInt32(Properties[PropType.StartMoney])));
|
||||||
|
|
||||||
|
foreach (string s in ListProperties[ListPropType.ManualBlindSlots])
|
||||||
|
{
|
||||||
|
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||||
|
Convert.ToUInt32(s)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetPacket(int type)
|
public NetPacket(int type)
|
||||||
{
|
{
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_properties = new Dictionary<PropType, string>();
|
m_properties = new Dictionary<PropType, string>();
|
||||||
m_listProperties = new Dictionary<ListPropertyType, List<string>>();
|
m_listProperties = new Dictionary<ListPropType, List<string>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<PropType, string> Properties
|
public Dictionary<PropType, string> Properties
|
||||||
@@ -228,7 +263,7 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<ListPropertyType, List<string>> ListProperties
|
public Dictionary<ListPropType, List<string>> ListProperties
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -259,6 +294,6 @@ namespace pokerth_lib
|
|||||||
|
|
||||||
private int m_type;
|
private int m_type;
|
||||||
private Dictionary<PropType, string> m_properties;
|
private Dictionary<PropType, string> m_properties;
|
||||||
private Dictionary<ListPropertyType, List<string>> m_listProperties;
|
private Dictionary<ListPropType, List<string>> m_listProperties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace pokerth_lib
|
namespace pokerth_lib
|
||||||
{
|
{
|
||||||
class NetPacketException : Exception
|
public class NetPacketException : Exception
|
||||||
{
|
{
|
||||||
public NetPacketException(string message)
|
public NetPacketException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace pokerth_lib
|
|||||||
List<string> playerSlots = new List<string>();
|
List<string> playerSlots = new List<string>();
|
||||||
for (int i = 0; i < curNumPlayers; i++)
|
for (int i = 0; i < curNumPlayers; i++)
|
||||||
playerSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
playerSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
ListProperties.Add(ListPropertyType.PlayerSlots, playerSlots);
|
ListProperties.Add(ListPropType.PlayerSlots, playerSlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Accept(INetPacketVisitor visitor)
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace pokerth_lib
|
|||||||
List<string> playerSlots = new List<string>();
|
List<string> playerSlots = new List<string>();
|
||||||
for (int i = 0; i < curNumPlayers; i++)
|
for (int i = 0; i < curNumPlayers; i++)
|
||||||
playerSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
playerSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||||
ListProperties.Add(ListPropertyType.PlayerSlots, playerSlots);
|
ListProperties.Add(ListPropType.PlayerSlots, playerSlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Accept(INetPacketVisitor visitor)
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
|||||||
@@ -32,31 +32,35 @@ namespace pokerth_lib
|
|||||||
m_callback = callback;
|
m_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitInit(NetPacketInit p)
|
public void VisitInit(NetPacket p)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitInitAck(NetPacketInitAck p)
|
public void VisitInitAck(NetPacket p)
|
||||||
{
|
{
|
||||||
m_data.MyPlayerId =
|
m_data.MyPlayerId =
|
||||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||||
|
// Add self to list.
|
||||||
|
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
||||||
|
m_data.MyPlayerId,
|
||||||
|
m_data.MyName));
|
||||||
m_callback.InitDone();
|
m_callback.InitDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitGameListNew(NetPacketGameListNew p)
|
public void VisitGameListNew(NetPacket 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.PropType.GameId]),
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]),
|
||||||
p.Properties[NetPacket.PropType.GameName],
|
p.Properties[NetPacket.PropType.GameName],
|
||||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
|
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
|
||||||
p.ListProperties[NetPacket.ListPropertyType.PlayerSlots].
|
p.ListProperties[NetPacket.ListPropType.PlayerSlots].
|
||||||
ConvertAll<uint>(Convert.ToUInt32),
|
ConvertAll<uint>(Convert.ToUInt32),
|
||||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.StartMoney])));
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.StartMoney])));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitGameListUpdate(NetPacketGameListUpdate p)
|
public void VisitGameListUpdate(NetPacket p)
|
||||||
{
|
{
|
||||||
GameInfo.Mode mode =
|
GameInfo.Mode mode =
|
||||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]);
|
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]);
|
||||||
@@ -67,12 +71,12 @@ namespace pokerth_lib
|
|||||||
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p)
|
public void VisitRetrievePlayerInfo(NetPacket p)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitPlayerInfo(NetPacketPlayerInfo p)
|
public void VisitPlayerInfo(NetPacket p)
|
||||||
{
|
{
|
||||||
// Add player to list.
|
// Add player to list.
|
||||||
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
||||||
@@ -80,19 +84,24 @@ namespace pokerth_lib
|
|||||||
p.Properties[NetPacket.PropType.PlayerName]));
|
p.Properties[NetPacket.PropType.PlayerName]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitJoinGame(NetPacketJoinGame p)
|
public void VisitCreateGame(NetPacket p)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitJoinGameAck(NetPacketJoinGameAck p)
|
public void VisitJoinGame(NetPacket p)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VisitJoinGameAck(NetPacket p)
|
||||||
{
|
{
|
||||||
m_data.MyGameId =
|
m_data.MyGameId =
|
||||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]);
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]);
|
||||||
m_callback.JoinedGame(m_data.GameList.GetGameInfo(m_data.MyGameId).Name);
|
m_callback.JoinedGame(m_data.GameList.GetGameInfo(m_data.MyGameId).Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitStartEvent(NetPacketStartEvent p)
|
public void VisitStartEvent(NetPacket p)
|
||||||
{
|
{
|
||||||
// Request player names for player ids.
|
// Request player names for player ids.
|
||||||
List<uint> playerSlots = m_data.GameList.GetGameInfo(m_data.MyGameId).PlayerSlots;
|
List<uint> playerSlots = m_data.GameList.GetGameInfo(m_data.MyGameId).PlayerSlots;
|
||||||
@@ -110,17 +119,17 @@ namespace pokerth_lib
|
|||||||
m_sender.Send(ack);
|
m_sender.Send(ack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitStartEventAck(NetPacketStartEventAck p)
|
public void VisitStartEventAck(NetPacket p)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitGameStart(NetPacketGameStart p)
|
public void VisitGameStart(NetPacket p)
|
||||||
{
|
{
|
||||||
// Generate player list, for gui and as hand data.
|
// Generate player list, for gui and as hand data.
|
||||||
List<string> strPlayers = new List<string>();
|
List<string> strPlayers = new List<string>();
|
||||||
|
|
||||||
List<uint> slots = p.ListProperties[NetPacket.ListPropertyType.PlayerSlots].
|
List<uint> slots = p.ListProperties[NetPacket.ListPropType.PlayerSlots].
|
||||||
ConvertAll<uint>(Convert.ToUInt32);
|
ConvertAll<uint>(Convert.ToUInt32);
|
||||||
m_players = new Dictionary<uint, Player>();
|
m_players = new Dictionary<uint, Player>();
|
||||||
|
|
||||||
@@ -128,8 +137,6 @@ namespace pokerth_lib
|
|||||||
{
|
{
|
||||||
if (m_data.PlayerList.HasPlayer(i))
|
if (m_data.PlayerList.HasPlayer(i))
|
||||||
strPlayers.Add(m_data.PlayerList.GetPlayerInfo(i).Name);
|
strPlayers.Add(m_data.PlayerList.GetPlayerInfo(i).Name);
|
||||||
else if (i == m_data.MyPlayerId)
|
|
||||||
strPlayers.Add(m_data.MyName);
|
|
||||||
else
|
else
|
||||||
strPlayers.Add(Convert.ToString(i));
|
strPlayers.Add(Convert.ToString(i));
|
||||||
// Set player data.
|
// Set player data.
|
||||||
@@ -141,7 +148,7 @@ namespace pokerth_lib
|
|||||||
m_callback.GameStarted(strPlayers);
|
m_callback.GameStarted(strPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitHandStart(NetPacketHandStart p)
|
public void VisitHandStart(NetPacket p)
|
||||||
{
|
{
|
||||||
int[] tmpCards = new int[2];
|
int[] tmpCards = new int[2];
|
||||||
tmpCards[0] =
|
tmpCards[0] =
|
||||||
@@ -156,22 +163,41 @@ namespace pokerth_lib
|
|||||||
m_callback.HandStarted(m_data.CurHand);
|
m_callback.HandStarted(m_data.CurHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitPlayersTurn(NetPacketPlayersTurn p)
|
public void VisitPlayersTurn(NetPacket p)
|
||||||
{
|
{
|
||||||
// TODO
|
uint curPlayer = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||||
|
Hand.State state = (Hand.State)Convert.ToUInt16(p.Properties[NetPacket.PropType.GameState]);
|
||||||
|
if (curPlayer == m_data.MyPlayerId)
|
||||||
|
m_callback.MyTurn(state);
|
||||||
|
else
|
||||||
|
m_callback.PlayersTurn(state, m_data.PlayerList.GetPlayerInfo(curPlayer).Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitPlayersAction(NetPacketPlayersAction p)
|
public void VisitPlayersAction(NetPacket p)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitPlayersActionDone(NetPacketPlayersActionDone p)
|
public void VisitPlayersActionDone(NetPacket p)
|
||||||
{
|
{
|
||||||
// TODO
|
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||||
|
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||||
|
curPlayer.CurAction =
|
||||||
|
(Hand.Action)Convert.ToUInt16(p.Properties[NetPacket.PropType.PlayerAction]);
|
||||||
|
curPlayer.Money =
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerMoney]);
|
||||||
|
curPlayer.TotalBet =
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerBetTotal]);
|
||||||
|
m_callback.ActionDone(
|
||||||
|
m_data.PlayerList.GetPlayerInfo(playerId).Name,
|
||||||
|
curPlayer.CurAction,
|
||||||
|
curPlayer.TotalBet,
|
||||||
|
curPlayer.Money,
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.HighestSet]),
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.MinimumRaise]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitPlayersActionRejected(NetPacketPlayersActionRejected p)
|
public void VisitPlayersActionRejected(NetPacket p)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user