public HoldemPlayer(byte[] data, int offset = 0) { // 0 Name = Encoding.ASCII.GetString(data, offset, 16); // 16 Balance = BitConverter.ToDouble(data, offset + 16); // 24 CurrentBet = BitConverter.ToDouble(data, offset + 24); // 32 ///////////////////////////////////// //card macros //#define RANK(c) ((c>>4)&0x0f) //#define SUIT(c) ((c>>0)&0x0f) //#define ISCARDBACK(c) (c==0xff) //#define ISUNKNOWN(c) (c==0) ///////////////////////////////////// byte[] cards = new byte[5]; for (int i = 0; i < 5; i++) { cards[i] = data[144 + sizeof(byte) * i]; int rank = ((cards[i] >> 4) & 0x0F); int suit = ((cards[i] >> 0) & 0x0F); // In pokerEval lib suits clubs and diamonds are swaped // So we need to swap those suites in ovder to use PokerEval.Mask() if (suit == 1) { suit = 3; } else if (suit == 3) { suit = 1; } int index = (rank - 2) + 13 * (suit - 1); Hand |= PokerEval.Mask(index); } // 34 //unsigned char m_name_known : 1 ; //0=no 1=yes //unsigned char m_balance_known : 1 ; //0=no 1=yes //unsigned char m_fillerbits : 6 ; //filler bits byte info = data[offset + 34]; NameKnown = (info & 0x1) != 0; BalanceKnown = (info & 0x2) != 0; }
public HoldemState(byte[] data) { // 0 TableTitle = Encoding.ASCII.GetString(data, 0, 64).TrimEnd('\0'); // 64 Pots = new double[10]; for (int i = 0; i < 10; i++) { Pots[i] = BitConverter.ToDouble(data, 64 + sizeof(double) * i); } // 144 ///////////////////////////////////// //card macros //#define RANK(c) ((c>>4)&0x0f) //#define SUIT(c) ((c>>0)&0x0f) //#define ISCARDBACK(c) (c==0xff) //#define ISUNKNOWN(c) (c==0) ///////////////////////////////////// byte[] commonCards = new byte[5]; for (int i = 0; i < 5; i++) { commonCards[i] = data[144 + sizeof(byte) * i]; int rank = ((commonCards[i] >> 4) & 0x0F); int suit = ((commonCards[i] >> 0) & 0x0F); // In pokerEval lib suits clubs and diamonds are swaped // So we need to swap those suites in ovder to use PokerEval.Mask() if (suit == 1) { suit = 3; } else if (suit == 3) { suit = 1; } int index = (rank - 2) + 13 * (suit - 1); CommonCards |= PokerEval.Mask(index); } // 149 // unsigned char m_is_playing : 1 ; //0=sitting-out, 1=sitting-in // unsigned char m_is_posting : 1 ; //0=autopost-off, 1=autopost-on // unsigned char m_fillerbits : 6 ; //filler bits byte info = data[149]; IsPlaing = (info & 0x1) != 0; IsPosting = (info & 0x2) != 0; // 151 DealerChair = BitConverter.ToInt32(data, 151); // 152 // each holdem_player struct is 40 bytes long Players = new HoldemPlayer[10]; for (int i = 0; i < 10; i++) { Players[i] = new HoldemPlayer(data, 152 + 40 * i); } }