コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sheets"></param>
        /// <returns></returns>
        protected override StatSheet AggregateStatSheets(params StatSheet[] sheets)
        {
            DefensiveStatSheet ret = new DefensiveStatSheet((Player)this.entity);

            foreach (DefensiveStatSheet sheet in sheets)
            {
                ret.tackles          += sheet.tackles;
                ret.sacks            += sheet.sacks;
                ret.interceptions    += sheet.interceptions;
                ret.fumbleRecoveries += sheet.fumbleRecoveries;
                ret.touchdowns       += sheet.touchdowns;
            }
            return(ret);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>int</returns>
        public override int Execute()
        {
            StringBuilder report = new StringBuilder();

            DefensiveStatSheet defensiveStats = (DefensiveStatSheet)this.principalBallcarrier.Stats[StatTypes.Defense];

            defensiveStats.Interceptions++;

            this.cc.ChangePossession();
            this.cc.ToggleDirection();

            int returnDistance = Dice.Roll(this.principalBallcarrier.PlayerSkills.Run);

            report.Append("INTERCEPTION!!!! ");


            report.Append(String.Format("{0} intercepts the ball and takes it to the {1} for a return of {2} yards! First and 10.", this.principalBallcarrier.Name, this.cc.CurrentYardLine, playLength));

            playReport = report.ToString();
            playLength = returnDistance;
            return(playLength);
        }
コード例 #3
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);
        }