Ejemplo n.º 1
0
        public IEvent SpawnEvent(Card card, Guid squadId, Models.Match.Match match)
        {
            var oppositionsDefenceRating = _ratingService.CurrentRating(PositionalArea.DEF, match, match.GetOppositionSquad(squadId));
            var shootersRating           = _ratingService.CurrentRating(card.Id, match, match.GetSquad(squadId));

            var shotOnTargetChance = (int)Math.Round(oppositionsDefenceRating + shootersRating * Constants.ShooterAgainstDefendersModifier);

            var randomNumber = _randomnessProvider.Next(0, shotOnTargetChance);

            if (randomNumber <= shootersRating * Constants.ShooterAgainstDefendersModifier)
            {
                var gkRating = _ratingService.CurrentRating(PositionalArea.GK, match, match.GetOppositionSquad(squadId));

                var goalChanceAccum = (int)Math.Round(gkRating + shootersRating * Constants.ShooterAgainstGkModifier);

                var goalRandomNumber = _randomnessProvider.Next(0, goalChanceAccum);
                if (goalRandomNumber <= shootersRating * Constants.ShooterAgainstGkModifier)
                {
                    return(new Goal(card.Id, squadId));
                }
                return(new ShotOnTarget(card.Id, squadId));
            }

            return(new ShotOffTarget(card.Id, squadId));
        }
Ejemplo n.º 2
0
 public int PossessionChance(Squad squad, Models.Match.Match match)
 {
     return((int)Math.Round((_ratingService.CurrentRating(PositionalArea.GK, match, squad) * 0.1) +
                            (_ratingService.CurrentRating(PositionalArea.DEF, match, squad) * 0.5) +
                            (_ratingService.CurrentRating(PositionalArea.MID, match, squad) * 1) +
                            (_ratingService.CurrentRating(PositionalArea.ATT, match, squad) * 0.5)));
 }