Console client: Show flop/turn/river cards.

This commit is contained in:
lotodore
2008-12-23 23:29:18 +00:00
parent 660168b8aa
commit 60fd3e2010
27 changed files with 361 additions and 178 deletions
+23 -3
View File
@@ -45,7 +45,7 @@ namespace pokerth_console
outPlayers += ", ";
outPlayers += s;
}
Console.WriteLine("Game was started. Players: {0}", outPlayers);
Console.WriteLine("Game was started. Players: {0}.", outPlayers);
}
public void HandStarted(pokerth_lib.Hand h)
@@ -71,12 +71,32 @@ namespace pokerth_console
public void ActionDone(string name, Hand.Action action, uint totalBet, uint money, uint highestSet, uint minimumRaise)
{
Console.WriteLine("{0} acts: {1}. Total bet: {2}. Money left: {3}",
Console.WriteLine("{0} acts: {1}. Total bet: {2}. Money left: {3}.",
name, Log.ActionToString(action), totalBet, money);
Console.WriteLine("Highest set: {0}. Minimum raise: {1}",
Console.WriteLine("Highest set: {0}. Minimum raise: {1}.",
highestSet, minimumRaise);
}
public void ShowFlopCards(int firstFlopCard, int secondFlopCard, int thirdFlopCard)
{
Console.WriteLine("Flop cards: {0} {1} {2}.",
Log.CardToString(firstFlopCard),
Log.CardToString(secondFlopCard),
Log.CardToString(thirdFlopCard));
}
public void ShowTurnCard(int turnCard)
{
Console.WriteLine("Turn card: {0}.",
Log.CardToString(turnCard));
}
public void ShowRiverCard(int riverCard)
{
Console.WriteLine("River card: {0}.",
Log.CardToString(riverCard));
}
public void Error(string message)
{
Console.WriteLine("Error: " + message);
+23 -1
View File
@@ -1,4 +1,23 @@
using System;
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
@@ -13,6 +32,9 @@ namespace pokerth_lib
void MyTurn(Hand.State state);
void PlayersTurn(Hand.State state, string player);
void ActionDone(string name, Hand.Action action, uint totalBet, uint money, uint highestSet, uint minimumRaise);
void ShowFlopCards(int firstFlopCard, int secondFlopCard, int thirdFlopCard);
void ShowTurnCard(int turnCard);
void ShowRiverCard(int riverCard);
void Error(string message);
}
}
+20 -1
View File
@@ -1,4 +1,23 @@
using System;
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
+20 -1
View File
@@ -1,4 +1,23 @@
using System;
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
+3
View File
@@ -42,5 +42,8 @@ namespace pokerth_lib
void VisitPlayersAction(NetPacket p);
void VisitPlayersActionDone(NetPacket p);
void VisitPlayersActionRejected(NetPacket p);
void VisitDealFlopCards(NetPacket p);
void VisitDealTurnCard(NetPacket p);
void VisitDealRiverCard(NetPacket p);
}
}
+14
View File
@@ -131,6 +131,11 @@ namespace pokerth_lib
HighestSet,
MinimumRaise,
ActionRejectReason,
FlopFirstCard,
FlopSecondCard,
FlopThirdCard,
TurnCard,
RiverCard,
}
public enum ListPropType
@@ -175,6 +180,15 @@ namespace pokerth_lib
case NetTypePlayersActionDone :
tmpPacket = new NetPacketPlayersActionDone(size, reader);
break;
case NetTypeDealFlopCards :
tmpPacket = new NetPacketDealFlopCards(size, reader);
break;
case NetTypeDealTurnCard :
tmpPacket = new NetPacketDealTurnCard(size, reader);
break;
case NetTypeDealRiverCard :
tmpPacket = new NetPacketDealRiverCard(size, reader);
break;
default:
break;
}
@@ -0,0 +1,66 @@
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace pokerth_lib.src
{
class NetPacketCreateGame : NetPacket
{
public NetPacketCreateGame()
: base(NetPacket.NetTypeCreateGame)
{
}
public override void Accept(INetPacketVisitor visitor)
{
visitor.VisitCreateGame(this);
}
public override byte[] ToByteArray()
{
MemoryStream memStream = new MemoryStream();
BinaryWriter w = new BinaryWriter(memStream);
string gamePassword = Properties[PropType.GamePassword];
byte[] tmpPassword = Encoding.UTF8.GetBytes(gamePassword);
int passwordWithPadding = AddPadding(tmpPassword.Length);
string gameName = Properties[PropType.GameName];
byte[] tmpName = Encoding.UTF8.GetBytes(gameName);
int nameWithPadding = AddPadding(tmpName.Length);
int numBlindSlots = ListProperties[ListPropType.ManualBlindSlots].Count;
int size = 8 + 28 + numBlindSlots * 4 + passwordWithPadding + nameWithPadding;
w.Write(IPAddress.HostToNetworkOrder((short)Type));
w.Write(IPAddress.HostToNetworkOrder((short)size));
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
w.Write(IPAddress.HostToNetworkOrder((short)gameName.Length));
WriteGameInfoBlock(w);
return memStream.ToArray();
}
}
}
@@ -0,0 +1,60 @@
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace pokerth_lib
{
class NetPacketDealFlopCards : NetPacket
{
public NetPacketDealFlopCards()
: base(NetPacket.NetTypeDealFlopCards)
{
}
public NetPacketDealFlopCards(int size, BinaryReader r)
: base(NetPacket.NetTypeDealFlopCards)
{
if (size != 12)
throw new NetPacketException("NetPacketDealFlopCards invalid size.");
Properties.Add(PropType.FlopFirstCard,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
Properties.Add(PropType.FlopSecondCard,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
Properties.Add(PropType.FlopThirdCard,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
}
public override void Accept(INetPacketVisitor visitor)
{
visitor.VisitDealFlopCards(this);
}
public override byte[] ToByteArray()
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,56 @@
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace pokerth_lib
{
class NetPacketDealRiverCard : NetPacket
{
public NetPacketDealRiverCard()
: base(NetPacket.NetTypeDealRiverCard)
{
}
public NetPacketDealRiverCard(int size, BinaryReader r)
: base(NetPacket.NetTypeDealRiverCard)
{
if (size != 8)
throw new NetPacketException("NetPacketDealRiverCard invalid size.");
Properties.Add(PropType.RiverCard,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
}
public override void Accept(INetPacketVisitor visitor)
{
visitor.VisitDealRiverCard(this);
}
public override byte[] ToByteArray()
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,56 @@
/***************************************************************************
* Copyright (C) 2008 by Lothar May *
* *
* This file is part of pokerth_console. *
* pokerth_console is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* pokerth_console is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the *
* GNU Affero General Public License along with pokerth_console. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace pokerth_lib
{
class NetPacketDealTurnCard : NetPacket
{
public NetPacketDealTurnCard()
: base(NetPacket.NetTypeDealTurnCard)
{
}
public NetPacketDealTurnCard(int size, BinaryReader r)
: base(NetPacket.NetTypeDealTurnCard)
{
if (size != 8)
throw new NetPacketException("NetPacketDealTurnCard invalid size.");
Properties.Add(PropType.TurnCard,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
}
public override void Accept(INetPacketVisitor visitor)
{
visitor.VisitDealTurnCard(this);
}
public override byte[] ToByteArray()
{
throw new NotImplementedException();
}
}
}
@@ -24,36 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED GameInfoData
{
u_int16_t maxNumberOfPlayers;
u_int16_t raiseIntervalMode;
u_int16_t raiseSmallBlindInterval;
u_int16_t raiseMode;
u_int16_t endRaiseMode;
u_int16_t numberOfManualBlinds;
u_int16_t proposedGuiSpeed;
u_int16_t playerActionTimeout;
u_int32_t firstSmallBlind;
u_int32_t endRaiseSmallBlindValue;
u_int32_t startMoney;
};
*/
/*
struct GCC_PACKED NetPacketGameListNewData
{
NetPacketHeader head;
u_int32_t gameId;
u_int32_t adminPlayerId;
u_int16_t gameMode;
u_int16_t gameNameLength;
u_int16_t curNumberOfPlayers;
u_int16_t gameFlags;
GameInfoData gameData;
};
*/
namespace pokerth_lib
{
@@ -24,15 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketGameListUpdateData
{
NetPacketHeader head;
u_int32_t gameId;
u_int16_t gameMode;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,15 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketGameStartData
{
NetPacketHeader head;
u_int32_t startDealerPlayerId;
u_int16_t numberOfPlayers;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,15 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketHandStartData
{
NetPacketHeader head;
u_int16_t yourCard1;
u_int16_t yourCard2;
u_int32_t smallBlind;
};
*/
namespace pokerth_lib
{
-12
View File
@@ -24,18 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketInitData
{
NetPacketHeader head;
u_int16_t requestedVersionMajor;
u_int16_t requestedVersionMinor;
u_int16_t passwordLength;
u_int16_t playerNameLength;
u_int16_t privacyFlags;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
-10
View File
@@ -24,16 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketInitAckData
{
NetPacketHeader head;
u_int16_t latestGameVersion;
u_int16_t latestBetaRevision;
u_int32_t sessionId;
u_int32_t playerId;
};
*/
namespace pokerth_lib
{
-9
View File
@@ -24,15 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketJoinGameData
{
NetPacketHeader head;
u_int32_t gameId;
u_int16_t passwordLength;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,16 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketJoinGameAckData
{
NetPacketHeader head;
u_int32_t gameId;
u_int16_t playerRights;
u_int16_t reserved;
GameInfoData gameData;
};
*/
namespace pokerth_lib
{
@@ -24,16 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketPlayerInfoData
{
NetPacketHeader head;
u_int32_t playerId;
u_int16_t playerFlags;
u_int16_t playerNameLength;
u_int32_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,15 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketPlayersActionData
{
NetPacketHeader head;
u_int16_t gameState;
u_int16_t playerAction;
u_int32_t playerBet;
};
*/
namespace pokerth_lib
{
@@ -24,19 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketPlayersActionDoneData
{
NetPacketHeader head;
u_int32_t playerId;
u_int16_t gameState;
u_int16_t playerAction;
u_int32_t totalPlayerBet;
u_int32_t playerMoney;
u_int32_t highestSet;
u_int32_t minimumRaise;
};
*/
namespace pokerth_lib
{
@@ -24,17 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketPlayersActionRejectedData
{
NetPacketHeader head;
u_int16_t gameState;
u_int16_t playerAction;
u_int32_t playerBet;
u_int16_t rejectionReason;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,15 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketPlayersTurnData
{
NetPacketHeader head;
u_int32_t playerId;
u_int16_t gameState;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,13 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketRetrievePlayerInfoData
{
NetPacketHeader head;
u_int32_t playerId;
};
*/
namespace pokerth_lib
{
@@ -24,14 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketStartEventData
{
NetPacketHeader head;
u_int16_t startFlags;
u_int16_t reserved;
};
*/
namespace pokerth_lib
{
@@ -24,13 +24,6 @@ using System.Net;
using System.Net.Sockets;
using System.IO;
/*
struct GCC_PACKED NetPacketStartEventAckData
{
NetPacketHeader head;
u_int32_t reserved;
};
*/
namespace pokerth_lib
{
+20
View File
@@ -202,6 +202,26 @@ namespace pokerth_lib
// TODO
}
public void VisitDealFlopCards(NetPacket p)
{
m_callback.ShowFlopCards(
Convert.ToInt32(p.Properties[NetPacket.PropType.FlopFirstCard]),
Convert.ToInt32(p.Properties[NetPacket.PropType.FlopSecondCard]),
Convert.ToInt32(p.Properties[NetPacket.PropType.FlopThirdCard]));
}
public void VisitDealTurnCard(NetPacket p)
{
m_callback.ShowTurnCard(
Convert.ToInt32(p.Properties[NetPacket.PropType.TurnCard]));
}
public void VisitDealRiverCard(NetPacket p)
{
m_callback.ShowRiverCard(
Convert.ToInt32(p.Properties[NetPacket.PropType.RiverCard]));
}
private PokerTHData m_data;
private SenderThread m_sender;
private ICallback m_callback;