Console client: Adding support for password protected games. Fixed issue with custom blinds. Cosmetic changes.
This commit is contained in:
@@ -82,7 +82,7 @@ namespace pokerth_console
|
|||||||
|
|
||||||
public void ActionDone(string name, Hand.Action action, uint curBet, uint money, List<string> nonFoldPlayers)
|
public void ActionDone(string name, Hand.Action action, uint curBet, uint money, List<string> nonFoldPlayers)
|
||||||
{
|
{
|
||||||
Console.WriteLine("{0} {1}. Cash: {2}.", name, Log.ActionToString(action, curBet), money);
|
Console.WriteLine("{0} {1}. Cash: ${2}.", name, Log.ActionToString(action, curBet), money);
|
||||||
if (action == Hand.Action.Fold)
|
if (action == Hand.Action.Fold)
|
||||||
{
|
{
|
||||||
string outPlayers = "";
|
string outPlayers = "";
|
||||||
@@ -103,7 +103,7 @@ namespace pokerth_console
|
|||||||
|
|
||||||
public void ShowPot(uint pot)
|
public void ShowPot(uint pot)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nPot is now {0}.", pot);
|
Console.WriteLine("\nPot is now ${0}.", pot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowFlopCards(int[] cards)
|
public void ShowFlopCards(int[] cards)
|
||||||
|
|||||||
+10
-3
@@ -42,9 +42,16 @@ namespace pokerth_console
|
|||||||
Console.WriteLine("Enter game id (or press enter to refresh)");
|
Console.WriteLine("Enter game id (or press enter to refresh)");
|
||||||
input = Console.ReadLine();
|
input = Console.ReadLine();
|
||||||
} while (input == "" || !Char.IsDigit(input[0]));
|
} while (input == "" || !Char.IsDigit(input[0]));
|
||||||
Console.WriteLine("Joining game...");
|
|
||||||
uint gameId = Convert.ToUInt32(input);
|
uint gameId = Convert.ToUInt32(input);
|
||||||
client.JoinGame(gameId);
|
string password = "";
|
||||||
|
if (data.GameList.HasGame(gameId)
|
||||||
|
&& data.GameList.GetGameInfo(gameId).PasswordProtected)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Enter game password:");
|
||||||
|
password = Console.ReadLine();
|
||||||
|
}
|
||||||
|
Console.WriteLine("Joining game...");
|
||||||
|
client.JoinGame(gameId, password);
|
||||||
// Hack this, because Mono does not support WaitOne(...).
|
// Hack this, because Mono does not support WaitOne(...).
|
||||||
DateTime cur = DateTime.Now;
|
DateTime cur = DateTime.Now;
|
||||||
while (!client.HasJoinedGame())
|
while (!client.HasJoinedGame())
|
||||||
@@ -110,7 +117,7 @@ namespace pokerth_console
|
|||||||
|
|
||||||
static int Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("pokerth_console V0.1 - Copyright (C) 2008 by Lothar May");
|
Console.WriteLine("pokerth_console V0.1.2 - Copyright (C) 2008 by Lothar May");
|
||||||
Console.WriteLine("See COPYING.txt for license terms.");
|
Console.WriteLine("See COPYING.txt for license terms.");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,14 @@ namespace pokerth_lib
|
|||||||
Closed
|
Closed
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameInfo(uint id, string name, Mode mode, List<uint> playerSlots, uint startMoney)
|
public GameInfo(uint id, string name, Mode mode, List<uint> playerSlots, uint startMoney, bool passwordProtected)
|
||||||
: base(id, name)
|
: base(id, name)
|
||||||
{
|
{
|
||||||
m_mutex = new Object();
|
m_mutex = new Object();
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
m_playerSlots = playerSlots;
|
m_playerSlots = playerSlots;
|
||||||
m_startMoney = startMoney;
|
m_startMoney = startMoney;
|
||||||
|
m_passwordProtected = passwordProtected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<uint> PlayerSlots
|
public List<uint> PlayerSlots
|
||||||
@@ -89,9 +90,21 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool PasswordProtected
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_mutex)
|
||||||
|
{
|
||||||
|
return m_passwordProtected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object m_mutex;
|
private Object m_mutex;
|
||||||
private Mode m_mode;
|
private Mode m_mode;
|
||||||
private List<uint> m_playerSlots;
|
private List<uint> m_playerSlots;
|
||||||
readonly private uint m_startMoney;
|
readonly private uint m_startMoney;
|
||||||
|
bool m_passwordProtected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasGame(uint id)
|
||||||
|
{
|
||||||
|
lock (m_list)
|
||||||
|
{
|
||||||
|
return m_list.ContainsKey(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetGameInfo(uint id, GameInfo info)
|
public void SetGameInfo(uint id, GameInfo info)
|
||||||
{
|
{
|
||||||
lock (m_list)
|
lock (m_list)
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ namespace pokerth_lib
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Try IPv6 first.
|
// Try IPv6 first.
|
||||||
IPAddress[] addresses = new IPAddress[2];
|
/*IPAddress[] addresses = new IPAddress[2];
|
||||||
addresses[0] = IPAddress.Parse(m_settings.ServerSettings.IPv6Address);
|
addresses[0] = IPAddress.Parse(m_settings.ServerSettings.IPv6Address);
|
||||||
addresses[1] = IPAddress.Parse(m_settings.ServerSettings.IPv4Address);
|
addresses[1] = IPAddress.Parse(m_settings.ServerSettings.IPv4Address);
|
||||||
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);
|
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);*/
|
||||||
//m_tcpClient.Connect("localhost", 7234);
|
m_tcpClient.Connect("localhost", 7234);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +60,9 @@ namespace pokerth_lib
|
|||||||
SendInit();
|
SendInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinGame(uint gameId)
|
public void JoinGame(uint gameId, string password)
|
||||||
{
|
{
|
||||||
SendJoinGame(gameId);
|
SendJoinGame(gameId, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasJoinedGame()
|
public bool HasJoinedGame()
|
||||||
@@ -119,11 +119,11 @@ namespace pokerth_lib
|
|||||||
m_sender.Send(init);
|
m_sender.Send(init);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SendJoinGame(uint gameId)
|
protected void SendJoinGame(uint gameId, string password)
|
||||||
{
|
{
|
||||||
NetPacket join = new NetPacketJoinGame();
|
NetPacket join = new NetPacketJoinGame();
|
||||||
join.Properties.Add(NetPacket.PropType.GameId, Convert.ToString(gameId));
|
join.Properties.Add(NetPacket.PropType.GameId, Convert.ToString(gameId));
|
||||||
join.Properties.Add(NetPacket.PropType.GamePassword, ""); // no password for now
|
join.Properties.Add(NetPacket.PropType.GamePassword, password);
|
||||||
m_sender.Send(join);
|
m_sender.Send(join);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ namespace pokerth_lib
|
|||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
Properties.Add(PropType.EndRaiseMode,
|
Properties.Add(PropType.EndRaiseMode,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
int numManualBlinds = r.ReadUInt16();
|
int numManualBlinds = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||||
Properties.Add(PropType.ProposedGuiSpeed,
|
Properties.Add(PropType.ProposedGuiSpeed,
|
||||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||||
Properties.Add(PropType.PlayerActionTimeout,
|
Properties.Add(PropType.PlayerActionTimeout,
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace pokerth_lib
|
|||||||
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.
|
||||||
|
|
||||||
|
w.Write(tmpPassword);
|
||||||
// Add padding.
|
// Add padding.
|
||||||
int passwordPadding = passwordWithPadding - tmpPassword.Length;
|
int passwordPadding = passwordWithPadding - tmpPassword.Length;
|
||||||
if (passwordPadding > 0)
|
if (passwordPadding > 0)
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ namespace pokerth_lib
|
|||||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
|
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
|
||||||
p.ListProperties[NetPacket.ListPropType.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]),
|
||||||
|
Convert.ToUInt16(p.Properties[NetPacket.PropType.GamePrivacyFlags]) == 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitGameListUpdate(NetPacket p)
|
public void VisitGameListUpdate(NetPacket p)
|
||||||
|
|||||||
Reference in New Issue
Block a user