Example #1
0
        public void HandleWalk(GameEvent curr)
        {
            Baserunner[] newBases = new Baserunner[4];
            Baserunner   scored   = null;

            int[] prevBases = new int[4];

            if (m_bases[1] != null)
            {
                newBases[2]  = m_bases[1];
                prevBases[2] = 1;
            }
            else
            {
                newBases[2]  = m_bases[2];
                prevBases[2] = 2;
            }

            if (m_bases[1] != null && m_bases[2] != null)
            {
                newBases[3]  = m_bases[2];
                prevBases[3] = 2;
            }
            else
            {
                newBases[3]  = m_bases[3];
                prevBases[3] = 3;
            }

            if (m_bases[1] != null && m_bases[2] != null && m_bases[3] != null)
            {
                scored = m_bases[3];
            }
            else
            {
                newBases[3]  = m_bases[3];
                prevBases[3] = 3;
            }

            List <GameEventBaseRunner> runners = new List <GameEventBaseRunner>();

            for (int i = 1; i < 4; i++)
            {
                if (newBases[i] != null)
                {
                    runners.Add(CreateGebr(newBases[i].runnerId, newBases[i].pitcherId, prevBases[i], i));
                }

                m_bases[i] = newBases[i];
            }
            if (scored != null)
            {
                runners.Add(CreateGebr(scored.runnerId, scored.pitcherId, 3, 4));
                IncrementScore();
            }

            CopyRunnersToEvent(curr, runners);

            PutBatterOnBase(curr, 1);
        }
Example #2
0
        private void PutBatterOnBase(GameEvent curr, int newBase)
        {
            if (newBase > 0 && newBase < 4)
            {
                m_bases[newBase] = new Baserunner(curr.batterId, curr.pitcherId);
            }
            var geb     = CreateGebr(curr.batterId, curr.pitcherId, 0, newBase);
            var runners = curr.baseRunners.ToList();

            runners.Add(geb);
            CopyRunnersToEvent(curr, runners);
        }
Example #3
0
        public void HandleSingle(GameEvent curr)
        {
            List <GameEventBaseRunner> runners = new List <GameEventBaseRunner>();

            // Score runners in scoring position
            for (int i = 2; i < 4; i++)
            {
                if (m_bases[i] != null)
                {
                    var geb = CreateGebr(m_bases[i].runnerId, m_bases[i].pitcherId, i, 4);
                    runners.Add(geb);
                    IncrementScore();
                }
            }
            m_bases[2] = null;
            m_bases[3] = null;

            if (m_bases[1] != null)
            {
                // Find new base for guy on first and put him there
                int newBase     = 1 + GetSingleAdvanceFromFirst(m_bases[1].runnerId);
                var whosOnFirst = CreateGebr(m_bases[1].runnerId, m_bases[1].pitcherId, 1, newBase);
                runners.Add(whosOnFirst);

                if (newBase == 4)
                {
                    IncrementScore();
                }

                if (newBase > 0 && newBase < 4)
                {
                    m_bases[newBase] = new Baserunner(whosOnFirst.runnerId, whosOnFirst.responsiblePitcherId);
                }
                m_bases[1] = null;
            }

            CopyRunnersToEvent(curr, runners);

            // Batter on 1st
            PutBatterOnBase(curr, 1);
        }