Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="thrower">Player</param>
        /// <param name="receiver">Player</param>
        /// <param name="yards">int</param>
        /// <param name="isTd">int</param>
        public void CompletePass(Player thrower, Player receiver, int yards, bool isTd)
        {
            this.attempts++;
            this.completions++;
            this.yards        += yards;
            this.completionPct = CalculatePercentage(attempts, completions);
            this.passerRating  = PassPlayStatSheet.CalculatePasserRating(this.attempts, this.yards, this.touchdowns.Count, this.completions, this.interceptions);
            CheckLongPlay(yards);
            //update receiver stats here:
            //receiverGameStats.AddRun(yards, isTd, false);
            //((CarryStatSheet)receiver.Stats[StatTypes.Receive]).AddRun(yards, isTd,false);

            if (isTd)
            {
                AddTouchdown(yards);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cc"></param>
        /// <param name="offense"></param>
        /// <param name="defense"></param>
        /// <param name="gamePassStats"></param>
        /// <param name="gameRunStats"></param>
        /// <param name="gameReceiverStats"></param>
        public PassPlay(GameStats gameStats, ChainCrew cc)
            : base(cc, cc.TeamInPossession, cc.TeamNotInPossession)
        {
            Team tip  = this.offense;
            Team tnip = this.defense;

            this.thrower              = tip.TeamOffense.GetPlayerAtPosition("QB");
            this.availableReceivers   = tip.TeamOffense.AvailableReceivers;
            this.principalBallcarrier = SelectReceiver(tip.TeamOffense.AvailableReceivers[0], tip.TeamOffense.AvailableReceivers);

            int throwerIndex  = tip.GetIndexOfPlayer(this.thrower);
            int receiverIndex = tip.TeamOffense.GetAvailableReceiverAtIndex(this.principalBallcarrier);

            this.gamePassStats     = (PassPlayStatSheet)gameStats[tip, throwerIndex][StatTypes.Pass];
            this.gameRunStats      = (CarryStatSheet)gameStats[tip, throwerIndex][StatTypes.Run];
            this.gameReceiverStats = (CarryStatSheet)gameStats[tip, receiverIndex][StatTypes.Receive];
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sheets">StatSheet[]</param>
        /// <returns>StatSheet</returns>
        protected override StatSheet AggregateStatSheets(params StatSheet[] sheets)
        {
            PassPlayStatSheet ret = new PassPlayStatSheet((Player)this.entity);

            foreach (PassPlayStatSheet sheet in sheets)
            {
                ret.yards += sheet.yards;
                ret.touchdowns.AddRange(sheet.touchdowns.ToArray());
                ret.completions  += sheet.completions;
                ret.attempts     += sheet.attempts;
                ret.completionPct = CalculatePercentage(ret.attempts, ret.completions);
                ret.passerRating  = PassPlayStatSheet.CalculatePasserRating(ret.attempts, ret.yards, ret.touchdowns.Count, ret.completions, ret.interceptions);
                if (sheet.longPlay > ret.LongPlay)
                {
                    ret.longPlay = sheet.LongPlay;
                }
            }
            return(ret);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>int</returns>
        public override int Execute()
        {
            this.cc.Field.Scoreboard.AddScore(scoringPlay);
            Player ballcarrier        = scoringPlay.PrincipalBallcarrier;
            int    indexOfBallcarrier = ballcarrier.Team.GetIndexOfPlayer(ballcarrier);

            if (scoringPlay is RunPlay)
            {
                CarryStatSheet gameStats = (CarryStatSheet)game.GameStats[ballcarrier.Team, indexOfBallcarrier][StatTypes.Run];
                gameStats.AddTouchdown(scoringPlay.PlayLength);
                ((CarryStatSheet)ballcarrier.Stats[StatTypes.Run]).AddTouchdown(scoringPlay.PlayLength);
            }
            else if (scoringPlay is PassPlay)
            {
                Player thrower       = ((PassPlay)scoringPlay).Thrower;
                int    indexOfPasser = thrower.Team.GetIndexOfPlayer(thrower);

                PassPlayStatSheet gamePassingStats = (PassPlayStatSheet)game.GameStats[ballcarrier.Team, indexOfPasser][StatTypes.Pass];
                gamePassingStats.AddTouchdown(scoringPlay.PlayLength);
                ((PassPlayStatSheet)thrower.Stats[StatTypes.Pass]).AddTouchdown(scoringPlay.PlayLength);
                CarryStatSheet gameReceivingStats = (CarryStatSheet)game.GameStats[ballcarrier.Team, indexOfBallcarrier][StatTypes.Receive];
                gameReceivingStats.AddTouchdown(scoringPlay.PlayLength);
                ((CarryStatSheet)ballcarrier.Stats[StatTypes.Receive]).AddTouchdown(scoringPlay.PlayLength);
            }
            else if ((scoringPlay is Interception) || (scoringPlay is Fumble))
            {
                DefensiveStatSheet gameDefensiveStats = (DefensiveStatSheet)game.GameStats[ballcarrier.Team, indexOfBallcarrier][StatTypes.Defense];
                gameDefensiveStats.DefensiveTouchdowns++;
                ((DefensiveStatSheet)ballcarrier.Stats[StatTypes.Defense]).DefensiveTouchdowns++;
            }
            else if (scoringPlay is KickoffReturnPlay)
            {
                CarryStatSheet gameReturnStats = (CarryStatSheet)game.GameStats[ballcarrier.Team, indexOfBallcarrier][StatTypes.Return];
                gameReturnStats.AddTouchdown(scoringPlay.PlayLength);
                ((CarryStatSheet)ballcarrier.Stats[StatTypes.Return]).AddTouchdown(scoringPlay.PlayLength);
            }

            StringBuilder report = new StringBuilder();

            if (scoringPlay is RunPlay)
            {
                report.Append((String.Format("TOUCHDOWN!! {0}! {1} scores from {2} yards out.", ballcarrier.Team.Name, ballcarrier.Name, scoringPlay.PlayLength)));
            }
            else if (scoringPlay is PassPlay)
            {
                report.Append((String.Format("TOUCHDOWN!! {0}! {1} scores from {2} yards out on a pass from {3}!", ballcarrier.Team.Name, ballcarrier.Name, scoringPlay.PlayLength, ((PassPlay)scoringPlay).Thrower.Name)));
            }
            else if (scoringPlay is KickoffReturnPlay)
            {
                report.Append((String.Format("TOUCHDOWN!! {0}! {1} scores on a {2} yard kickoff return!", ballcarrier.Team.Name, ballcarrier.Name, scoringPlay.PlayLength)));
            }
            else if (scoringPlay is Interception)
            {
                report.Append((String.Format("TOUCHDOWN!! {0}! {1} scores on an interception return of {2} yards!", ballcarrier.Team.Name, ballcarrier.Name, scoringPlay.PlayLength)));
            }
            else if (scoringPlay is Fumble)
            {
                report.Append((String.Format("TOUCHDOWN!! {0}! {1} rumbles into the endzone on a fumble return of {2} yards!", ballcarrier.Team.Name, ballcarrier.Name, scoringPlay.PlayLength)));
            }
            report.AppendLine(String.Format(" And the score is {0}", game.Scoreboard));

            playReport = report.ToString();

            return(scoringPlay.PlayLength);
        }