private void LoadPlayersData(HandHistories.Objects.Hand.HandHistory CurrentGame)
        {
            PlayersList.Clear();

            var players = CurrentGame.Players;

            for (int i = 0; i < players.Count; i++)
            {
                var list = new List <CardModel>();

                if (players[i].hasHoleCards)
                {
                    foreach (var card in players[i].HoleCards)
                    {
                        list.Add(new CardModel()
                        {
                            Rank = new RangeCardRank().StringToRank(card.Rank),
                            Suit = new RangeCardSuit().StringToSuit(card.Suit)
                        });
                    }
                }

                if (i > PlayersList.Count - 1)
                {
                    PlayersList.Add(new PlayerModel());
                }

                var currentPlayer = PlayersList[i];
                currentPlayer.SetCollection(list);
                currentPlayer.PlayerName = players[i].PlayerName;
            }
        }
Exemple #2
0
        public Player AddPlayerToList(string name)
        {
            if (!PlayersList.Keys.Contains(name))
            {
                //dodanie
                PlayersList.Add(name, 0);
            }
            //wczytanie
            var myPlayer = new Player(name, PlayersList[name]);

            return(myPlayer);
        }
        public void LosujKolejnoscGraczyTest()
        {
            //arrange
            PlayersList x = new PlayersList();
            bool        RandomWorkCorrectly = false;
            int         myTry = 3;

            while (RandomWorkCorrectly == false && myTry != 0)
            {
                x.Add(new PlayerItem()
                {
                    Nazwa = "0"
                });
                x.Add(new PlayerItem()
                {
                    Nazwa = "1"
                });
                x.Add(new PlayerItem()
                {
                    Nazwa = "2"
                });
                x.Add(new PlayerItem()
                {
                    Nazwa = "3"
                });

                x.UstalKolejnoscGraczy();//act
                for (int i = 0; i < x.Count; i++)
                {
                    if (!x[i].Nazwa.Equals((i % 4).ToString()))
                    {
                        RandomWorkCorrectly = true;
                        break;
                    }
                }
                myTry--;
            }
            //assert
            Assert.IsTrue(RandomWorkCorrectly);
        }
        private void generate_Click(object sender, RoutedEventArgs e)
        {
            XDocument doc = new XDocument();

            XElement root = new XElement("players");

            players = new PlayersList();
            for (int i = 0; i < 10; ++i)
            {
                players.Add(new Player(1000, rnd.Next(800, 1200), i.ToString()));
            }

            dgridPlayers.ItemsSource = players;
        }
        private void InitPlayersList()
        {
            if (PlayersList == null)
            {
                PlayersList = new ObservableCollection <PlayerModel>();
            }
            else
            {
                PlayersList.Clear();
            }

            for (int i = 0; i < _playersCount; i++)
            {
                PlayersList.Add(new PlayerModel());
            }
        }
Exemple #6
0
        private void AddPlayer()
        {
            Player temp = new Player(Name.Trim(), Surname.Trim(), Age, Weight);

            if (!PlayersList.Contains(temp))
            {
                PlayersList.Add(temp);
                Clear();
            }
            else
            {
                var dialog = MessageBox.Show($"{temp.ToString()} już jest na liście {Environment.NewLine} Czy wyczyścić formularz?", "Uwaga", MessageBoxButton.OKCancel);
                if (dialog == MessageBoxResult.OK)
                {
                    Clear();
                }
            }
        }
Exemple #7
0
        private bool GetPlayers(XmlDocument response, PlayersList players)
        {
            bool newPlayersAdded = false;

            foreach (XmlNode subRootNode in response.DocumentElement.ChildNodes)
            {
                if (subRootNode.Name == "players")
                {
                    foreach (XmlNode playerNode in subRootNode)
                    {
                        Players player = new Players();
                        if (playerNode["steamid"] != null)
                        {
                            player =
                                players.Find(
                                    x =>
                                    x.SteamID ==
                                    Convert.ToInt32(Convert.ToInt64(playerNode["steamid"].InnerText) - 76561197960265728));
                            if (!player.RecordExists)
                            {
                                player = new Players();
                                players.Add(player);
                            }
                        }
                        else
                        {
                            player = new Players();
                            players.Add(player);
                        }

                        if (playerNode["steamid"] != null)
                            player.SteamID64 = Convert.ToInt64(playerNode["steamid"].InnerText);
                        if (playerNode["communityvisibilitystate"] != null)
                            player.CommunityVisibilityState = Convert.ToInt32(playerNode["communityvisibilitystate"].InnerText);
                        if (playerNode["profilestate"] != null)
                            player.ProfileState = Convert.ToInt32(playerNode["profilestate"].InnerText);
                        if (playerNode["personaname"] != null)
                            player.PersonaName = playerNode["personaname"].InnerText;
                        if (playerNode["lastlogoff"] != null)
                            player.LastLogOff = UnixTimeStampToDateTime(Convert.ToDouble(playerNode["lastlogoff"].InnerText));
                        if (playerNode["profileurl"] != null)
                            player.ProfileURL = playerNode["profileurl"].InnerText;
                        if (playerNode["avatar"] != null)
                            player.Avatar = playerNode["avatar"].InnerText;
                        if (playerNode["avatarmedium"] != null)
                            player.AvatarMedium = playerNode["avatarmedium"].InnerText;
                        if (playerNode["avatarfull"] != null)
                            player.AvatarFull = playerNode["avatarfull"].InnerText;
                        if (playerNode["personastate"] != null)
                            player.PersonaState = Convert.ToInt32(playerNode["personastate"].InnerText);
                        if (playerNode["realname"] != null)
                            player.RealName = playerNode["realname"].InnerText;

                        if (playerNode["primaryclanid"] != null)
                            player.PrimaryClanID = Convert.ToInt64(playerNode["primaryclanid"].InnerText);
                        if (playerNode["timecreated"] != null)
                            player.TimeCreated = UnixTimeStampToDateTime(Convert.ToDouble(playerNode["timecreated"].InnerText));
                        if (playerNode["loccountrycode"] != null)
                            player.LocCountyCode = playerNode["loccountrycode"].InnerText;
                        if (playerNode["locstatecode"] != null)
                            player.LocStateCode = playerNode["locstatecode"].InnerText;
                        if (playerNode["loccityid"] != null)
                            player.LocCityID = playerNode["loccityid"].InnerText;

                        if (!QuiteMode)
                            Console.WriteLine("Steam ID: " + player.SteamID + " Name: " + player.PersonaName + " Real Name: " + (player.RealName ?? ""));

                        newPlayersAdded = true;
                    }
                }
            }

            players.ForEach(x => x.LastUpdated = DateTime.Now);
            players.UpdateAll();

            if (File.Exists("PlayerSummaryInfo" + players[0].SteamID + "(" +
                                                DateTime.Now.ToString("ddMMyyyy") + ").xml"))
            {
                File.Delete("PlayerSummaryInfo" + players[0].SteamID + "(" +
                            DateTime.Now.ToString("ddMMyyyy") + ").xml");
            }

            return newPlayersAdded;
        }
Exemple #8
0
        private void addPlayer(PlayersList players, TeamPlayersList teamPlayersList, int teamID, XmlNode teamNode, string playerAccountId)
        {
            Players player = new Players();
            if (teamNode[playerAccountId] != null)
            {
                int steamID = Convert.ToInt32(teamNode[playerAccountId].InnerText);

                if (players.Find(x => x.SteamID == steamID) == null)
                {
                    player.LoadItem(steamID);

                    player.SteamID = steamID;
                    //player.TeamID = teamID;

                    players.Add(player);

                    TeamPlayers teamPlayers = new TeamPlayers();
                    teamPlayers.GetByTeamPlayer(teamID, steamID);

                    teamPlayers.Team = teamID;
                    teamPlayers.Player = steamID;
                    teamPlayers.InsertOrUpdate();

                    if (!QuiteMode)
                        Console.WriteLine("Player ID:" + player.SteamID);
                }

                TeamPlayers teamPlayer = teamPlayersList.Find(x => x.Player == steamID);
                if (teamPlayer != null)
                    teamPlayersList.Remove(teamPlayer);
            }
        }
Exemple #9
0
        public void Decode(byte[] array)
        {
            reader = new KrosmagaReader();
            reader.SetData(array);
            int tag;

            while (reader.B.BaseStream.Position < reader.B.BaseStream.Length && (tag = reader.ReadTag()) != 0)
            {
                if (tag <= 48)
                {
                    if (tag <= 18)
                    {
                        if (tag == 10)
                        {
                            Data.Player player = new Data.Player();
                            int         size   = (int)reader.ReadRawVarint32();
                            player.Decode(reader.ReadMessage(size));
                            PlayersList.Add(player);
                            continue;
                        }
                        if (tag == 18)
                        {
                            BackgroundName = reader.ReadString();
                            continue;
                        }
                    }
                    else
                    {
                        if (tag == 24)
                        {
                            BoardColumnsCount = (int)reader.ReadRawVarint32();
                            continue;
                        }
                        if (tag == 32)
                        {
                            BoardRowsCount = (int)reader.ReadRawVarint32();
                            continue;
                        }
                        if (tag == 48)
                        {
                            MyIndex = (int)reader.ReadRawVarint32();
                            continue;
                        }
                    }
                }
                else if (tag <= 72)
                {
                    if (tag == 56)
                    {
                        MyCardsCount = (int)reader.ReadRawVarint32();
                        continue;
                    }
                    if (tag == 64)
                    {
                        OpponentCardsCount = (int)reader.ReadRawVarint32();
                        continue;
                    }
                    if (tag == 72)
                    {
                        GameType = (Enums.GameType)Enum.Parse(typeof(Enums.GameType), reader.ReadRawVarint32().ToString());
                        continue;
                    }
                }
                else
                {
                    if (tag == 80)
                    {
                        DofusBaseLife = (int)reader.ReadRawVarint32();
                        continue;
                    }
                    if (tag == 88)
                    {
                        DraftAllInOwnAmount = (int)reader.ReadRawVarint32();
                        continue;
                    }
                    if (tag == 96)
                    {
                        DraftAllInOpponentAmount = (int)reader.ReadRawVarint32();
                        continue;
                    }
                }
            }
        }
Exemple #10
0
        public void enterSquare(ClientSession cs)
        {
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ENTER_SQUARE_ACK))
            {
                PlayersList.Add(cs);
                oPacket.WriteInt(0);              //00 00 00 00
                oPacket.WriteInt(CurrentPlayers); //00 00 00 04

                /*for (int i = 0; i < CurrentPlayers; i++)
                 * {
                 *  oPacket.WriteInt(1);//00 00 00 01
                 *  oPacket.WriteInt(4);//00 00 00 04
                 *  oPacket.WriteInt(1273);//00 00 04 F9
                 *  oPacket.WriteInt("1273_1.png".Length * 2);//00 00 00 14
                 *  oPacket.WriteUnicodeString("1273_1.png");//31 00 32 00 37 00 33 00 5F 00 31 00 2E 00 70 00 6E 00 67 00
                 *  oPacket.WriteInt("BrokenLimit".Length * 2);//00 00 00 16
                 *  oPacket.WriteUnicodeString("BrokenLimit");//42 00 72 00 6F 00 6B 00 65 00 6E 00 4C 00 69 00 6D 00 69 00 74 00
                 *  oPacket.WriteInt(cs.LoginUID);//00 01 59 58
                 *  oPacket.WriteInt(cs.Nick.Length * 2);//00 00 00 08
                 *  oPacket.WriteUnicodeString(cs.Nick);//41 00 6C 00 79 00 73 00
                 *  oPacket.WriteByte(4);//04 //CharID
                 *  oPacket.WriteInt(1);//00 00 00 01
                 *  oPacket.WriteInt(7);//Length Equips
                 *  for (int j = 0; j < 7; j++)
                 *  {
                 *      oPacket.WriteInt(380070);//itemID
                 *  }
                 *  oPacket.WriteHexString("00 00 00 0D 00 00 00 00 00 00 00 01 40 F1 99 9A 3E 8A 3D 71 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 12 C8 F2 00 00 E5 74 00 01 BD E6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                 * }*/

                foreach (ClientSession u in PlayersList)
                {
                    oPacket.WriteInt(1);                               //00 00 00 01
                    oPacket.WriteInt(4);                               //00 00 00 04
                    oPacket.WriteInt(u.MyGuilds.GuildID);              //00 00 04 F9
                    oPacket.WriteInt(u.MyGuilds.MarkName.Length * 2);  //00 00 00 14
                    oPacket.WriteUnicodeString(u.MyGuilds.MarkName);   //31 00 32 00 37 00 33 00 5F 00 31 00 2E 00 70 00 6E 00 67 00
                    oPacket.WriteInt(u.MyGuilds.GuildName.Length * 2); //00 00 00 16
                    oPacket.WriteUnicodeString(u.MyGuilds.GuildName);  //42 00 72 00 6F 00 6B 00 65 00 6E 00 4C 00 69 00 6D 00 69 00 74 00
                    oPacket.WriteInt(u.LoginUID);                      //00 01 59 58
                    oPacket.WriteInt(u.Nick.Length * 2);               //00 00 00 08
                    oPacket.WriteUnicodeString(u.Nick);                //41 00 6C 00 79 00 73 00
                    int MyCharPos = -1;
                    for (int t = 0; t < u.MyCharacter.MyChar.Length; t++)
                    {
                        if (u.MyCharacter.MyChar[t].CharType == u.CurrentChar)
                        {
                            MyCharPos = t;
                        }
                    }
                    oPacket.WriteByte((byte)u.MyCharacter.MyChar[MyCharPos].CharType);                    //0F//CharID

                    /*oPacket.WriteByte((byte)u.CurrentChar);//0F//CharID
                     * //oPacket.WriteInt(0);//Equips
                     * int MyCharPos = -1;
                     * for (int t = 0; t < cs.MyCharacter.MyChar.Length; t++)
                     *  if (cs.MyCharacter.MyChar[t].CharType == u.CurrentChar)
                     *      MyCharPos = t;*/
                    oPacket.WriteInt(u.MyCharacter.MyChar[MyCharPos].Level);//00 00 00 01//Level
                    oPacket.WriteInt(u.MyCharacter.MyChar[MyCharPos].Equip.Length);
                    for (int y = 0; y < u.MyCharacter.MyChar[MyCharPos].Equip.Length; y++)
                    {
                        oPacket.WriteInt(u.MyCharacter.MyChar[MyCharPos].Equip[y].ItemID);
                    }
                    //oPacket.WriteHexString("00 00 00 03 00 0D 1D D0 00 0D 1D DA 00 0D 1D E4");
                    oPacket.WriteHexString("00 00 00 04 00 00 00 00 00 00 00 01 40 F1 99 9A 3E 8A 3D 71 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 12 C8 F2 00 00 E5 74 00 01 BD E6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                    //("00 00 00 04 00 00 00 00 00 00 00 01 41 14 00 00 3E 8A 3D 71 02 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 E5 6A 00 00 E5 88 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 06 00 00 13 FB 00 00 00 1E 64 00 65 00 66 00 61 00 75 00 6C 00 74 00 6D 00 61 00 72 00 6B 00 2E 00 70 00 6E 00 67 00 00 00 00 14 45 00 6C 00 69 00 74 00 65 00 4D 00 61 00 66 00 69 00 61 00 00 05 F1 A4 00 00 00 16 42 00 72 00 61 00 69 00 6E 00 4D 00 61 00 73 00 74 00 65 00 72 00 0E 00 00 00 4F 00 00 00 20 00 07 DF 6E 00 0C 43 EC 00 0A E2 4A 00 0A DD C2 00 0A DC F0 00 0A DC FA 00 0A D0 52 00 0A D0 3E 00 0A D0 66 00 0A D0 5C 00 0A D0 48 00 0A D0 70 00 0A DD 72 00 12 4C 24 00 0A DD 36 00 0A DB 06 00 12 4C 2E 00 12 4C 38 00 12 4C 10 00 12 4C 1A 00 12 4C 42 00 12 56 B0 00 0A DD 7C 00 12 56 CE 00 12 4E D6 00 0A DE 1C 00 12 56 A6 00 10 5D BA 00 10 57 16 00 0A DE 12 00 12 56 C4 00 05 0F 6E 00 00 00 04 00 00 00 00 00 00 00 01 40 F1 99 9A 3E 8A 3D 71 0B 00 00 00 00 00 00 13 AF EC 00 00 00 10 50 00 72 00 69 00 6E 00 73 00 69 00 6F 00 6E 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 04 00 12 C8 F2 00 00 E5 74 00 01 BD F0 00 01 BE 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 13 E6 CE 00 00 00 01 31 FD D9 2D 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E6 D8 00 00 00 01 31 FD D9 2E 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E6 E2 00 00 00 01 31 FD D9 2F 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E6 EC 00 00 00 01 31 FD D9 30 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E8 22 00 00 00 01 31 FD D9 31 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 4A 00 00 00 01 31 FD D9 C0 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 54 00 00 00 01 31 FD D9 C1 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 5E 00 00 00 01 31 FD D9 C2 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 68 00 00 00 01 31 FD D9 C3 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 72 00 00 00 01 31 FD D9 C4 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 7C 00 00 00 01 31 FD D9 C5 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03");
                }
                oPacket.WriteIPFromString(Server.TCPRelayIP, true);
                oPacket.WriteShort(Server.TCPRelayPort);//2D 50 0C C6 25 E4
                oPacket.WriteHexString("00 00 00 00 00 00 00 01 41 14 00 00 3E 8A 3D 71");
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }