Console client: Several fixes and improvements (thanks to heyn).
This commit is contained in:
@@ -92,6 +92,6 @@ namespace pokerth_lib
|
||||
private Object m_mutex;
|
||||
private Mode m_mode;
|
||||
private List<uint> m_playerSlots;
|
||||
private uint m_startMoney;
|
||||
readonly private uint m_startMoney;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-2
@@ -53,6 +53,7 @@ namespace pokerth_lib
|
||||
m_players = players;
|
||||
m_myPlayerId = myPlayerId;
|
||||
m_smallBlind = smallBlind;
|
||||
m_pot = 0;
|
||||
}
|
||||
|
||||
public State CurState
|
||||
@@ -73,7 +74,10 @@ namespace pokerth_lib
|
||||
m_state = value;
|
||||
// Reset bets.
|
||||
foreach (KeyValuePair<uint, Player> player in m_players)
|
||||
{
|
||||
m_pot += player.Value.TotalBet;
|
||||
player.Value.TotalBet = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,13 +167,25 @@ namespace pokerth_lib
|
||||
}
|
||||
}
|
||||
|
||||
public uint Pot
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_pot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object m_mutex;
|
||||
private State m_state;
|
||||
private Dictionary<uint, Player> m_players;
|
||||
private int[] m_tableCards;
|
||||
private uint m_myPlayerId;
|
||||
private uint m_smallBlind;
|
||||
readonly private uint m_myPlayerId;
|
||||
readonly private uint m_smallBlind;
|
||||
private uint m_highestSet;
|
||||
private uint m_minimumRaise;
|
||||
private uint m_pot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ namespace pokerth_lib
|
||||
void BigBlind(string name, uint blind);
|
||||
void MyTurn(Hand.State state, uint highestSet, uint minimumRaise, uint money);
|
||||
void PlayersTurn(Hand.State state, string player);
|
||||
void ActionDone(string name, Hand.Action action, uint curBet);
|
||||
void ActionDone(string name, Hand.Action action, uint curBet, uint money, List<string> nonFoldPlayers);
|
||||
void ActionRejected();
|
||||
void ShowPot(uint pot);
|
||||
void ShowFlopCards(int[] cards);
|
||||
void ShowTurnCards(int[] cards);
|
||||
void ShowRiverCards(int[] cards);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace pokerth_lib
|
||||
}
|
||||
}
|
||||
|
||||
private uint m_id;
|
||||
private string m_name;
|
||||
readonly private uint m_id;
|
||||
readonly private string m_name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace pokerth_lib
|
||||
cardString = "Two Pairs, "
|
||||
+ CardCodeToString(secondPart, true)
|
||||
+ " and "
|
||||
+ CardCodeToString(secondPart, true);
|
||||
+ CardCodeToString(thirdPart, true);
|
||||
break;
|
||||
// One Pair
|
||||
case 1 :
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace pokerth_lib
|
||||
private Object m_mutex;
|
||||
private uint m_myPlayerId;
|
||||
private uint m_myGameId;
|
||||
private string m_myName;
|
||||
readonly private string m_myName;
|
||||
private bool m_joinedGame;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,21 @@ namespace pokerth_lib
|
||||
}
|
||||
}
|
||||
|
||||
public string Server
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_server;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_server = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string m_ipv4Address = "";
|
||||
private string m_ipv6Address = "";
|
||||
private string m_server = "";
|
||||
private int m_port = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,19 @@ namespace pokerth_lib
|
||||
public void Connect()
|
||||
{
|
||||
// Connect to the server.
|
||||
// Try IPv6 first.
|
||||
IPAddress[] addresses = new IPAddress[2];
|
||||
addresses[0] = IPAddress.Parse(m_settings.ServerSettings.IPv6Address);
|
||||
addresses[1] = IPAddress.Parse(m_settings.ServerSettings.IPv4Address);
|
||||
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);
|
||||
//m_tcpClient.Connect("localhost", 7234);
|
||||
// If the user specified a server, try this.
|
||||
if (m_settings.ServerSettings.Server.Length > 0)
|
||||
m_tcpClient.Connect(
|
||||
m_settings.ServerSettings.Server, m_settings.ServerSettings.Port);
|
||||
else
|
||||
{
|
||||
// Try IPv6 first.
|
||||
IPAddress[] addresses = new IPAddress[2];
|
||||
addresses[0] = IPAddress.Parse(m_settings.ServerSettings.IPv6Address);
|
||||
addresses[1] = IPAddress.Parse(m_settings.ServerSettings.IPv4Address);
|
||||
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);
|
||||
//m_tcpClient.Connect("localhost", 7234);
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace pokerth_lib
|
||||
public NetPacketPlayersActionRejected(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypePlayersActionRejected)
|
||||
{
|
||||
if (size != 28)
|
||||
if (size != 16)
|
||||
throw new NetPacketException("NetPacketPlayersActionRejected invalid size.");
|
||||
Properties.Add(PropType.GameState,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
|
||||
@@ -236,10 +236,20 @@ namespace pokerth_lib
|
||||
}
|
||||
else
|
||||
{
|
||||
// Collect non-fold players.
|
||||
List<string> nonFoldPlayers = new List<string>();
|
||||
foreach (KeyValuePair<uint, Player> player in m_players)
|
||||
{
|
||||
if (player.Value.CurAction != Hand.Action.Fold)
|
||||
nonFoldPlayers.Add(m_data.PlayerList.GetPlayerInfo(player.Key).Name);
|
||||
}
|
||||
// Inform about action.
|
||||
m_callback.ActionDone(
|
||||
name,
|
||||
curPlayer.CurAction,
|
||||
curBet);
|
||||
curBet,
|
||||
curPlayer.Money,
|
||||
nonFoldPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +266,7 @@ namespace pokerth_lib
|
||||
tmpCards[1] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopSecondCard]);
|
||||
tmpCards[2] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopThirdCard]);
|
||||
m_data.CurHand.TableCards = tmpCards;
|
||||
m_callback.ShowPot(m_data.CurHand.Pot);
|
||||
m_callback.ShowFlopCards(tmpCards);
|
||||
}
|
||||
|
||||
@@ -266,6 +277,7 @@ namespace pokerth_lib
|
||||
m_data.CurHand.TableCards.CopyTo(tmpCards, 0);
|
||||
tmpCards[3] = Convert.ToInt32(p.Properties[NetPacket.PropType.TurnCard]);
|
||||
m_data.CurHand.TableCards = tmpCards;
|
||||
m_callback.ShowPot(m_data.CurHand.Pot);
|
||||
m_callback.ShowTurnCards(tmpCards);
|
||||
}
|
||||
|
||||
@@ -276,6 +288,7 @@ namespace pokerth_lib
|
||||
m_data.CurHand.TableCards.CopyTo(tmpCards, 0);
|
||||
tmpCards[4] = Convert.ToInt32(p.Properties[NetPacket.PropType.RiverCard]);
|
||||
m_data.CurHand.TableCards = tmpCards;
|
||||
m_callback.ShowPot(m_data.CurHand.Pot);
|
||||
m_callback.ShowRiverCards(tmpCards);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user