Console client: Several fixes, added handling of removed from game event.
This commit is contained in:
@@ -52,6 +52,7 @@ namespace pokerth_lib
|
||||
void VisitEndOfHandShowCards(NetPacket p);
|
||||
void VisitEndOfHandHideCards(NetPacket p);
|
||||
void VisitEndOfGame(NetPacket p);
|
||||
void VisitRemovedFromGame(NetPacket p);
|
||||
void VisitChatText(NetPacket p);
|
||||
void VisitError(NetPacket p);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ namespace pokerth_lib
|
||||
|
||||
public enum PropType
|
||||
{
|
||||
ErrorReason,
|
||||
RequestedVersionMajor,
|
||||
RequestedVersionMinor,
|
||||
PlayerId,
|
||||
@@ -145,6 +144,8 @@ namespace pokerth_lib
|
||||
BestHandPos5,
|
||||
CardsValue,
|
||||
ChatText,
|
||||
ErrorReason,
|
||||
RemoveReason,
|
||||
}
|
||||
|
||||
public enum ListPropType
|
||||
@@ -222,6 +223,9 @@ namespace pokerth_lib
|
||||
case NetTypeEndOfGame :
|
||||
tmpPacket = new NetPacketEndOfGame(size, reader);
|
||||
break;
|
||||
case NetTypeRemovedFromGame :
|
||||
tmpPacket = new NetPacketRemovedFromGame(size, reader);
|
||||
break;
|
||||
case NetTypeChatText :
|
||||
tmpPacket = new NetPacketChatText(size, reader);
|
||||
break;
|
||||
|
||||
@@ -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 NetPacketRemovedFromGame : NetPacket
|
||||
{
|
||||
public NetPacketRemovedFromGame()
|
||||
: base(NetPacket.NetTypeRemovedFromGame)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketRemovedFromGame(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeRemovedFromGame)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketRemovedFromGame invalid size.");
|
||||
Properties.Add(PropType.RemoveReason,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitRemovedFromGame(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,6 @@ namespace pokerth_lib
|
||||
{
|
||||
uint curPlayer = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
Hand.State state = (Hand.State)Convert.ToUInt16(p.Properties[NetPacket.PropType.GameState]);
|
||||
m_data.CurHand.CurState = state;
|
||||
if (curPlayer == m_data.MyPlayerId)
|
||||
m_callback.MyTurn(state, m_data.CurHand.HighestSet,
|
||||
m_data.CurHand.MinimumRaise, m_players[curPlayer].Money);
|
||||
@@ -251,6 +250,7 @@ namespace pokerth_lib
|
||||
|
||||
public void VisitDealFlopCards(NetPacket p)
|
||||
{
|
||||
m_data.CurHand.CurState = Hand.State.Flop;
|
||||
int[] tmpCards = new int[3];
|
||||
tmpCards[0] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopFirstCard]);
|
||||
tmpCards[1] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopSecondCard]);
|
||||
@@ -261,6 +261,7 @@ namespace pokerth_lib
|
||||
|
||||
public void VisitDealTurnCard(NetPacket p)
|
||||
{
|
||||
m_data.CurHand.CurState = Hand.State.Turn;
|
||||
int[] tmpCards = new int[4];
|
||||
m_data.CurHand.TableCards.CopyTo(tmpCards, 0);
|
||||
tmpCards[3] = Convert.ToInt32(p.Properties[NetPacket.PropType.TurnCard]);
|
||||
@@ -270,6 +271,7 @@ namespace pokerth_lib
|
||||
|
||||
public void VisitDealRiverCard(NetPacket p)
|
||||
{
|
||||
m_data.CurHand.CurState = Hand.State.River;
|
||||
int[] tmpCards = new int[5];
|
||||
m_data.CurHand.TableCards.CopyTo(tmpCards, 0);
|
||||
tmpCards[4] = Convert.ToInt32(p.Properties[NetPacket.PropType.RiverCard]);
|
||||
@@ -358,6 +360,11 @@ namespace pokerth_lib
|
||||
m_data.JoinedGame = false;
|
||||
}
|
||||
|
||||
public void VisitRemovedFromGame(NetPacket p)
|
||||
{
|
||||
m_callback.RemovedFromGame();
|
||||
}
|
||||
|
||||
public void VisitChatText(NetPacket p)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
|
||||
Reference in New Issue
Block a user