Console client: Adding support for password protected games. Fixed issue with custom blinds. Cosmetic changes.

This commit is contained in:
lotodore
2008-12-28 01:37:59 +00:00
parent e4ead9e706
commit 128c917a5b
8 changed files with 45 additions and 15 deletions
+2 -2
View File
@@ -82,7 +82,7 @@ namespace pokerth_console
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)
{
string outPlayers = "";
@@ -103,7 +103,7 @@ namespace pokerth_console
public void ShowPot(uint pot)
{
Console.WriteLine("\nPot is now {0}.", pot);
Console.WriteLine("\nPot is now ${0}.", pot);
}
public void ShowFlopCards(int[] cards)
+10 -3
View File
@@ -42,9 +42,16 @@ namespace pokerth_console
Console.WriteLine("Enter game id (or press enter to refresh)");
input = Console.ReadLine();
} while (input == "" || !Char.IsDigit(input[0]));
Console.WriteLine("Joining game...");
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(...).
DateTime cur = DateTime.Now;
while (!client.HasJoinedGame())
@@ -110,7 +117,7 @@ namespace pokerth_console
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();
+14 -1
View File
@@ -32,13 +32,14 @@ namespace pokerth_lib
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)
{
m_mutex = new Object();
m_mode = mode;
m_playerSlots = playerSlots;
m_startMoney = startMoney;
m_passwordProtected = passwordProtected;
}
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 Mode m_mode;
private List<uint> m_playerSlots;
readonly private uint m_startMoney;
bool m_passwordProtected;
}
}
+8
View File
@@ -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)
{
lock (m_list)
+7 -7
View File
@@ -45,11 +45,11 @@ namespace pokerth_lib
else
{
// Try IPv6 first.
IPAddress[] addresses = new IPAddress[2];
/*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);
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);*/
m_tcpClient.Connect("localhost", 7234);
}
}
@@ -60,9 +60,9 @@ namespace pokerth_lib
SendInit();
}
public void JoinGame(uint gameId)
public void JoinGame(uint gameId, string password)
{
SendJoinGame(gameId);
SendJoinGame(gameId, password);
}
public bool HasJoinedGame()
@@ -119,11 +119,11 @@ namespace pokerth_lib
m_sender.Send(init);
}
protected void SendJoinGame(uint gameId)
protected void SendJoinGame(uint gameId, string password)
{
NetPacket join = new NetPacketJoinGame();
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);
}
+1 -1
View File
@@ -314,7 +314,7 @@ namespace pokerth_lib
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
Properties.Add(PropType.EndRaiseMode,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
int numManualBlinds = r.ReadUInt16();
int numManualBlinds = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
Properties.Add(PropType.ProposedGuiSpeed,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
Properties.Add(PropType.PlayerActionTimeout,
+1
View File
@@ -56,6 +56,7 @@ namespace pokerth_lib
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Reserved.
w.Write(tmpPassword);
// Add padding.
int passwordPadding = passwordWithPadding - tmpPassword.Length;
if (passwordPadding > 0)
+2 -1
View File
@@ -57,7 +57,8 @@ namespace pokerth_lib
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
p.ListProperties[NetPacket.ListPropType.PlayerSlots].
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)