Ejemplo n.º 1
0
        public Card RollCard(Squad team, IAction action, MatchMinute[] minutes)
        {
            PositionalArea positionalArea = ChanceHelper.PercentBase100Chance(action.PositionalChance, x => x.Value).Key;

            var sentOffCardIds = minutes.SelectMany(x => x.Events).Where(x => x is RedCard).Select(x => x.CardId);
            var cards          = team.Lineup[positionalArea.ToString()].Where(x => x != null && !sentOffCardIds.Contains(x.Id)).ToList();

            int r = _randomnessProvider.Next(cards.Count);

            return(cards.ElementAtOrDefault(r)); //returns null TODO fix rolling position with 0 cards due to sending off
        }
Ejemplo n.º 2
0
        public int CurrentRating(PositionalArea positionalArea, Models.Match.Match match, Squad squad)
        {
            var players = squad.Lineup.Where(x => x.Value != null && x.Key == positionalArea.ToString()).SelectMany(x => x.Value).ToList();

            var sentOffCardIds = match.Minutes.SelectMany(x => x.Events).Where(x => x is RedCard).Select(x => x.CardId);
            var onTheField     = players.Where(x => x != null && !sentOffCardIds.Contains(x.Id)).ToList();

            if (onTheField.Count == 0 || players.Count == 0)
            {
                return(0);
            }
            return((int)Math.Round((onTheField.Sum(x => x.Rating * 0.7) + onTheField.Sum(x => _calculatedCardStatService.Fitness(match, x.Id) * 0.3)) / players.Count));
        }
Ejemplo n.º 3
0
        public static int CurrentRating(PositionalArea positionalArea, Squad squad, IEnumerable <IEvent> events)
        {
            var players = squad.Lineup.Where(x => x.Value != null && x.Key == positionalArea.ToString()).SelectMany(x => x.Value).ToList();

            var sentOffCardIds = events.Where(x => x.GetType() == typeof(RedCard)).Select(x => x.CardId);
            var onTheField     = players.Where(x => x != null && !sentOffCardIds.Contains(x.Id)).ToList();

            if (onTheField.Count == 0 || players.Count == 0)
            {
                return(0);
            }
            return((int)Math.Round((onTheField.Sum(x => x.Rating * 0.7) + onTheField.Sum(x => x.Fitness * 0.3)) / players.Count));
        }