Exemplo n.º 1
0
        /// <summary>
        /// Return the player who's name is the same as the given vmPlayer instance
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public vmPlayer MapPlayer(vmPlayer _value)
        {
            var Candidates = Players.Where(p => p.Name == _value.Name).ToList();

            if (Candidates.Count == 1)
            {
                return(Candidates.First());
            }
            return(_value);
        }
Exemplo n.º 2
0
        public void AddOrUpdateLocalPlayer()
        {
            Settings _Settings = Settings.GetInstance();

            vmPlayer LocalPlayer = new vmPlayer();

            object value = _Settings.Get("UserID");

            if (!String.IsNullOrEmpty((string)value))
            {
                if (value is string)
                {
                    LocalPlayer.ID = (string)value;
                }

                value = _Settings.Get("ScreenName");
                if ((value is string))
                {
                    LocalPlayer.Name = (string)value;
                }

                LocalPlayer.LocalPlayer = true;

                var LocalPlayers = Players.Where(p => p.ID == LocalPlayer.ID).ToList();

                //Add a new local player
                if (LocalPlayers.Count() == 0)
                {
                    AddPlayer(LocalPlayer);
                }

                //Update the existing player
                if (LocalPlayers.Count() > 0)
                {
                    LocalPlayers.First().Name        = LocalPlayer.Name;
                    LocalPlayers.First().LocalPlayer = true;
                }
            }

            //Set other players to false if they have a localplayer-flag set
            var NonLocalPlayers = Players.Where(p => p.ID != LocalPlayer.ID && p.LocalPlayer == true).ToList();

            foreach (vmPlayer Player in NonLocalPlayers)
            {
                Player.LocalPlayer = false;
            }
        }
Exemplo n.º 3
0
        public void AddPlayer(String Name, String ID, String ProfileImage)
        {
            var MatchingPlayers = Players.Where(p => p.Name == Name);

            if (MatchingPlayers.Count() == 0)
            {
                vmPlayer newPlayer = new vmPlayer();
                newPlayer.ID           = ID;
                newPlayer.Name         = Name;
                newPlayer.ProfileImage = ProfileImage;
                newPlayer.LastMatch    = DateTime.Now;

                Players.Add(newPlayer);
            }
            else
            {
                foreach (vmPlayer MatchingPlayer in MatchingPlayers)
                {
                    MatchingPlayer.LastMatch = DateTime.Now;
                }
            }

            FilterCollection();
        }
Exemplo n.º 4
0
        public vmNewMatch()
        {
            Player1             = new vmPlayer();
            Player1.Name        = "Player 1";
            Player2             = new vmPlayer();
            Player2.Name        = "Player 2";
            Player1Partner      = new vmPlayer();
            Player1Partner.Name = "Partner";
            Player2Partner      = new vmPlayer();
            Player2Partner.Name = "Partner";
            BestOutOf           = 1;
            GamesPerSet         = 6;
            LogLevel            = 0;
            Type             = 0;
            Surface          = 0;
            TiebreakFinalSet = true;
            ShowAdvanced     = false;
            Locations        = new ObservableCollection <vmLocation>();

            // TimedOut on Windows Store App
            //GetPositionAsync();

            CreateMatchVariants();
        }
Exemplo n.º 5
0
 public void AddPlayer(vmPlayer _Player)
 {
     AddPlayer(_Player.Name, _Player.ID, _Player.ProfileImage);
 }