Exemple #1
0
        public bool PassBall(FootballPlayer playerWithBall, FootballPlayer teamPlayer, FootballPlayer opponentPlayer)
        {
            //player with ball shoots ball towards team player. opponent player is defending against this action
            var teamValue    = (playerWithBall.Passing + teamPlayer.BallControl) / 2;
            var chanceToPass = (double)teamValue / (teamValue + opponentPlayer.Tackles);

            return(chanceToPass > _randomHandler.NextDouble());
        }
Exemple #2
0
        public void InitMatch(Match match)
        {
            //teams get placed at their starting position
            ResetTeam(match.Team1, TeamConstants.Team1Positions);
            ResetTeam(match.Team2, TeamConstants.Team2Positions);

            //a coin toss is made, the team that wins gets the ball first
            var coinToss = _randomHandler.NextDouble();

            GiveBall(match, coinToss >= 0.5 ? match.Team1 : match.Team2);
        }