Console client: Now functional, but several features are still missing.
This commit is contained in:
@@ -28,7 +28,8 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
public void InitDone()
|
public void InitDone()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Init successful.");
|
Console.WriteLine("Connection established.");
|
||||||
|
Console.WriteLine("Retrieving list of games...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinedGame(string name)
|
public void JoinedGame(string name)
|
||||||
@@ -69,6 +70,7 @@ namespace pokerth_console
|
|||||||
{
|
{
|
||||||
Console.WriteLine("\n--> {0}: Your turn. Highest set: ${1}. Minimum raise: ${2}. Cash: ${3}.",
|
Console.WriteLine("\n--> {0}: Your turn. Highest set: ${1}. Minimum raise: ${2}. Cash: ${3}.",
|
||||||
Log.StateToString(state), highestSet, minimumRaise, money);
|
Log.StateToString(state), highestSet, minimumRaise, money);
|
||||||
|
Console.WriteLine("Enter: (f)old, (c)heck, ca(l)l, (b)et<num>, (r)aise<num>, (a)ll in");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayersTurn(Hand.State state, string player)
|
public void PlayersTurn(Hand.State state, string player)
|
||||||
@@ -110,9 +112,22 @@ namespace pokerth_console
|
|||||||
Log.CardToString(cards[4]));
|
Log.CardToString(cards[4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AllInState()
|
||||||
|
{
|
||||||
|
Console.WriteLine(); // simply print a newline
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowCards(string name, int[] cards)
|
||||||
|
{
|
||||||
|
Console.WriteLine("{0} shows [{1}, {2}].",
|
||||||
|
name,
|
||||||
|
Log.CardToString(cards[0]),
|
||||||
|
Log.CardToString(cards[1]));
|
||||||
|
}
|
||||||
|
|
||||||
public void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn)
|
public void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn)
|
||||||
{
|
{
|
||||||
Console.WriteLine("{0} {1} [{2}, {3}] - {4}",
|
Console.WriteLine("{0} {1} [{2}, {3}] - {4}.",
|
||||||
name,
|
name,
|
||||||
allIn ? "has" : "shows",
|
allIn ? "has" : "shows",
|
||||||
Log.CardToString(cards[0]),
|
Log.CardToString(cards[0]),
|
||||||
@@ -120,6 +135,11 @@ namespace pokerth_console
|
|||||||
Log.CardsValueToString(cardsValue));
|
Log.CardsValueToString(cardsValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void HandResult()
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
public void PlayerWins(string name, uint moneyWon)
|
public void PlayerWins(string name, uint moneyWon)
|
||||||
{
|
{
|
||||||
Console.WriteLine("{0} wins ${1}.", name, moneyWon);
|
Console.WriteLine("{0} wins ${1}.", name, moneyWon);
|
||||||
@@ -128,6 +148,8 @@ namespace pokerth_console
|
|||||||
public void Error(string message)
|
public void Error(string message)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error: " + message);
|
Console.WriteLine("Error: " + message);
|
||||||
|
Console.WriteLine("Hint: Try using a different nickname.");
|
||||||
|
System.Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-4
@@ -29,21 +29,76 @@ 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("See license.txt for license terms.");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Enter your nickname:");
|
||||||
|
string name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Connecting to server...");
|
||||||
Settings settings = new Settings();
|
Settings settings = new Settings();
|
||||||
PokerTHData data = new PokerTHData("Testuser1");
|
PokerTHData data = new PokerTHData(name);
|
||||||
ConsoleCallback callback = new ConsoleCallback();
|
ConsoleCallback callback = new ConsoleCallback();
|
||||||
Client client = new Client(settings, data, callback);
|
Client client = new Client(settings, data, callback);
|
||||||
client.Connect();
|
client.Connect();
|
||||||
client.Start();
|
client.Start();
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
|
string input;
|
||||||
|
bool joined = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
Console.WriteLine("Open Games:");
|
Console.WriteLine("Open Games:");
|
||||||
Console.Write(data.GameList.ToString());
|
Console.Write(data.GameList.GetOpenGamesString());
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("Enter game id");
|
Console.WriteLine("Enter game id (or press enter to refresh)");
|
||||||
string input = Console.ReadLine();
|
input = Console.ReadLine();
|
||||||
|
} while (input == "" || !Char.IsDigit(input[0]));
|
||||||
|
Console.WriteLine("Joining game...");
|
||||||
uint gameId = Convert.ToUInt32(input);
|
uint gameId = Convert.ToUInt32(input);
|
||||||
client.JoinGame(gameId);
|
client.JoinGame(gameId);
|
||||||
|
if (client.WaitJoinGame(5000))
|
||||||
|
joined = true;
|
||||||
|
else
|
||||||
|
Console.WriteLine("Could not join game.");
|
||||||
|
} while (!joined);
|
||||||
|
Console.WriteLine("Waiting for admin to start the game...");
|
||||||
|
client.WaitStartGame();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
input = Console.ReadLine();
|
input = Console.ReadLine();
|
||||||
|
} while (input == "");
|
||||||
|
Hand.Action action = Hand.Action.None;
|
||||||
|
uint bet = 0;
|
||||||
|
switch (input[0])
|
||||||
|
{
|
||||||
|
case 'f':
|
||||||
|
action = Hand.Action.Fold;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
action = Hand.Action.Check;
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
action = Hand.Action.Call;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
action = Hand.Action.Bet;
|
||||||
|
bet = Convert.ToUInt32(input.Substring(1));
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
action = Hand.Action.Raise;
|
||||||
|
bet = Convert.ToUInt32(input.Substring(1));
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
action = Hand.Action.AllIn;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (action != Hand.Action.None)
|
||||||
|
client.MyAction(action, bet);
|
||||||
|
} while (true);
|
||||||
client.SetTerminateFlag();
|
client.SetTerminateFlag();
|
||||||
client.WaitTermination();
|
client.WaitTermination();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -66,12 +66,14 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public string GetOpenGamesString()
|
||||||
{
|
{
|
||||||
string outString = "";
|
string outString = "";
|
||||||
lock (m_list)
|
lock (m_list)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<uint, GameInfo> i in m_list)
|
foreach (KeyValuePair<uint, GameInfo> i in m_list)
|
||||||
|
{
|
||||||
|
if (i.Value.CurrentMode == GameInfo.Mode.Created)
|
||||||
{
|
{
|
||||||
outString += i.Key;
|
outString += i.Key;
|
||||||
outString += " ";
|
outString += " ";
|
||||||
@@ -79,6 +81,7 @@ namespace pokerth_lib
|
|||||||
outString += '\n';
|
outString += '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return outString;
|
return outString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ namespace pokerth_lib
|
|||||||
void ShowFlopCards(int[] cards);
|
void ShowFlopCards(int[] cards);
|
||||||
void ShowTurnCards(int[] cards);
|
void ShowTurnCards(int[] cards);
|
||||||
void ShowRiverCards(int[] cards);
|
void ShowRiverCards(int[] cards);
|
||||||
|
void AllInState();
|
||||||
|
void ShowCards(string name, int[] cards);
|
||||||
void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn);
|
void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn);
|
||||||
|
void HandResult();
|
||||||
void PlayerWins(string name, uint moneyWon);
|
void PlayerWins(string name, uint moneyWon);
|
||||||
void Error(string message);
|
void Error(string message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
|
||||||
namespace pokerth_lib
|
namespace pokerth_lib
|
||||||
{
|
{
|
||||||
@@ -33,6 +35,8 @@ namespace pokerth_lib
|
|||||||
m_myPlayerId = 0;
|
m_myPlayerId = 0;
|
||||||
m_myGameId = 0;
|
m_myGameId = 0;
|
||||||
m_myName = name;
|
m_myName = name;
|
||||||
|
m_joinGameEvent = new AutoResetEvent(false);
|
||||||
|
m_startGameEvent = new AutoResetEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameInfoList GameList
|
public GameInfoList GameList
|
||||||
@@ -113,6 +117,22 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventWaitHandle JoinGameEvent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_joinGameEvent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventWaitHandle StartGameEvent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_startGameEvent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private GameInfoList m_gameInfoList;
|
private GameInfoList m_gameInfoList;
|
||||||
private PlayerInfoList m_playerInfoList;
|
private PlayerInfoList m_playerInfoList;
|
||||||
private Hand m_curHand;
|
private Hand m_curHand;
|
||||||
@@ -120,5 +140,7 @@ namespace pokerth_lib
|
|||||||
private uint m_myPlayerId;
|
private uint m_myPlayerId;
|
||||||
private uint m_myGameId;
|
private uint m_myGameId;
|
||||||
private string m_myName;
|
private string m_myName;
|
||||||
|
private EventWaitHandle m_joinGameEvent;
|
||||||
|
private EventWaitHandle m_startGameEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ namespace pokerth_lib
|
|||||||
{
|
{
|
||||||
// Connect to the server.
|
// Connect to the server.
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
@@ -58,6 +58,31 @@ namespace pokerth_lib
|
|||||||
SendJoinGame(gameId);
|
SendJoinGame(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool WaitJoinGame(int timeout)
|
||||||
|
{
|
||||||
|
return m_data.JoinGameEvent.WaitOne(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool WaitStartGame()
|
||||||
|
{
|
||||||
|
return m_data.StartGameEvent.WaitOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MyAction(Hand.Action action, uint bet)
|
||||||
|
{
|
||||||
|
NetPacket a = new NetPacketPlayersAction();
|
||||||
|
a.Properties.Add(
|
||||||
|
NetPacket.PropType.GameState,
|
||||||
|
Convert.ToString((int)m_data.CurHand.CurState));
|
||||||
|
a.Properties.Add(
|
||||||
|
NetPacket.PropType.PlayerAction,
|
||||||
|
Convert.ToString((int)action));
|
||||||
|
a.Properties.Add(
|
||||||
|
NetPacket.PropType.PlayerBet,
|
||||||
|
Convert.ToString(bet));
|
||||||
|
m_sender.Send(a);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetTerminateFlag()
|
public void SetTerminateFlag()
|
||||||
{
|
{
|
||||||
m_sender.SetTerminateFlag();
|
m_sender.SetTerminateFlag();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace pokerth_lib
|
|||||||
void VisitInitAck(NetPacket p);
|
void VisitInitAck(NetPacket p);
|
||||||
void VisitGameListNew(NetPacket p);
|
void VisitGameListNew(NetPacket p);
|
||||||
void VisitGameListUpdate(NetPacket p);
|
void VisitGameListUpdate(NetPacket p);
|
||||||
|
void VisitGameListPlayerJoined(NetPacket p);
|
||||||
|
void VisitGameListPlayerLeft(NetPacket p);
|
||||||
void VisitRetrievePlayerInfo(NetPacket p);
|
void VisitRetrievePlayerInfo(NetPacket p);
|
||||||
void VisitPlayerInfo(NetPacket p);
|
void VisitPlayerInfo(NetPacket p);
|
||||||
void VisitCreateGame(NetPacket p);
|
void VisitCreateGame(NetPacket p);
|
||||||
@@ -45,7 +47,9 @@ namespace pokerth_lib
|
|||||||
void VisitDealFlopCards(NetPacket p);
|
void VisitDealFlopCards(NetPacket p);
|
||||||
void VisitDealTurnCard(NetPacket p);
|
void VisitDealTurnCard(NetPacket p);
|
||||||
void VisitDealRiverCard(NetPacket p);
|
void VisitDealRiverCard(NetPacket p);
|
||||||
|
void VisitAllInShowCards(NetPacket p);
|
||||||
void VisitEndOfHandShowCards(NetPacket p);
|
void VisitEndOfHandShowCards(NetPacket p);
|
||||||
void VisitEndOfHandHideCards(NetPacket p);
|
void VisitEndOfHandHideCards(NetPacket p);
|
||||||
|
void VisitError(NetPacket p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ namespace pokerth_lib
|
|||||||
|
|
||||||
public enum PropType
|
public enum PropType
|
||||||
{
|
{
|
||||||
|
ErrorReason,
|
||||||
RequestedVersionMajor,
|
RequestedVersionMajor,
|
||||||
RequestedVersionMinor,
|
RequestedVersionMinor,
|
||||||
PlayerId,
|
PlayerId,
|
||||||
@@ -153,7 +154,8 @@ namespace pokerth_lib
|
|||||||
|
|
||||||
public enum RecordPropType
|
public enum RecordPropType
|
||||||
{
|
{
|
||||||
PlayerResult,
|
PlayerResults,
|
||||||
|
PlayerCards,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NetPacket Create(int type, int size, BinaryReader reader)
|
public static NetPacket Create(int type, int size, BinaryReader reader)
|
||||||
@@ -171,6 +173,12 @@ namespace pokerth_lib
|
|||||||
case NetTypeGameListUpdate :
|
case NetTypeGameListUpdate :
|
||||||
tmpPacket = new NetPacketGameListUpdate(size, reader);
|
tmpPacket = new NetPacketGameListUpdate(size, reader);
|
||||||
break;
|
break;
|
||||||
|
case NetTypeGameListPlayerJoined :
|
||||||
|
tmpPacket = new NetPacketGameListPlayerJoined(size, reader);
|
||||||
|
break;
|
||||||
|
case NetTypeGameListPlayerLeft :
|
||||||
|
tmpPacket = new NetPacketGameListPlayerLeft(size, reader);
|
||||||
|
break;
|
||||||
case NetTypeJoinGameAck :
|
case NetTypeJoinGameAck :
|
||||||
tmpPacket = new NetPacketJoinGameAck(size, reader);
|
tmpPacket = new NetPacketJoinGameAck(size, reader);
|
||||||
break;
|
break;
|
||||||
@@ -201,12 +209,18 @@ namespace pokerth_lib
|
|||||||
case NetTypeDealRiverCard :
|
case NetTypeDealRiverCard :
|
||||||
tmpPacket = new NetPacketDealRiverCard(size, reader);
|
tmpPacket = new NetPacketDealRiverCard(size, reader);
|
||||||
break;
|
break;
|
||||||
|
case NetTypeAllInShowCards :
|
||||||
|
tmpPacket = new NetPacketAllInShowCards(size, reader);
|
||||||
|
break;
|
||||||
case NetTypeEndOfHandShowCards :
|
case NetTypeEndOfHandShowCards :
|
||||||
tmpPacket = new NetPacketEndOfHandShowCards(size, reader);
|
tmpPacket = new NetPacketEndOfHandShowCards(size, reader);
|
||||||
break;
|
break;
|
||||||
case NetTypeEndOfHandHideCards :
|
case NetTypeEndOfHandHideCards :
|
||||||
tmpPacket = new NetPacketEndOfHandHideCards(size, reader);
|
tmpPacket = new NetPacketEndOfHandHideCards(size, reader);
|
||||||
break;
|
break;
|
||||||
|
case NetTypeError :
|
||||||
|
tmpPacket = new NetPacketError(size, reader);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace pokerth_lib
|
|||||||
|
|
||||||
tmpRecordList.Add(tmpList);
|
tmpRecordList.Add(tmpList);
|
||||||
}
|
}
|
||||||
RecordProperties.Add(RecordPropType.PlayerResult, tmpRecordList);
|
RecordProperties.Add(RecordPropType.PlayerResults, tmpRecordList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Accept(INetPacketVisitor visitor)
|
public override void Accept(INetPacketVisitor visitor)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace pokerth_lib
|
|||||||
BinaryWriter w = new BinaryWriter(memStream);
|
BinaryWriter w = new BinaryWriter(memStream);
|
||||||
|
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
w.Write(IPAddress.HostToNetworkOrder((short)12));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
Convert.ToUInt16(Properties[PropType.GameState])));
|
Convert.ToUInt16(Properties[PropType.GameState])));
|
||||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||||
|
|||||||
@@ -71,6 +71,26 @@ namespace pokerth_lib
|
|||||||
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void VisitGameListPlayerJoined(NetPacket p)
|
||||||
|
{
|
||||||
|
GameInfo info = m_data.GameList.GetGameInfo(
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]));
|
||||||
|
List<uint> playerSlots = info.PlayerSlots;
|
||||||
|
playerSlots.Add(
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]));
|
||||||
|
info.PlayerSlots = playerSlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VisitGameListPlayerLeft(NetPacket p)
|
||||||
|
{
|
||||||
|
GameInfo info = m_data.GameList.GetGameInfo(
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]));
|
||||||
|
List<uint> playerSlots = info.PlayerSlots;
|
||||||
|
playerSlots.Remove(
|
||||||
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]));
|
||||||
|
info.PlayerSlots = playerSlots;
|
||||||
|
}
|
||||||
|
|
||||||
public void VisitRetrievePlayerInfo(NetPacket p)
|
public void VisitRetrievePlayerInfo(NetPacket p)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@@ -99,6 +119,7 @@ namespace pokerth_lib
|
|||||||
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);
|
||||||
|
m_data.JoinGameEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitStartEvent(NetPacket p)
|
public void VisitStartEvent(NetPacket p)
|
||||||
@@ -146,6 +167,7 @@ namespace pokerth_lib
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_callback.GameStarted(strPlayers);
|
m_callback.GameStarted(strPlayers);
|
||||||
|
m_data.StartGameEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitHandStart(NetPacket p)
|
public void VisitHandStart(NetPacket p)
|
||||||
@@ -250,10 +272,28 @@ namespace pokerth_lib
|
|||||||
m_callback.ShowRiverCards(tmpCards);
|
m_callback.ShowRiverCards(tmpCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void VisitAllInShowCards(NetPacket p)
|
||||||
|
{
|
||||||
|
List<Dictionary<NetPacket.PropType, string>> tmpList
|
||||||
|
= p.RecordProperties[NetPacket.RecordPropType.PlayerCards];
|
||||||
|
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
||||||
|
{
|
||||||
|
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
||||||
|
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||||
|
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||||
|
int[] tmpCards = new int[2];
|
||||||
|
tmpCards[0] = Convert.ToInt32(i[NetPacket.PropType.FirstCard]);
|
||||||
|
tmpCards[1] = Convert.ToInt32(i[NetPacket.PropType.SecondCard]);
|
||||||
|
curPlayer.Cards = tmpCards;
|
||||||
|
|
||||||
|
m_callback.ShowCards(name, tmpCards);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void VisitEndOfHandShowCards(NetPacket p)
|
public void VisitEndOfHandShowCards(NetPacket p)
|
||||||
{
|
{
|
||||||
List<Dictionary<NetPacket.PropType, string>> tmpList
|
List<Dictionary<NetPacket.PropType, string>> tmpList
|
||||||
= p.RecordProperties[NetPacket.RecordPropType.PlayerResult];
|
= p.RecordProperties[NetPacket.RecordPropType.PlayerResults];
|
||||||
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
||||||
{
|
{
|
||||||
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
||||||
@@ -299,6 +339,11 @@ namespace pokerth_lib
|
|||||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.MoneyWon]));
|
Convert.ToUInt32(p.Properties[NetPacket.PropType.MoneyWon]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void VisitError(NetPacket p)
|
||||||
|
{
|
||||||
|
m_callback.Error(p.Properties[NetPacket.PropType.ErrorReason]);
|
||||||
|
}
|
||||||
|
|
||||||
private PokerTHData m_data;
|
private PokerTHData m_data;
|
||||||
private SenderThread m_sender;
|
private SenderThread m_sender;
|
||||||
private ICallback m_callback;
|
private ICallback m_callback;
|
||||||
|
|||||||
Reference in New Issue
Block a user