Console client: Print player action.
This commit is contained in:
@@ -32,31 +32,35 @@ namespace pokerth_lib
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
public void VisitInit(NetPacketInit p)
|
||||
public void VisitInit(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitInitAck(NetPacketInitAck p)
|
||||
public void VisitInitAck(NetPacket p)
|
||||
{
|
||||
m_data.MyPlayerId =
|
||||
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();
|
||||
}
|
||||
|
||||
public void VisitGameListNew(NetPacketGameListNew p)
|
||||
public void VisitGameListNew(NetPacket p)
|
||||
{
|
||||
// Add game to list.
|
||||
m_data.GameList.AddGameInfo(new GameInfo(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]),
|
||||
p.Properties[NetPacket.PropType.GameName],
|
||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
|
||||
p.ListProperties[NetPacket.ListPropertyType.PlayerSlots].
|
||||
p.ListProperties[NetPacket.ListPropType.PlayerSlots].
|
||||
ConvertAll<uint>(Convert.ToUInt32),
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.StartMoney])));
|
||||
}
|
||||
|
||||
public void VisitGameListUpdate(NetPacketGameListUpdate p)
|
||||
public void VisitGameListUpdate(NetPacket p)
|
||||
{
|
||||
GameInfo.Mode mode =
|
||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]);
|
||||
@@ -67,12 +71,12 @@ namespace pokerth_lib
|
||||
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
||||
}
|
||||
|
||||
public void VisitRetrievePlayerInfo(NetPacketRetrievePlayerInfo p)
|
||||
public void VisitRetrievePlayerInfo(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitPlayerInfo(NetPacketPlayerInfo p)
|
||||
public void VisitPlayerInfo(NetPacket p)
|
||||
{
|
||||
// Add player to list.
|
||||
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
||||
@@ -80,19 +84,24 @@ namespace pokerth_lib
|
||||
p.Properties[NetPacket.PropType.PlayerName]));
|
||||
}
|
||||
|
||||
public void VisitJoinGame(NetPacketJoinGame p)
|
||||
public void VisitCreateGame(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitJoinGameAck(NetPacketJoinGameAck p)
|
||||
public void VisitJoinGame(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitJoinGameAck(NetPacket p)
|
||||
{
|
||||
m_data.MyGameId =
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]);
|
||||
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.
|
||||
List<uint> playerSlots = m_data.GameList.GetGameInfo(m_data.MyGameId).PlayerSlots;
|
||||
@@ -110,17 +119,17 @@ namespace pokerth_lib
|
||||
m_sender.Send(ack);
|
||||
}
|
||||
|
||||
public void VisitStartEventAck(NetPacketStartEventAck p)
|
||||
public void VisitStartEventAck(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitGameStart(NetPacketGameStart p)
|
||||
public void VisitGameStart(NetPacket p)
|
||||
{
|
||||
// Generate player list, for gui and as hand data.
|
||||
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);
|
||||
m_players = new Dictionary<uint, Player>();
|
||||
|
||||
@@ -128,8 +137,6 @@ namespace pokerth_lib
|
||||
{
|
||||
if (m_data.PlayerList.HasPlayer(i))
|
||||
strPlayers.Add(m_data.PlayerList.GetPlayerInfo(i).Name);
|
||||
else if (i == m_data.MyPlayerId)
|
||||
strPlayers.Add(m_data.MyName);
|
||||
else
|
||||
strPlayers.Add(Convert.ToString(i));
|
||||
// Set player data.
|
||||
@@ -141,7 +148,7 @@ namespace pokerth_lib
|
||||
m_callback.GameStarted(strPlayers);
|
||||
}
|
||||
|
||||
public void VisitHandStart(NetPacketHandStart p)
|
||||
public void VisitHandStart(NetPacket p)
|
||||
{
|
||||
int[] tmpCards = new int[2];
|
||||
tmpCards[0] =
|
||||
@@ -156,22 +163,41 @@ namespace pokerth_lib
|
||||
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();
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user