Exemplo n.º 1
0
        public IStatValue Extract(Root root, int playerId, Constants.StatSource statSource)
        {
            Player player;

            if (root.Players.TryGetValue(playerId, out player))
            {
                IPlayerData playerData;
                if (player.PlayerData.TryGetValue(statSource, out playerData))
                {
                    float statValue;
                    if (playerData.Stats.TryGetValue(this.StatID, out statValue))
                    {
                        return(new CountingStatValue((int)statValue));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public PlayerGroupStatAnalysis(IEnumerable <int> playerList, IEnumerable <int> playerSubset, int selectedPlayer, IStatExtractor extractor, Root root, Constants.StatSource statSource)
        {
            this.playerList     = playerList;
            this.extractor      = extractor;
            this.root           = root;
            this.StatSource     = statSource;
            this.selectedPlayer = selectedPlayer;

            if (playerSubset != null)
            {
                this.playerSubset = new HashSet <int>();
                foreach (int playerId in playerSubset)
                {
                    this.playerSubset.Add(playerId);
                }
            }
            else
            {
                this.playerSubset = null;
            }

            this.dataSet = ExtractAnalysisDataSet(this.playerList, this.extractor, this.root, this.StatSource);

            this.DataPoints   = this.dataSet.Count;
            this.MinStatValue = float.MaxValue;
            this.MaxStatValue = float.MinValue;
            foreach (Tuple <IStatValue, int> dataItem in this.dataSet)
            {
                this.MinStatValue = Math.Min(this.MinStatValue, dataItem.Item1.Value);
                this.MaxStatValue = Math.Max(this.MaxStatValue, dataItem.Item1.Value);
            }
        }
Exemplo n.º 3
0
 public PlayerGroupStatAnalysis(IEnumerable <int> playerList, IEnumerable <int> playerSubset, IStatExtractor extractor, Root root, Constants.StatSource statSource)
     : this(playerList, playerSubset, -1, extractor, root, statSource)
 {
 }
Exemplo n.º 4
0
 public PlayerGroupStatAnalysis(IEnumerable <int> playerList, int selectedPlayer, IStatExtractor extractor, Root root, Constants.StatSource statSource)
     : this(playerList, null, selectedPlayer, extractor, root, statSource)
 {
 }
Exemplo n.º 5
0
        public static List <Tuple <IStatValue, int> > ExtractAnalysisDataSet(IEnumerable <int> playerList, IStatExtractor extractor, Root root, Constants.StatSource statSource)
        {
            List <Tuple <IStatValue, int> > playersWithStats = new List <Tuple <IStatValue, int> >();

            foreach (int player in playerList)
            {
                IStatValue statValue = extractor.Extract(root, player, statSource);
                if (statValue != null && !float.IsInfinity(statValue.Value))
                {
                    playersWithStats.Add(new Tuple <IStatValue, int>(statValue, player));
                }
            }

            if (extractor.MoreIsBetter)
            {
                playersWithStats.Sort((Tuple <IStatValue, int> x, Tuple <IStatValue, int> y) => y.Item1.Value.CompareTo(x.Item1.Value));
            }
            else
            {
                playersWithStats.Sort((Tuple <IStatValue, int> x, Tuple <IStatValue, int> y) => x.Item1.Value.CompareTo(y.Item1.Value));
            }

            return(playersWithStats);
        }