Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        private void Loop()
        {
            for (int i = 0; i < 80; ++i)
            {
                if (((i % 15) == 1) && (i != 1))
                {
                    scoreboard.MoveToNextQuarter();
                }
                if (!gameOver)
                {
                    //run
                    Team tip  = cc.TeamInPossession;
                    Team tnip = cc.TeamNotInPossession;
                    int  roll = Dice.Roll("d2");
                    if (roll == 1)//run
                    {
                        Player         ballcarrier = tip.TeamOffense.GetPlayerAtPosition("TB");
                        int            playerIndex = tip.GetIndexOfPlayer(ballcarrier);
                        CarryStatSheet runStats    = (CarryStatSheet)gameStats[tip, playerIndex][StatTypes.Run];
                        RunPlay        run         = new RunPlay(cc, tip, tnip, ballcarrier, runStats);
                        run.Execute();
                    }
                    else
                    {
                        //pass
                        Player thrower = tip.TeamOffense.GetPlayerAtPosition("QB");

                        PassPlay pass = new PassPlay(gameStats, cc);
                        pass.Execute();
                    }
                    Thread.Sleep(TIMER_SLEEP);
                }
            }
            finalScore = this.announcer.ReportFinalScore();
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sheets">StatSheet[]</param>
        /// <returns>StatSheet</returns>
        protected override StatSheet AggregateStatSheets(params StatSheet[] sheets)
        {
            CarryStatSheet ret = new CarryStatSheet((Player)this.entity);

            foreach (CarryStatSheet sheet in sheets)
            {
                ret.touches += sheet.touches;
                ret.yards   += sheet.yards;
                ret.touchdowns.AddRange(sheet.touchdowns.ToArray());
                ret.fumbles += sheet.fumbles;
                if (sheet.longPlay > ret.LongPlay)
                {
                    ret.longPlay = sheet.LongPlay;
                }
            }
            return(ret);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="kickingTeam">Team</param>
        /// <param name="receivingTeam">Team</param>
        /// <returns>int</returns>
        public int MoveBallKickoff(Team kickingTeam, Team receivingTeam, int kickDistance)
        {
            if (currentDirection == Direction.Left)
            {
                if ((currentIndex - kickDistance) <= 0)//touchback
                {
                    kickDistance = currentIndex;
                    currentIndex = 19;
                }
                else
                {
                    currentIndex -= kickDistance;
                }
            }
            else if (currentDirection == Direction.Right)
            {
                if ((currentIndex + kickDistance) >= 99)//touchback
                {
                    kickDistance = currentIndex;
                    currentIndex = 79;
                }
                else
                {
                    currentIndex += kickDistance;
                }
            }


            SetBall(currentIndex, currentDirection, receivingTeam, kickingTeam);
            ToggleDirection();
            Player kicker      = kickingTeam.TeamOffense.GetPlayerAtPosition("K");
            Player returner    = receivingTeam.TeamOffense.GetPlayerAtPosition("KR");
            int    playerIndex = receivingTeam.GetIndexOfPlayer(returner);
            string reportPlay  = String.Format("And the kickoff by {0} is in the air! It is fielded by {1} at the {2} yardline", kicker.Name, returner.Name, CurrentYardLine);

            this.game.GameAnnouncer.ReportGameEvent(reportPlay);

            //Return the kickoff
            CarryStatSheet    returnStats   = (CarryStatSheet)game.GameStats[receivingTeam, playerIndex][StatTypes.Return];
            KickoffReturnPlay kickoffReturn = new KickoffReturnPlay(this, receivingTeam, kickingTeam, returner, returnStats);
            int returnDistance = kickoffReturn.Execute();

            MoveBallKickoffReturn(kickoffReturn, false);

            return(kickDistance);
        }
Esempio n. 4
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];
        }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cc">ChainCrew</param>
 /// <param name="offense">Team</param>
 /// <param name="defense">Team</param>
 /// <param name="ballcarrier">Player</param>
 public RunPlay(ChainCrew cc, Team offense, Team defense, Player ballcarrier, CarryStatSheet runStats) : base(cc, offense, defense)
 {
     this.principalBallcarrier = ballcarrier;
     this.runStats             = runStats;
 }
Esempio n. 6
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);
        }