示例#1
0
        public double ChanceToReceivePass(Player passingPlayer, TeamStrategy strategy)
        {
            if (passingPlayer == this)
            {
                return 0;
            }
            else
            {
                int distanceForward = passingPlayer.Position.DistanceForward(Position);
                int distanceSideways = passingPlayer.Position.DistanceSideways(Position);

                double chance = 1;
                
                if (distanceForward > 0)
                {
                    chance = 10.0 / distanceForward;
                }
                else if (distanceForward == 0)
                {
                    chance = 5.0;
                }
                else
                {
                    chance = 1.0 / (-distanceForward);
                }

                if (distanceSideways > 0)
                {
                    chance /= distanceSideways;
                }

                if (IsStrategicPlayer(strategy) && !passingPlayer.IsStrategicPlayer(strategy))
                {
                    chance *= 1.5;
                }

                if (IsForward)
                {
                    chance *= 2.0;
                }

                if (IsGoalkeeper)
                {
                    chance /= 5;
                }

                return chance;
            }
        }