public override bool Equals(object obj)
        {
            SquadResult other = obj as SquadResult;

            if (other == null)
            {
                return(false);
            }

            var playersSum      = this.Positions.Sum(c => c.Player.BaseId);
            var otherPlayersSum = other.Positions.Sum(c => c.Player.BaseId);

            if (playersSum != otherPlayersSum)
            {
                return(false);
            }

            return(true);
            //for (var i = 0; i < this.Cards.Count(); i++)
            //{
            //    var thisCard = this.Cards.ElementAt(i);
            //    var otherCard = other.Cards.ElementAt(i);
            //    if (otherCard == null || !otherCard.Equals(thisCard))
            //    {
            //        return false;
            //    }
            //}

            //return true;
        }
示例#2
0
        private void AddToResults(string basePlayer, string permutation)
        {
            var allPlayersSum    = this.formation.Positions.Select(pos => pos.Player).Sum(pl => pl.Rating);
            var formationAverage = allPlayersSum / 11;

            if (this.result.Squads.Any(s => s.Rating > formationAverage))
            {
                return;
            }

            this.result.Squads.RemoveAll(s => s.Rating < formationAverage);

            SquadResult squad = new SquadResult();
            var         soma  = 0;

            foreach (var pos in this.formation.Positions)
            {
                if (pos.Player != null)
                {
                    squad.Positions.Add(new PositionResult
                    {
                        PositionEnum = pos.PositionEnum,
                        Player       = pos.Player
                    });

                    soma = soma + pos.Player.Rating;
                }
            }

            if (this.result.Squads.Contains(squad))
            {
                return;
            }

            squad.Rating      = formationAverage;
            squad.BasePlayer  = basePlayer;
            squad.Permutation = permutation;
            this.result.Squads.Add(squad);
        }