Console client: Show cards and result at end of hand. All-in still not working.
This commit is contained in:
@@ -45,6 +45,7 @@ namespace pokerth_lib
|
||||
void VisitDealFlopCards(NetPacket p);
|
||||
void VisitDealTurnCard(NetPacket p);
|
||||
void VisitDealRiverCard(NetPacket p);
|
||||
void VisitEndOfHandShowCards(NetPacket p);
|
||||
void VisitEndOfHandHideCards(NetPacket p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,12 @@ namespace pokerth_lib
|
||||
TurnCard,
|
||||
RiverCard,
|
||||
MoneyWon,
|
||||
BestHandPos1,
|
||||
BestHandPos2,
|
||||
BestHandPos3,
|
||||
BestHandPos4,
|
||||
BestHandPos5,
|
||||
CardsValue,
|
||||
}
|
||||
|
||||
public enum ListPropType
|
||||
@@ -195,6 +201,9 @@ namespace pokerth_lib
|
||||
case NetTypeDealRiverCard :
|
||||
tmpPacket = new NetPacketDealRiverCard(size, reader);
|
||||
break;
|
||||
case NetTypeEndOfHandShowCards :
|
||||
tmpPacket = new NetPacketEndOfHandShowCards(size, reader);
|
||||
break;
|
||||
case NetTypeEndOfHandHideCards :
|
||||
tmpPacket = new NetPacketEndOfHandHideCards(size, reader);
|
||||
break;
|
||||
|
||||
@@ -60,6 +60,18 @@ namespace pokerth_lib.src
|
||||
|
||||
WriteGameInfoBlock(w);
|
||||
|
||||
w.Write(tmpPassword);
|
||||
// Add padding.
|
||||
int passwordPadding = passwordWithPadding - tmpPassword.Length;
|
||||
if (passwordPadding > 0)
|
||||
w.Write(new byte[passwordPadding]);
|
||||
|
||||
w.Write(tmpName);
|
||||
// Add padding.
|
||||
int namePadding = nameWithPadding - tmpName.Length;
|
||||
if (namePadding > 0)
|
||||
w.Write(new byte[namePadding]);
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,32 @@ namespace pokerth_lib
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.SecondCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos1,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos2,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos3,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos4,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos5,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
r.ReadUInt16(); // reserved
|
||||
tmpList.Add(PropType.CardsValue,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
tmpList.Add(PropType.MoneyWon,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
tmpList.Add(PropType.PlayerMoney,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
|
||||
tmpRecordList.Add(tmpList);
|
||||
}
|
||||
RecordProperties.Add(RecordPropType.PlayerResult, tmpRecordList);
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitEndOfHandHideCards(this);
|
||||
visitor.VisitEndOfHandShowCards(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
|
||||
@@ -250,6 +250,43 @@ namespace pokerth_lib
|
||||
m_callback.ShowRiverCards(tmpCards);
|
||||
}
|
||||
|
||||
public void VisitEndOfHandShowCards(NetPacket p)
|
||||
{
|
||||
List<Dictionary<NetPacket.PropType, string>> tmpList
|
||||
= p.RecordProperties[NetPacket.RecordPropType.PlayerResult];
|
||||
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;
|
||||
int[] tmpBest = new int[5];
|
||||
tmpBest[0] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos1]);
|
||||
tmpBest[1] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos2]);
|
||||
tmpBest[2] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos3]);
|
||||
tmpBest[3] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos4]);
|
||||
tmpBest[4] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos5]);
|
||||
curPlayer.BestHandPos = tmpBest;
|
||||
curPlayer.CardsValue = Convert.ToInt32(i[NetPacket.PropType.CardsValue]);
|
||||
curPlayer.Money = Convert.ToUInt32(i[NetPacket.PropType.PlayerMoney]);
|
||||
|
||||
m_callback.EndOfHandShowCards(name, tmpCards, curPlayer.CardsValue, false);
|
||||
}
|
||||
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
||||
{
|
||||
uint moneyWon = Convert.ToUInt32(i[NetPacket.PropType.MoneyWon]);
|
||||
if (moneyWon > 0)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
m_callback.PlayerWins(name, moneyWon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void VisitEndOfHandHideCards(NetPacket p)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
@@ -257,7 +294,7 @@ namespace pokerth_lib
|
||||
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||
curPlayer.Money = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerMoney]);
|
||||
|
||||
m_callback.PlayerWinsHideCards(
|
||||
m_callback.PlayerWins(
|
||||
name,
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.MoneyWon]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user