بسم الله الرحمن الرحيم
زي ما وعدت ووفيت بس للعلم البوكر مش مظبوط قوي يعنى
انهرضه انا لاقيت ان في ناس محتاجه البوكر قولت انزلو للرجاله الي في المنتده ومحتاج بس تقييم وكلمه شكر منكم علشان الي جاي احله
بكتيييييير
المهم نخش علي الاضاااااااااااااافه بسرعه
هتفتح ملف
Poker.cs
الي في المسار ده
Game\Features\Tournaments
تمام بدلو كلو بده
using System; using System.Collections.Generic; using System.Linq; using System.Text; using HarryPotter.Network; using HarryPotter.Network.GamePackets; namespace HarryPotter.Game { public class HandlePoker { public HandlePoker(byte[] packet, Client.GameState client)// HarryPotter { if (packet == null) return; if (client == null) return; ushort Length = BitConverter.ToUInt16(packet, 0); ushort ID = BitConverter.ToUInt16(packet, 2); ushort ID2 = BitConverter.ToUInt16(packet, 4); switch (ID) { #region 2171 Join table case 2171:// HarryPotter { Game.Entity MyChar = client.Entity; uint TableId = BitConverter.ToUInt32(packet, 8); uint PlayerId = BitConverter.ToUInt32(packet, 12); byte Seat = packet[16]; byte Typ = packet[4]; switch (Typ) { case 0://join table { if (Kernel.PokerTables.ContainsKey(TableId)) { Game.PokerTable T = Kernel.PokerTables[TableId]; if (T.Players.ContainsKey(client.Entity.UID)) T.RemovePlayer(MyChar.UID); if (T.FreeSeat(Seat)) { T.AddNewPlayer(client.Entity, Seat, true); MyChar.PokerTable = T.Id; byte CurrentState = 1; if (!T.Players.ContainsKey(MyChar.UID)) if (T.Watchers.ContainsKey(MyChar.UID)) CurrentState = T.Watchers[MyChar.UID].CurrentState; client.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, CurrentState, T.Nomber)); foreach (Game.PokerPlayer P in T.Players.Values) { if (P.PlayerId == MyChar.UID) continue; client.Send(Game.PokerPackets.PokerPlayerInfo(P.Seat, P.PlayerId, P.CurrentState, T.Nomber)); P.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, CurrentState, T.Nomber)); } foreach (Game.PokerPlayer P in T.Watchers.Values) { if (P.PlayerId == MyChar.UID) continue; client.Send(Game.PokerPackets.PokerPlayerInfo(P.Seat, P.PlayerId, P.CurrentState, T.Nomber)); P.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, CurrentState, T.Nomber)); } if (T.Players.Count == 2 && T.Pot == 0) T.SetNewRound(5);//5 sec } } break; } case 4://watch { if (Kernel.PokerTables.ContainsKey(TableId)) { Game.PokerTable T = Kernel.PokerTables[TableId]; if (T.Players.ContainsKey(MyChar.UID) || T.Watchers.ContainsKey(MyChar.UID)) return; if (T.FreeSeat(Seat)) { T.AddNewPlayer(MyChar, Seat, false); T.Watchers[MyChar.UID].CurrentState = 2; MyChar.PokerTable = T.Id; client.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, 2, T.Nomber)); foreach (Game.PokerPlayer P in T.Players.Values) { if (P.PlayerId == MyChar.UID) continue; client.Send(Game.PokerPackets.PokerPlayerInfo(P.Seat, P.PlayerId, P.CurrentState, T.Nomber)); P.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, 2, T.Nomber)); } foreach (Game.PokerPlayer P in T.Watchers.Values) { if (P.PlayerId == MyChar.UID) continue; client.Send(Game.PokerPackets.PokerPlayerInfo(P.Seat, P.PlayerId, P.CurrentState, T.Nomber)); P.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, 2, T.Nomber)); } } } break; } default: { break; } } break; } #endregion 2171 Join table #region 2093 Player move case 2093:// HarryPotter { byte Typ = packet[6]; Game.Entity MyChar = client.Entity; Game.PokerTable T = new Game.PokerTable(); if (Kernel.PokerTables.ContainsKey(MyChar.PokerTable)) T = MyChar.MyPokerTable; else return; switch (Typ) { default: { T.NewPlayerMove(packet, MyChar.UID); break; } } break; } #endregion 2093 Player move #region 2096 Leave table case 2096:// HarryPotter { Game.Entity MyChar = client.Entity; if (MyChar.MyPokerTable == null) return; if (MyChar.MyPokerTable.Players.ContainsKey(MyChar.UID) && MyChar.MyPokerTable.Pot > 1) { byte[] P = new byte[10]; P[6] = 4; P[9] = 200; MyChar.MyPokerTable.NewPlayerMove(P, MyChar.UID); } else MyChar.MyPokerTable.RemovePlayer(MyChar.UID); client.Send(packet); break; } #endregion 2096 Leave table #region Next Round case 2090:// HarryPotter { byte Typ = packet[6]; Game.Entity MyChar = client.Entity; switch (Typ) { case 1: { if (MyChar.PokerTable > 0) { if (Kernel.PokerTables.ContainsKey(MyChar.PokerTable)) { byte Seat = packet[8]; Game.PokerTable T = MyChar.MyPokerTable; if (T.Players.ContainsKey(client.Entity.UID)) return; if (T.FreeSeat(Seat)) { T.AddNewPlayer(MyChar, Seat, true); byte CurrentState = 1; if (!T.Players.ContainsKey(MyChar.UID)) if (T.Watchers.ContainsKey(MyChar.UID)) { CurrentState = T.Watchers[MyChar.UID].CurrentState; T.Watchers.Remove(MyChar.UID); } client.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, CurrentState, T.Nomber)); foreach (Game.PokerPlayer P in T.Players.Values) { if (P.PlayerId == MyChar.UID) continue; client.Send(Game.PokerPackets.PokerPlayerInfo(P.Seat, P.PlayerId, P.CurrentState, T.Nomber)); P.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, CurrentState, T.Nomber)); } foreach (Game.PokerPlayer P in T.Watchers.Values) { if (P.PlayerId == MyChar.UID) continue; client.Send(Game.PokerPackets.PokerPlayerInfo(P.Seat, P.PlayerId, P.CurrentState, T.Nomber)); P.Send(Game.PokerPackets.PokerPlayerInfo(Seat, MyChar.UID, CurrentState, T.Nomber)); } if (T.Players.Count == 2 && T.Pot == 0) T.SetNewRound(21);//21 sec } } } break; } default: { string D = ""; for (int x = 0; x < packet.Length; x++) D += packet[x].ToString("X") + " "; client.Send(new Message("Unknown type: " + ID + " with length " + packet.Length + " :- " + D, System.Drawing.Color.CadetBlue, Message.Talk)); break; } } break; } #endregion 2090 #region Unknow - List case 2099:// HarryPotter client.Send(packet); break; #endregion } } } public class PokerPackets { public static byte[] PokerTable(PokerTable Table)// HarryPotter { PacketBuilder HarryPotter = new PacketBuilder(2172, 52 + (Table.Players.Count * 6)); HarryPotter.Long(Table.Id); HarryPotter.Long(0); HarryPotter.Long(0); HarryPotter.Short(Table.X);//Table X coord HarryPotter.Short(Table.Y);//Table Y Coord HarryPotter.Long(7217967);//Fixed nomber don't know what it is HarryPotter.Short(0); HarryPotter.Long(Table.Nomber);//table nomber HarryPotter.Int((Table.FreeBet ? 1 : 0));//Limited=0 Unlimited=1 HarryPotter.Int(0); HarryPotter.Short(0); HarryPotter.Long(Table.BetType);//table bet type 1=Silver 0=CPs HarryPotter.Long(Table.MinLimit); HarryPotter.Int((byte)Table.State);//table state 0=unopened 1=Pocket 2=flop 3=turn 4=river 5=showdown HarryPotter.ULong(Table.Pot);//Pot HarryPotter.Int(Table.Players.Count);//Players Count foreach (PokerPlayer Player in Table.Players.Values) { if (Player.MyChar == null) { HarryPotter.Move(6); continue; } HarryPotter.Long(Player.PlayerId); HarryPotter.Int(Player.Seat); HarryPotter.Int(Player.Connected ? 1 : 0); } return HarryPotter.getFinal(); } public static byte[] PokerJoinAction(uint TableId, uint PlayerId, byte Req, byte Seat)// HarryPotter { PacketBuilder HarryPotter = new PacketBuilder(2171, 20); HarryPotter.Long(Req); HarryPotter.Long(TableId); HarryPotter.Long(PlayerId); HarryPotter.Long(Seat); return HarryPotter.getFinal(); } public static byte[] PokerPlayerInfo(byte Seat, uint PlayerId, byte State, byte TableNo)// HarryPotter { byte[] HarryPotter = new byte[25 + 8]; Writer.Ushort(25, 0, HarryPotter); Writer.Ushort(2090, 2, HarryPotter); Writer.Byte(1, 4, HarryPotter); Writer.Byte(State, 5, HarryPotter); Writer.Byte(Seat, 7, HarryPotter); Writer.Byte(TableNo, 9, HarryPotter); Writer.Uint(PlayerId, 13, HarryPotter); return HarryPotter.ToArray(); } public static byte[] PokerCards1Card(PokerTable T)// HarryPotter { PacketBuilder HarryPotter = new PacketBuilder(2091, 44 + T.Players.Count * 8); HarryPotter.Short(7); HarryPotter.Short(4); HarryPotter.Long(0); HarryPotter.Long(0); HarryPotter.Long(0); HarryPotter.Long(0); HarryPotter.Long(0); HarryPotter.Short(0); HarryPotter.Short(T.Players.Count); HarryPotter.Long(T._StartingPlayer); HarryPotter.Long(0); HarryPotter.Long(0); foreach (PokerPlayer Pl in T.Players.Values) { foreach (PokerCard C in Pl.MyCards.Values) { HarryPotter.Short(C.Val); HarryPotter.Short((byte)C.Typ); } HarryPotter.Long(Pl.PlayerId); } return HarryPotter.getFinal(); } public static byte[] PokerCards2Cards(PokerTable T, Dictionary<byte, PokerCard> Cards) // Card in list { PacketBuilder HarryPotter = new PacketBuilder(2091, 44 + T.Players.Count * 8); HarryPotter.Long(0); HarryPotter.Short(2); foreach (PokerCard C in Cards.Values) { HarryPotter.Short(C.Val); } HarryPotter.Short(0); HarryPotter.Long(0); foreach (PokerCard C in Cards.Values) { HarryPotter.Short((byte)C.Typ); } HarryPotter.Short(0); HarryPotter.Long(0); HarryPotter.Short(T.Players.Count); HarryPotter.Long(T._StartingPlayer); HarryPotter.Long(T.GetLastPlayer()); HarryPotter.Long(T.GetNextPlayer()); foreach (PokerPlayer Pl in T.Players.Values) { HarryPotter.Short(13); HarryPotter.Short(4); HarryPotter.Long(Pl.PlayerId); } Console.WriteLine("A"); return HarryPotter.getFinal(); } public static byte[] PokerTableCards(Dictionary<byte, PokerCard> Cards, PokerTable T, byte RoundStage) // Card in Table { PacketBuilder HarryPotter = new PacketBuilder(2091, 44); HarryPotter.Short(0); HarryPotter.Short(RoundStage); HarryPotter.Short(Cards.Count); foreach (PokerCard C in Cards.Values) { HarryPotter.Short(C.Val); } for (byte x = 0; x < 5 - Cards.Count; x++) HarryPotter.Short(0); foreach (PokerCard C in Cards.Values) { HarryPotter.Short((byte)C.Typ); } for (byte x = 0; x < 5 - Cards.Count; x++) HarryPotter.Short(0); HarryPotter.Short(0); HarryPotter.Long(T._StartingPlayer); HarryPotter.Long(T.GetLastPlayer()); HarryPotter.Long(T.GetNextPlayer()); return HarryPotter.getFinal(); } public static byte[] PokerPlayerTurn(uint Id1, uint LastBet, uint RequierdBet, byte Type, byte TimeDown) // HarryPotter { byte[] HarryPotter = new byte[28 + 8];// HarryPotter Writer.Ushort(28, 0, HarryPotter); Writer.Ushort(2092, 2, HarryPotter); Writer.Ushort(TimeDown, 4, HarryPotter); //timer count Writer.Ushort(Type, 6, HarryPotter); //Type Writer.Ulong(LastBet, 8, HarryPotter); //last bet Writer.Ulong(RequierdBet, 16, HarryPotter); //requierd bet Writer.Ulong(Id1, 24, HarryPotter); //PlayerId return HarryPotter.ToArray(); } public static byte[] PokerPlayerMove(uint PlayerId, byte Typ, uint Bet, uint RequierdBet)// HarryPotter { PacketBuilder HarryPotter = new PacketBuilder(2093, 20);// HarryPotter HarryPotter.Short(0); HarryPotter.Short(Typ);//move type 32 =all in one HarryPotter.Long(Bet);//player bet HarryPotter.Long(RequierdBet);//requierd bet HarryPotter.Long(PlayerId); return HarryPotter.getFinal(); } public static byte[] PokerShowAllCards(PokerTable T)// HarryPotter { PacketBuilder HarryPotter = new PacketBuilder(2094, 8 + T.Players.Count * 12); HarryPotter.Short(0);// HarryPotter.Short(T.Players.Count); foreach (PokerPlayer Pl in T.Players.Values) { byte Card1Val = 0, Card1Type = 0, Card2Val = 0, Card2Type = 0; byte Co = 0; foreach (PokerCard C in Pl.MyCards.Values) { Co++; if (Co == 1) { Card1Val = C.Val; Card1Type = (byte)C.Typ; } else if (Co == 2) { Card2Val = C.Val; Card2Type = (byte)C.Typ; } } HarryPotter.Short(Card1Val); HarryPotter.Short(Card2Val); HarryPotter.Short(Card1Type); HarryPotter.Short(Card2Type); HarryPotter.Long(Pl.PlayerId); } return HarryPotter.getFinal(); } public static byte[] PokerRoundResult(PokerTable T, uint WinnerId, uint MoneyWins) { PacketBuilder HarryPotter = new PacketBuilder(2095, 8 + T.Players.Count * 15); HarryPotter.Short(20);//Timer HarryPotter.Short(T.Players.Count); HarryPotter.Int(0); HarryPotter.Int(0); HarryPotter.Int(0); HarryPotter.Long(WinnerId); HarryPotter.Long(MoneyWins); HarryPotter.Long(0); foreach (PokerPlayer Pl in T.Players.Values) { try { byte ContinuePlaying = 0; if (Pl.PlayerId == WinnerId) continue; if (T.BetType == 0) if (Pl.MyChar.Money >= T.MinLimit * 10) ContinuePlaying = 0; else ContinuePlaying = 1; else if (T.BetType == 1) if (Pl.MyChar.ConquerPoints >= T.MinLimit * 10) ContinuePlaying = 0; else ContinuePlaying = 1; if (ContinuePlaying == 0) HarryPotter.Int(0); else { HarryPotter.Int(1); Pl.CurrentState = 2; } HarryPotter.Int(255); HarryPotter.Int(0); HarryPotter.Long(Pl.PlayerId); HarryPotter.Long(0xffffffff - Pl.Bet); HarryPotter.Short(0xffff); HarryPotter.Short(0xffff); } catch { HarryPotter.Int(0); HarryPotter.Int(255); HarryPotter.Int(0); HarryPotter.Long(Pl.PlayerId); HarryPotter.Long(0xffffffff - Pl.Bet); HarryPotter.Short(0xffff); HarryPotter.Short(0xffff); } } return HarryPotter.getFinal(); } public static byte[] PokerLeaveTable(uint Id1) { PacketBuilder HarryPotter = new PacketBuilder(2096, 16); HarryPotter.Long(1);// HarryPotter.Long(0); HarryPotter.Long(Id1); return HarryPotter.getFinal(); } public static byte[] PokerTableState(PokerTable T, byte CountDown) { PacketBuilder HarryPotter = new PacketBuilder(2098, 45 + T.Players.Count * 11); uint Id1 = 0, Id2 = 0, Id3 = 0, Id4 = 0, Id5 = 0, Id6 = 0; byte Counter = 0; foreach (PokerPlayer Pl in T.Players.Values) { Counter++; if (Counter == 1) Id1 = Pl.PlayerId; else if (Counter == 2) Id2 = Pl.PlayerId; else if (Counter == 3) Id3 = Pl.PlayerId; else if (Counter == 4) Id4 = Pl.PlayerId; else if (Counter == 5) Id5 = Pl.PlayerId; else if (Counter == 6) Id6 = Pl.PlayerId; } HarryPotter.Short(0); HarryPotter.Int(T.Players.Count);//Players Count HarryPotter.Int(CountDown);//Time Count Down HarryPotter.Int(0); HarryPotter.Short(0); HarryPotter.Long(0); HarryPotter.Long(0); HarryPotter.Long(Id1); HarryPotter.Long(Id2); HarryPotter.Long(Id3); HarryPotter.Long(Id4); HarryPotter.Long(Id5); HarryPotter.Long(Id6); HarryPotter.Short(0); foreach (PokerPlayer Pl in T.Players.Values) { HarryPotter.Int(2); HarryPotter.Int(4); HarryPotter.Int(13); HarryPotter.Int(0); HarryPotter.Int(4); HarryPotter.Int(13); HarryPotter.Int(0); HarryPotter.Long(Pl.PlayerId); } return HarryPotter.getFinal(); } } public class PokerTable { public uint Pis = 0; public uint Pis1 = 0; public uint Pis2 = 0; public uint Id = 0; public byte Nomber = 0; public uint Map = 0; public ushort X = 0; public ushort Y = 0; public uint MinLimit = 100000; public bool FreeBet = true; public byte _State = (byte)PokerTableState.UnOpened; public byte StartSeat = 0; public byte CurrentSeat = 0; public uint _StartingPlayer = 0; public byte RoundStage = 0; public uint RoundMaxBet = 0; public System.Timers.Timer RoundTimer = new System.Timers.Timer(); public System.Timers.Timer MoveTimer = new System.Timers.Timer(); public PokerTableState State { get { return (PokerTableState)_State; } set { _State = (byte)value; } } public uint Pot = 0; public byte BetType = 1;//Silver=0 CPs=1; public Dictionary<uint, PokerPlayer> Players = new Dictionary<uint, PokerPlayer>(10); public Dictionary<byte, PokerPlayer> Seats { get { Dictionary<byte, PokerPlayer> Ses = new Dictionary<byte, PokerPlayer>(10); foreach (PokerPlayer P in Players.Values) { if (P.CurrentState == 1) Ses.Add(P.Seat, P); } return Ses; } } public Dictionary<uint, PokerPlayer> Watchers = new Dictionary<uint, PokerPlayer>(10); public Dictionary<byte, PokerCard> Cards = new Dictionary<byte, PokerCard>(52); public Dictionary<byte, PokerCard> TableCards = new Dictionary<byte, PokerCard>(5); public uint PlayerBySeat(byte S) { uint I = 0; foreach (PokerPlayer P in Players.Values) if (P.Seat == S) I = P.PlayerId; return I; } public uint GetStartingPlayer() { if (Players.Count < 2) return 0; uint I = 0; StartSeat++; if (StartSeat > 9) StartSeat = 0; for (byte x = StartSeat; x < 10; x++) { I = PlayerBySeat(x); if (I > 0) { StartSeat = x; break; } } if (I == 0) { for (byte x = 0; x < StartSeat; x++) { I = PlayerBySeat(x); if (I > 0) { StartSeat = x; break; } } } return I; } public PokerPlayer StartingPlayer { get { if (Players.ContainsKey(_StartingPlayer)) return Players[_StartingPlayer]; else return null; } } public uint GetNextPlayer() { if (Players.Count < 2) return 0; uint I = 0; byte StartSe = StartSeat; if (StartSe > 9) StartSe = 0; for (byte x = StartSe; x < 10; x++) { I = PlayerBySeat(x); if (I > 0) { if (I == GetLastPlayer()) continue; break; } } if (I == 0) { for (byte x = 0; x < StartSe; x++) { I = PlayerBySeat(x); if (I > 0) { if (I == GetLastPlayer()) continue; break; } } } return I; } public uint GetLastPlayer() { if (Players.Count < 2) return 0; uint I = 0; byte CurrentSeat = StartSeat; if (CurrentSeat < 1) CurrentSeat = 9; for (byte x = CurrentSeat; x > 0; x--) { I = PlayerBySeat(x); if (I > 0) { break; } } if (I == 0) { if (PlayerBySeat(0) > 0) return PlayerBySeat(0); for (byte x = 9; x > StartSeat; x--) { I = PlayerBySeat(x); if (I > 0) { break; } } } return I; } public void SetNewRound(byte CountDown) { Dictionary<uint, PokerPlayer> NotConnectedAnymore = new Dictionary<uint, PokerPlayer>(); foreach (PokerPlayer P in Players.Values) { if (!P.Connected) NotConnectedAnymore.Add(P.PlayerId, P); else if (P.CurrentState == 2) if (!Watchers.ContainsKey(P.PlayerId)) Watchers.Add(P.PlayerId, P); } foreach (PokerPlayer P in NotConnectedAnymore.Values) RemovePlayer(P.PlayerId); foreach (PokerPlayer P in Watchers.Values) { if (P.CurrentState == 3) { if (!Players.ContainsKey(P.PlayerId)) Players.Add(P.PlayerId, P); } else if (P.CurrentState == 2) { if (Players.ContainsKey(P.PlayerId)) Players.Remove(P.PlayerId); } } foreach (PokerPlayer P in Players.Values) { if (Watchers.ContainsKey(P.PlayerId)) Watchers.Remove(P.PlayerId); P.MyCards.Clear(); P.CurrentState = 1; P.RoundState = 0; P.HandVals = ""; P.Bet = MinLimit; if (BetType == 0) { if (P.MyChar.Money >= MinLimit) P.MyChar.Money -= MinLimit; else P.MyChar.Money = 0; } else if (BetType == 1) { if (P.MyChar.ConquerPoints >= MinLimit) P.MyChar.ConquerPoints -= MinLimit; else P.MyChar.ConquerPoints = 0; } } Cards.Clear(); TableCards.Clear(); RoundStage = 0; for (byte Y = 0; Y < 4; Y++) { PokerCardsType T = PokerCardsType.Hearts; if (Y == 1) T = PokerCardsType.Spades; else if (Y == 2) T = PokerCardsType.Clubs; else if (Y == 3) T = PokerCardsType.Diamonds; for (byte x = 0; x < 13; x++) { PokerCard Pc = new PokerCard(); Pc.Id = (byte)(x + (13 * Y)); Pc.Typ = T; Pc.Val = x; Cards.Add(Pc.Id, Pc); } } if (RoundTimer != null && RoundTimer.Enabled) { RoundTimer.Stop(); RoundTimer.Dispose(); RoundTimer = null; RoundTimer = new System.Timers.Timer(); } else if (RoundTimer == null) { RoundTimer = new System.Timers.Timer(); } RoundTimer.Interval = CountDown * 1000; RoundTimer.Elapsed += delegate { if (Players.Count > 1 && Pot < 1) { DrawCards(1, false); Pot = MinLimit; RoundMaxBet = MinLimit; _StartingPlayer = GetStartingPlayer(); SendToAll(PokerPackets.PokerCards1Card(this)); DrawCards(1, false); foreach (PokerPlayer Pl in Players.Values) { Pl.Bet = MinLimit; Pl.Send(PokerPackets.PokerCards2Cards(this, Pl.MyCards)); } SendToAll(PokerPackets.PokerPlayerTurn(_StartingPlayer, MinLimit, MinLimit * 2, 38, 20)); StartMoveTimer(30, _StartingPlayer); RoundTimer.Stop(); RoundTimer.Dispose(); RoundTimer = null; } }; RoundTimer.Start(); SendToAll(PokerPackets.PokerPlayerTurn(0, 0, 0, 0, CountDown)); Data D = new Data(true); D.ID = 234; D.UID = Id; D.dwParam = (uint)(MinLimit * Players.Count); SendToAll(D.ToArray()); } public void StartMoveTimer(byte CountDown, uint PlayerId) { if (MoveTimer != null && MoveTimer.Enabled) { MoveTimer.Stop(); MoveTimer.Dispose(); } MoveTimer = new System.Timers.Timer(); MoveTimer.Interval = CountDown * 1000; MoveTimer.Elapsed += delegate { byte[] FoldMe = new byte[10]; FoldMe[6] = 4; NewPlayerMove(FoldMe, PlayerId); MoveTimer.Stop(); MoveTimer.Dispose(); }; MoveTimer.Start(); } public bool FreeSeat(byte Seat) { bool Free = true; foreach (PokerPlayer P in Players.Values) { if (P.Seat == Seat) Free = false; } foreach (PokerPlayer P in Watchers.Values) { if (P.CurrentState == 3) if (P.Seat == Seat) Free = false; } return Free; } public void AddNewPlayer(Entity P, byte Seat, bool Player) { P.PokerTable = this.Id; PokerPlayer Pl = new PokerPlayer(); Pl.PlayerId = P.UID; Pl.TableId = Id; Pl.Seat = Seat; if (Player) { if (Pot > 0) Pl.RoundState = 4; if (!Players.ContainsKey(Pl.PlayerId)) Players.Add(Pl.PlayerId, Pl); ToLocal(PokerPackets.PokerTable(this)); } else { if (!Watchers.ContainsKey(Pl.PlayerId)) Watchers.Add(Pl.PlayerId, Pl); } } public void RemovePlayer(uint Id) { if (Players.ContainsKey(Id)) { try { lock (Players) { foreach (PokerPlayer P in Players.Values) { P.Send(PokerPackets.PokerLeaveTable(Id)); } } lock (Watchers) { foreach (PokerPlayer P in Watchers.Values) { P.Send(PokerPackets.PokerLeaveTable(Id)); } } if (Players[Id].MyChar != null) Players[Id].MyChar.PokerTable = 0; Players.Remove(Id); } catch { } } else if (Watchers.ContainsKey(Id)) { lock (Players) { foreach (PokerPlayer P in Players.Values) P.Send(PokerPackets.PokerLeaveTable(Id)); } lock (Watchers) { foreach (PokerPlayer P in Watchers.Values) P.Send(PokerPackets.PokerLeaveTable(Id)); } if (Watchers[Id].MyChar != null) Watchers[Id].MyChar.PokerTable = 0; Watchers.Remove(Id); } ToLocal(PokerPackets.PokerLeaveTable(Id)); ToLocal(PokerPackets.PokerTable(this)); } public void SendToAll(byte[] P) { foreach (PokerPlayer Player in Players.Values) Player.Send(P); foreach (PokerPlayer Player in Watchers.Values) Player.Send(P); } public PokerCard GetNewCard() { Random Rand = new Random(); PokerCard PC = new PokerCard(); int Rnd = Rand.Next(52); PC.Id = (byte)Rnd; while (!Cards.ContainsKey(PC.Id)) { PC.Id = (byte)Rand.Next(52); } PC = Cards[PC.Id]; return PC; } public void DrawCards(byte Count, bool Table) { try { if (!Table) { for (byte x = 0; x < Count; x++) { foreach (PokerPlayer P in Players.Values) { if (!P.Connected) continue; if (P.CurrentState > 1) continue; PokerCard C = GetNewCard(); C.PlayerId = P.PlayerId; P.MyCards.Add(C.Id, C); if (Cards.ContainsKey(C.Id)) Cards.Remove(C.Id); } } return; } byte Co = (byte)TableCards.Count; for (byte x = Co; x < (byte)(Count + Co); x++) { PokerCard C = GetNewCard(); C.PlayerId = 0; TableCards.Add(x, C); if (Cards.ContainsKey(C.Id)) Cards.Remove(C.Id); } } catch (Exception xp) { Console.WriteLine(xp.ToString()); } } public static int Allin = 0; int HarryPotter = 0; public void NewPlayerMove(byte[] P, uint PlayerId) { if (Pot == 0) return; try { if (Players.ContainsKey(PlayerId)) { if (MoveTimer != null && MoveTimer.Enabled) { MoveTimer.Stop(); MoveTimer.Dispose(); } PokerPlayer Pl = Players[PlayerId]; byte Move = P[6]; byte CSeat = Pl.Seat; Pl.RoundState = Move; uint ReqPot = Pot; switch (Move) { #region Rise case 2://call { Pot += MinLimit; Pl.Bet += MinLimit; if (Pl.Bet > RoundMaxBet) RoundMaxBet = Pl.Bet; if (BetType == 0) Pl.MyChar.Money -= MinLimit; else if (BetType == 1) { if (Pl.MyChar.ConquerPoints >= MinLimit) Pl.MyChar.ConquerPoints -= MinLimit; else Pl.MyChar.ConquerPoints = 0; } Data D = new Data(true); D.ID = 234; D.UID = Id; D.dwParam = Pot; SendToAll(D.ToArray()); SendToAll(PokerPackets.PokerPlayerMove(PlayerId, Move, Pl.Bet, Pot)); break; } case 8: { break; } case 16://Rise { uint Botting = MinLimit + MinLimit; Pot += Botting; Pl.Bet += Botting; if (Pl.Bet > RoundMaxBet) RoundMaxBet = Pl.Bet; if (BetType == 0) Pl.MyChar.Money -= Botting; else if (BetType == 1) { if (Pl.MyChar.ConquerPoints >= Botting) Pl.MyChar.ConquerPoints -= Botting; else Pl.MyChar.ConquerPoints = 0; } Data D = new Data(true); D.ID = 234; D.UID = Id; D.dwParam = Pot; D.Data24_Uint = RoundMaxBet; SendToAll(D.ToArray()); SendToAll(PokerPackets.PokerPlayerMove(PlayerId, Move, Pl.Bet, Pot)); break; } #endregion #region Fold case 4: { if (P[9] == 200) { //RemoveThis = true; RemovePlayer(PlayerId); } else if (Players.ContainsKey(PlayerId)) { SendToAll(PokerPackets.PokerPlayerMove(PlayerId, Move, MinLimit, Pot)); Players[PlayerId].MyCards.Clear(); Players[PlayerId].RoundState = 4; } break; } default: SendToAll(P); break; #endregion #region AllIn case 32: { uint Betting = 0; if (HarryPotter == 0) Pis = Pl.MyChar.Money; if (HarryPotter == 1) Pis1 = Pl.MyChar.Money; if (BetType == 0) { Betting = (uint)Pl.MyChar.Money; Pl.MyChar.Money = 0; } else if (BetType == 1) { Betting = (uint)Pl.MyChar.ConquerPoints; Pl.MyChar.ConquerPoints = 0; } Pot += Betting; Pl.Bet += Betting; if (Pl.Bet > RoundMaxBet) RoundMaxBet = Pl.Bet; Allin++; Data D = new Data(true); D.ID = 234; D.UID = Id; D.dwParam = Pot; D.Data24_Uint = RoundMaxBet; SendToAll(D.ToArray()); SendToAll(PokerPackets.PokerPlayerMove(PlayerId, Move, Pl.Bet, Pot)); break; } #endregion } uint NextPlayer = GetNextSeat(CSeat, true); if (Allin >= 1) { HarryPotter++; if (Players.Count == HarryPotter) { #region Send First 3 table cards if (TableCards.Count < 3) { DrawCards(3, true); Dictionary<byte, PokerCard> TC = new Dictionary<byte, PokerCard>(3); TC.Add(0, TableCards[0]); TC.Add(1, TableCards[1]); TC.Add(2, TableCards[2]); SendToAll(PokerPackets.PokerTableCards(TC, this, 1)); } #endregion #region Send Forth table card if (TableCards.Count < 4) { DrawCards(1, true); Dictionary<byte, PokerCard> TC = new Dictionary<byte, PokerCard>(1); if (TableCards.ContainsKey(3)) TC.Add(3, TableCards[3]); SendToAll(PokerPackets.PokerTableCards(TC, this, 2)); } #endregion #region Send Fifth table cards if (TableCards.Count < 5) { DrawCards(1, true); Dictionary<byte, PokerCard> TC = new Dictionary<byte, PokerCard>(1); if (TableCards.ContainsKey(4)) TC.Add(4, TableCards[4]); SendToAll(PokerPackets.PokerTableCards(TC, this, 3)); } #endregion EndRound(0u); HarryPotter = 0; } } else { if (Players.Count < HarryPotter) HarryPotter = Players.Count; else HarryPotter++; } Console.WriteLine(HarryPotter); #region No More Players available if (NextPlayer == Pl.PlayerId) { EndRound(NextPlayer); return; } else if (Players.ContainsKey(NextPlayer) && NextPlayer == GetNextSeat(Players[NextPlayer].Seat, false)) { EndRound(NextPlayer); return; } #endregion switch (RoundStage) { #region Send First 3 table cards case 1: { if (TableCards.Count < 3) { DrawCards(3, true); Dictionary<byte, PokerCard> TC = new Dictionary<byte, PokerCard>(3); TC.Add(0, TableCards[0]); TC.Add(1, TableCards[1]); TC.Add(2, TableCards[2]); SendToAll(PokerPackets.PokerTableCards(TC, this, 1)); } break; } #endregion #region Send Forth table card case 2: { if (TableCards.Count < 4) { DrawCards(1, true); Dictionary<byte, PokerCard> TC = new Dictionary<byte, PokerCard>(1); if (TableCards.ContainsKey(3)) TC.Add(3, TableCards[3]); SendToAll(PokerPackets.PokerTableCards(TC, this, 2)); } break; } #endregion #region Send Fifth table cards case 3: { if (TableCards.Count < 5) { DrawCards(1, true); Dictionary<byte, PokerCard> TC = new Dictionary<byte, PokerCard>(1); if (TableCards.ContainsKey(4)) TC.Add(4, TableCards[4]); SendToAll(PokerPackets.PokerTableCards(TC, this, 3)); } break; } #endregion case 4: { EndRound(0); return; } } if (this.RoundStage != 4) { byte b3 = 36; bool flag = false; if (this.Players.ContainsKey(NextPlayer)) { uint bet = this.Players[NextPlayer].Bet; PokerPlayer pokerPlayer2 = this.Players[NextPlayer]; if (this.RoundMaxBet < bet) { b3 += 8; } else { b3 += 2; } if (this.BetType == 0) { if (pokerPlayer2.MyChar.Money < this.RoundMaxBet) { flag = true; } else { if (pokerPlayer2.MyChar.Money < this.MinLimit) { flag = true; } } if (pokerPlayer2.MyChar.Money >= this.MinLimit * 2u) { b3 += 16; } } else { if (this.BetType == 1) { if (pokerPlayer2.MyChar.ConquerPoints < this.RoundMaxBet) { flag = true; } else { if (pokerPlayer2.MyChar.ConquerPoints < this.MinLimit) { flag = true; } } if (pokerPlayer2.MyChar.ConquerPoints >= this.MinLimit * 2u) { b3 += 16; } } } } if (flag) { b3 = 32; } SendToAll(PokerPackets.PokerPlayerTurn(NextPlayer, MinLimit, RoundMaxBet, b3, 30)); StartMoveTimer(30, NextPlayer); } } } catch (Exception xp) { Console.WriteLine(xp.ToString()); } } public void EndRound(uint WinnerId) { SendToAll(PokerPackets.PokerPlayerTurn(0, 0, 0, 0, 30)); try { if (MoveTimer != null || MoveTimer.Enabled) { MoveTimer.Stop(); MoveTimer.Dispose(); } } catch { } uint num = Pot - (Pot / 10); #region Check Winner if (WinnerId == 0) { ushort HighestPower = 0; ulong HighestHandPower = 0; SendToAll(PokerPackets.PokerShowAllCards(this)); foreach (PokerPlayer Pla in Players.Values) { if (Pla.RoundState == 4 || !Pla.Connected) continue; ulong HP = GetHandPower(Pla.MyCards, Pla); if (HP > HighestHandPower) { HighestHandPower = HP; WinnerId = Pla.PlayerId; HighestPower = Pla.GetFullPower(Pla.MyCards); } else if (HP == HighestHandPower) { if (Pla.GetFullPower(Pla.MyCards) > HighestPower) { WinnerId = Pla.PlayerId; HighestPower = Pla.GetFullPower(Pla.MyCards); } } } } #endregion if (this.Players.ContainsKey(WinnerId)) { if (this.BetType == 0) { #region Drop Allin if (Pis > Pis1 && Allin >= 2) { foreach (PokerPlayer current in this.Players.Values) { if (current.PlayerId != WinnerId) // 1 - loss - low { this.Players[current.PlayerId].MyChar.Money += 0; } else if (current.PlayerId == WinnerId)// 1 - win - great { this.Players[current.PlayerId].MyChar.Money += num; this.SendToAll(PokerPackets.PokerRoundResult(this, WinnerId, num - Pis)); } } } else if (Allin >= 2) { foreach (PokerPlayer current in this.Players.Values)// 2 - win - low { if (current.PlayerId != WinnerId)// 2 - loss - great { this.Players[current.PlayerId].MyChar.Money = Pis1 - Pis; } else if (current.PlayerId == WinnerId)// 2 - win - low { this.Players[current.PlayerId].MyChar.Money += Pis * 2; this.SendToAll(PokerPackets.PokerRoundResult(this, WinnerId, Pis)); } } } else { this.Players[WinnerId].MyChar.Money += num; this.SendToAll(PokerPackets.PokerRoundResult(this, WinnerId, num)); } #endregion } else { if (this.BetType == 1) { this.Players[WinnerId].MyChar.ConquerPoints += num; } } } Pot = 0; #region Start new round if (Players.Count < 2) return; else { Pot = 0; SetNewRound(15); } #endregion } public void ToLocal(byte[] P) { Client.GameState[] Locals = new Client.GameState[Program.Values.Length]; Locals = Kernel.GamePool.Values.ToArray(); foreach (Client.GameState client in Locals) { if (client != null) { if (client.Map.ID == Map) { if (Kernel.GetDistance(client.Entity.X, client.Entity.Y, X, Y) > 25) { continue; } client.Send(P); } } } } public uint GetNextSeat(byte Seat, bool Next) { try { Dictionary<byte, PokerPlayer> Ses = Seats; uint Id = 0; byte Se = (byte)(Seat + 1); bool Found = false; while (!Found) { if (Ses.ContainsKey(Se)) { if (Ses[Se].RoundState == 4 || !Ses[Se].Connected) { } else { Found = true; break; } } Se++; if (Se > 9) Se = 0; } Id = Ses[Se].PlayerId; if (Id == _StartingPlayer && Next) RoundStage++; return Id; } catch (Exception xp) { Console.WriteLine(xp.ToString()); return 0; } } public ulong GetHandPower(Dictionary<byte, PokerCard> hand, PokerPlayer Pl) { ulong _hand = 0; ulong board = 0; foreach (var item in hand.Values) { _hand |= HoldemHand.Hand.CardMasksTable[item.Id]; } foreach (var item in this.TableCards.Values) { board |= HoldemHand.Hand.CardMasksTable[item.Id]; } return HoldemHand.Hand.Evaluate((ulong)(board | _hand)); } public bool IsRoyal(string HandVals) { if (HandVals.Contains("89ABC")) return true; else return false; } public bool IsStraight(string HandVals) { bool Straight = false; string V = HandVals; if (V.Contains("01234") || V.Contains("12345") || V.Contains("23456")) Straight = true; else if (V.Contains("34567") || V.Contains("45678") || V.Contains("56789")) Straight = true; else if (V.Contains("6789A") || V.Contains("789AB") || V.Contains("89ABC")) Straight = true; else if (V.Contains("C0123")) Straight = true; return Straight; } public bool IsFourOfAKind(string HandVals) { bool Yes = false; string V = HandVals; if (V.Contains("0123") || V.Contains("1234") || V.Contains("2345")) Yes = true; else if (V.Contains("3456") || V.Contains("4567") || V.Contains("5678")) Yes = true; else if (V.Contains("6789") || V.Contains("789A") || V.Contains("89AB")) Yes = true; else if (V.Contains("9ABC") || V.Contains("C012")) Yes = true; else if (V.Contains("0000") || V.Contains("1111") || V.Contains("2222")) Yes = true; else if (V.Contains("3333") || V.Contains("4444") || V.Contains("5555")) Yes = true; else if (V.Contains("6666") || V.Contains("7777") || V.Contains("8888")) Yes = true; else if (V.Contains("9999") || V.Contains("AAAA") || V.Contains("BBBB")) Yes = true; else if (V.Contains("CCCC")) Yes = true; return Yes; } public bool IsThreeOfAKind(PokerPlayer Pl) { bool Yes = false; string V = Pl.HandVals; if (V.Contains("012") || V.Contains("123") || V.Contains("234")) Yes = true; else if (V.Contains("345") || V.Contains("456") || V.Contains("567")) Yes = true; else if (V.Contains("678") || V.Contains("789") || V.Contains("89A")) Yes = true; else if (V.Contains("9AB") || V.Contains("ABC") || V.Contains("C01")) Yes = true; else if (V.Contains("000") || V.Contains("111") || V.Contains("222")) Yes = true; else if (V.Contains("333") || V.Contains("444") || V.Contains("555")) Yes = true; else if (V.Contains("666") || V.Contains("777") || V.Contains("888")) Yes = true; else if (V.Contains("999") || V.Contains("AAA") || V.Contains("BBB")) Yes = true; else if (V.Contains("CCC")) Yes = true; if (V.Contains("CCC")) V = V.Replace("CCC", ""); else if (V.Contains("BBB")) V = V.Replace("BBB", ""); else if (V.Contains("AAA")) V = V.Replace("AAA", ""); else if (V.Contains("999")) V = V.Replace("999", ""); else if (V.Contains("888")) V = V.Replace("888", ""); else if (V.Contains("777")) V = V.Replace("777", ""); else if (V.Contains("666")) V = V.Replace("666", ""); else if (V.Contains("555")) V = V.Replace("555", ""); else if (V.Contains("444")) V = V.Replace("444", ""); else if (V.Contains("333")) V = V.Replace("333", ""); else if (V.Contains("222")) V = V.Replace("222", ""); else if (V.Contains("111")) V = V.Replace("111", ""); else if (V.Contains("000")) V = V.Replace("000", ""); else if (V.Contains("ABC")) V = V.Replace("ABC", ""); else if (V.Contains("C01")) V = V.Replace("C01", ""); else if (V.Contains("9AB")) V = V.Replace("9AB", ""); else if (V.Contains("89A")) V = V.Replace("89A", ""); else if (V.Contains("789")) V = V.Replace("789", ""); else if (V.Contains("678")) V = V.Replace("678", ""); else if (V.Contains("567")) V = V.Replace("567", ""); else if (V.Contains("456")) V = V.Replace("456", ""); else if (V.Contains("345")) V = V.Replace("345", ""); else if (V.Contains("234")) V = V.Replace("234", ""); else if (V.Contains("123")) V = V.Replace("123", ""); else if (V.Contains("012")) V = V.Replace("012", ""); Pl.HandVals = V; return Yes; } public bool IsPair(PokerPlayer Pl) { bool Yes = false; string V = Pl.HandVals; if (V.Contains("01") || V.Contains("12") || V.Contains("23")) Yes = true; else if (V.Contains("34") || V.Contains("45") || V.Contains("56")) Yes = true; else if (V.Contains("67") || V.Contains("78") || V.Contains("89")) Yes = true; else if (V.Contains("9A") || V.Contains("AB") || V.Contains("BC")) Yes = true; else if (V.Contains("C0")) Yes = true; else if (V.Contains("00") || V.Contains("11") || V.Contains("22")) Yes = true; else if (V.Contains("33") || V.Contains("44") || V.Contains("55")) Yes = true; else if (V.Contains("66") || V.Contains("77") || V.Contains("88")) Yes = true; else if (V.Contains("99") || V.Contains("AA") || V.Contains("BB")) Yes = true; else if (V.Contains("CC")) Yes = true; if (V.Contains("CC")) V = V.Replace("CC", ""); else if (V.Contains("BB")) V = V.Replace("BB", ""); else if (V.Contains("AA")) V = V.Replace("AA", ""); else if (V.Contains("99")) V = V.Replace("99", ""); else if (V.Contains("88")) V = V.Replace("88", ""); else if (V.Contains("77")) V = V.Replace("77", ""); else if (V.Contains("66")) V = V.Replace("66", ""); else if (V.Contains("55")) V = V.Replace("55", ""); else if (V.Contains("44")) V = V.Replace("44", ""); else if (V.Contains("33")) V = V.Replace("33", ""); else if (V.Contains("22")) V = V.Replace("22", ""); else if (V.Contains("11")) V = V.Replace("11", ""); else if (V.Contains("00")) V = V.Replace("00", ""); else if (V.Contains("BC")) V = V.Replace("BC", ""); else if (V.Contains("AB")) V = V.Replace("AB", ""); else if (V.Contains("C0")) V = V.Replace("C0", ""); else if (V.Contains("9A")) V = V.Replace("9A", ""); else if (V.Contains("89")) V = V.Replace("89", ""); else if (V.Contains("78")) V = V.Replace("78", ""); else if (V.Contains("67")) V = V.Replace("67", ""); else if (V.Contains("56")) V = V.Replace("56", ""); else if (V.Contains("45")) V = V.Replace("45", ""); else if (V.Contains("34")) V = V.Replace("34", ""); else if (V.Contains("23")) V = V.Replace("23", ""); else if (V.Contains("12")) V = V.Replace("12", ""); else if (V.Contains("01")) V = V.Replace("01", ""); Pl.HandVals = V; return Yes; } } public class PokerPlayer { public uint TableId = 0; public uint PlayerId = 0; public bool Connected = true; public byte CurrentState = 1; public byte RoundState = 0; public uint Bet = 0; public byte Seat = 0; public byte CardsPower = 0; public string HandVals = ""; public System.Timers.Timer MoveTimer = new System.Timers.Timer(); public ushort GetFullPower(Dictionary<byte, PokerCard> TCards) { ushort P = 0; foreach (PokerCard C in MyCards.Values) { P += (ushort)(C.Id); } return P; } public Dictionary<byte, PokerCard> MyCards = new Dictionary<byte, PokerCard>(5); public Entity MyChar { get { if (Kernel.GamePool.ContainsKey(PlayerId)) return Kernel.GamePool[PlayerId].Entity; else { Connected = false; return null; } } set { PlayerId = value.UID; } } public PokerTable MyTable { get { if (Kernel.PokerTables.ContainsKey(TableId)) return Kernel.PokerTables[TableId]; else return null; } set { TableId = value.Id; } } public void Send(byte[] P) { if (!Connected) { if (Kernel.PokerTables.ContainsKey(TableId)) { if (Kernel.PokerTables[TableId].Players.ContainsKey(PlayerId)) Kernel.PokerTables[TableId].Players[PlayerId].RoundState = 4; return; } } if (Kernel.GamePool.ContainsKey(PlayerId)) Kernel.GamePool[PlayerId].Send(P); else { Connected = false; if (Kernel.PokerTables.ContainsKey(TableId)) { if (Kernel.PokerTables[TableId].Players.ContainsKey(PlayerId)) Kernel.PokerTables[TableId].Players[PlayerId].RoundState = 4; } } } } public class PokerCard { public byte Id = 0; public uint PlayerId; public byte Val = 0; public PokerCardsType Typ = PokerCardsType.Clubs; } public enum PokerTableState : byte { UnOpened = 0, Pocket = 1, Flop = 2, Turn = 3, River = 4, ShowDown = 5 } public enum PokerJoinTableType : byte { Join = 0, Leave = 1, Watching = 2 } public enum PokerCardsType : byte { Hearts = 0, Spades = 1, Clubs = 2, Diamonds = 3 } public enum PokerCardsValue : byte { Ace = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, Seven = 7, Eight = 8, Nine = 9, Ten = 10, Jack = 11, Queen = 12, King = 13, } public enum PokerHandPower : byte { RoyalFlush = 10, StraightFlush = 9, FourofaKind = 8, FullHouse = 7, Flush = 6, Straight = 5, ThreeOfAKind = 4, TwoPairs = 3, Pair = 2, Nothing = 1 } public enum PokerCallTypes : byte { Bet = 1, Call = 2, Fold = 4, Check = 8, Rise = 16, AllIn = 32, CallFold = 6, CheckFold = 12, RiseCall = 18, RiseFold = 20, RiseCallFold = 22, RiseCheck = 24, AllInCall = 34, AllInFold = 36, AllInCallFold = 38, } public class PacketBuilder { protected byte[] _buffer = new byte[1024]; protected int Position = 0; protected int Len = 0; protected byte[] TQ_SERVER = Program.Encoding.GetBytes("TQServer"); public int GetPos() { return Position; } public void SetPosition(int Pos) { Position = Pos; } public PacketBuilder(int T, int L) { Len = L; Length(L); Type(T); } public void Short(int value) { _buffer[Position] = ((byte)(value & 0xff)); Position++; _buffer[Position] = ((byte)((value >> 8) & 0xff)); Position++; } public void Short(uint value) { _buffer[Position] = ((byte)(value & 0xff)); Position++; _buffer[Position] = ((byte)((value >> 8) & 0xff)); Position++; } public void Length(int value) { _buffer[Position] = ((byte)(value & 0xff)); Position++; _buffer[Position] = ((byte)((value >> 8) & 0xff)); Position++; } public void Type(int value) { _buffer[Position] = ((byte)(value & 0xff)); Position++; _buffer[Position] = ((byte)((value >> 8) & 0xff)); Position++; } public void Long(int value) { _buffer[Position] = ((byte)(value & 0xff)); Position++; _buffer[Position] = ((byte)(value >> 8 & 0xff)); Position++; _buffer[Position] = (byte)(value >> 16 & 0xff); Position++; _buffer[Position] = ((byte)(value >> 24 & 0xff)); Position++; } public void Long(ulong value) { _buffer[Position] = ((byte)((ulong)value & 0xffL)); Position++; _buffer[Position] = ((byte)(value >> 8 & 0xff)); Position++; _buffer[Position] = (byte)(value >> 16 & 0xff); Position++; _buffer[Position] = ((byte)(value >> 24 & 0xff)); Position++; } public void ULong(ulong value) { _buffer[Position] = (byte)(value); Position++; _buffer[Position] = (byte)(value >> 8); Position++; _buffer[Position] = (byte)(value >> 16); Position++; _buffer[Position] = (byte)(value >> 24); Position++; _buffer[Position] = (byte)(value >> 32); Position++; _buffer[Position] = (byte)(value >> 40); Position++; _buffer[Position] = (byte)(value >> 48); Position++; _buffer[Position] = (byte)(value >> 56); Position++; } public void Int(int value) { _buffer[Position] = (Convert.ToByte(value & 0xff)); Position++; } public void Int(uint value) { _buffer[Position] = (Convert.ToByte(value & 0xff)); Position++; } public void Long(uint value) { _buffer[Position] = ((byte)(value & 0xff)); Position++; _buffer[Position] = ((byte)(value >> 8 & 0xff)); Position++; _buffer[Position] = (byte)(value >> 16 & 0xff); Position++; _buffer[Position] = ((byte)(value >> 24 & 0xff)); Position++; } public void Move(int value) { for (int x = 0; x < value; x++) { _buffer[Position] = 0; Position++; } } public void Text(string value) { byte[] nvalue = Program.Encoding.GetBytes(value); Array.Copy(nvalue, 0, _buffer, Position, nvalue.Length); Position += nvalue.Length; } protected void Seal() { Array.Copy(TQ_SERVER, 0, _buffer, Position, TQ_SERVER.Length); Position += TQ_SERVER.Length + 1; byte[] x = new byte[Position - 1]; Array.Copy(_buffer, x, Position - 1); _buffer = new byte[x.Length]; Array.Copy(x, _buffer, x.Length); x = null; } public byte[] getFinal() { Seal(); return _buffer; } internal void Fill(int End) { for (int x = Position; x < End; x++) Int(0); } internal void PrintThis() { string Dat = ""; for (int x = 0; x < Position; x++) Dat += _buffer[x].ToString("X") + " "; Console.WriteLine(Dat); } #region Add from offset public void Short(int value, int Offset) { _buffer[Offset] = ((byte)(value & 0xff)); _buffer[Offset + 1] = ((byte)((value >> 8) & 0xff)); } public void Short(uint value, int Offset) { _buffer[Offset] = ((byte)(value & 0xff)); Offset++; _buffer[Offset] = ((byte)((value >> 8) & 0xff)); } public void Length(int value, int Offset) { _buffer[Offset] = ((byte)(value & 0xff)); Offset++; _buffer[Offset] = ((byte)((value >> 8) & 0xff)); } public void Type(int value, int Offset) { _buffer[Offset] = ((byte)(value & 0xff)); Offset++; _buffer[Offset] = ((byte)((value >> 8) & 0xff)); } public void Long(int value, int Offset) { _buffer[Offset] = ((byte)(value & 0xff)); Offset++; _buffer[Offset] = ((byte)(value >> 8 & 0xff)); Offset++; _buffer[Offset] = (byte)(value >> 16 & 0xff); Offset++; _buffer[Offset] = ((byte)(value >> 24 & 0xff)); } public void Long(ulong value, int Offset) { _buffer[Offset] = ((byte)((ulong)value & 0xffL)); Offset++; _buffer[Offset] = ((byte)(value >> 8 & 0xff)); Offset++; _buffer[Offset] = (byte)(value >> 16 & 0xff); Offset++; _buffer[Offset] = ((byte)(value >> 24 & 0xff)); } public void ULong(ulong value, int Offset) { _buffer[Offset] = (byte)(value); Offset++; _buffer[Offset] = (byte)(value >> 8); Offset++; _buffer[Offset] = (byte)(value >> 16); Offset++; _buffer[Offset] = (byte)(value >> 24); Offset++; _buffer[Offset] = (byte)(value >> 32); Offset++; _buffer[Offset] = (byte)(value >> 40); Offset++; _buffer[Offset] = (byte)(value >> 48); Offset++; _buffer[Offset] = (byte)(value >> 56); } public void Int(int value, int Offset) { _buffer[Offset] = (Convert.ToByte(value & 0xff)); Offset++; } public void Int(uint value, int Offset) { _buffer[Offset] = (Convert.ToByte(value & 0xff)); Offset++; } public void Long(uint value, int Offset) { _buffer[Offset] = ((byte)(value & 0xff)); Offset++; _buffer[Offset] = ((byte)(value >> 8 & 0xff)); Offset++; _buffer[Offset] = (byte)(value >> 16 & 0xff); Offset++; _buffer[Offset] = ((byte)(value >> 24 & 0xff)); Offset++; } #endregion } }
واعمل كلاس جديد لو مش عندك في
Network/GamePackets
بأسم
PacketID.cs
حط فيه دلو ولو عندك بدلو
namespace HarryPotter.Network.GamePackets { public unsafe class PacketID { public const ushort VipStatus = 1129, UserIPInfo = 2078, ServerInfo = 2079, SpawnEntity = 10014, Update = 10017, UpdateAura = 2410, CraftItem = 1028, AuctionAction = 1320, AuctionBrowse = 1321, AuctionQuery = 1322, FactionWar = 1072, EnemyLast = 1041, ReloadScreen = 1037, ConfirmMap = 1044, Gambleing = 1113, SkillSoul = 1103, JiangHu = 2700, JiangHuStatus = 2701, JiangHuStudy = 2702, JiangHuRanking = 2703, JiangHuSettings = 2704, ClanCityWar = 1313, ThrillingSpooks = 2400, AutoHunt = 1070, CurrentFlag = 2430, OneArmedBandit = 1351, AdvertiseCommend = 2227, AdvertiseRank = 2226, AdvertiseRecruit = 2225, EnitityCreate = 1001, Message = 1004, ItemUsage = 1009, String = 1015, KnownPersons = 1019, Attack = 1022, Team = 1023, Atributes = 1024, Socketing = 1027, WindowStats = 1040, LoginPacket = 1052, Trade = 1056, Lottery = 1314, FloorItem = 1101, Warehouses = 1102, GuildCommand = 1107, PokerPlayerInfo = 2090, PokerPlayerMove = 2093, PokerLeaveTable = 2096, PokerJoinTable = 2171, Enlight = 1127, QuizShow = 2068, ArsenalInscribedPage = 2202, ArsenalPackets = 2203, FastInscribeItem = 2204, Compose = 2036, OfflineTG = 2044, TradePartner = 2046, ItemLock = 2048, Broadcast = 2050, Nobility = 2064, RacePotion = 2072, MessageBoard = 1111, TopGuild = 1058, GuildDoantion = 2101, FairyFlower = 2070, SendFlower = 1150, FlowersPacket = 1151, VIPTeleport = 1128, MentorPrize = 2067, MentorApprentice = 2065, MentorInformation = 2066, MentorPremio = 1036, GuildMember = 2102, ArenaRank = 2207, ArenaRequest = 2206, ArenaDialog = 2205, ArenaShowWiners = 2208, ArenaStatistic = 2209, ArenaWatch = 2211, TeamArenaRank = 2243, TeamArenaRequest = 2242, TeamArenaDialog = 2241, TeamArenaShowWiners = 2244, TeamArenaStatistic = 2245, InTeamArena = 2247, ChampionArenaRank = 2600, ChampionArenaStats = 2601, ChampionArenaShowTop = 2602, ChampionArenaShowTop2 = 2603, ChampionArenaHandle = 2604, ElitePkRank = 2223, ElitePKBrackets = 2219, ElitePKWager = 1064, ElitePKWagersList = 1065, ElitePKTitle = 1130, TeamPkBrackets = 2232, TeamPkTournament = 2233, TeamPkFighterStats = 2240, SkillTeamPkBrackets = 2252, SkillTeamPkTournament = 2253, SkillTeamPkFighterStats = 2260, CaptureTheFlag = 2224, ChiSystem = 2533, RetreatChi = 2536, GroundMovement = 10005, Reincarnation = 1066, PurifyItem = 2076, Clan = 1312, SubClass = 2320, ItemAdding = 1038, GeneralData = 10010, TimePacket = 1033, PkExplorer = 2220, SecondaryPassword = 2261, ChangeName = 2080, AutoInvite = 1126, MemoryAgate = 2110, Achievement = 1136, MailboxPage = 1045, MailboxCheck = 1046, MailboxIcon = 1047, MailboxMessage = 1048, QuestTrace = 1134, QuestData = 1135, CloneAttack = 2812, RewardEvent = 1315, RewardPoint = 1316, OflineEvent = 1317, NpcSpawn = 2030, NpcInit = 2031, NpcDialog = 2032, RouletteShareBetting = 2810, RoulettedAddNewPlayer = 2809, RouletteOpenGui = 2808, RouletteTable = 2807, RouletteInvite = 2806, RouletteSignUp = 2805, RouletteAction = 2804, RouletteScreen = 2803, RouletteRecord = 2802, RouletteNoWinner = 2801, RouletteCheck = 2800, CrossServer = 1063, CrossServerData = 2900, CrossServerName = 2901, CrossServerSend = 2902, CrossServerColor = 2501, GuildPrizeRank = 2504, CrossServerWar = 2505, CrossServerBase = 2506, CrossServerRank = 2507, LuckyWheel = 2811, LuckyWheelGift = 2812, Activeness = 2820, ActivenessGift = 2822, ActivenessPoint = 2823, WayofHeroes = 2830, WayofHeroesDone = 2831, WayofHeroesSend = 2832, InnerPowerStageInfo = 2611, InnerPowerGui = 2612, InnerPowerHandler = 2610; } }
بس كده ولو جالك اي ايرور في اي حته انا موجود
سلام عليكم