public IHalfInningActions FillWalkActions(IHalfInningActions actions)
        {
            HalfInningActionsDto dto = Mapper.Map <HalfInningActionsDto>(actions);

            if (AreBasesLoaded(dto) == true)
            {
                dto.TotalRuns++;
            }
            else
            {
                if (dto.IsRunnerOnFirst && dto.IsRunnerOnSecond)
                {
                    dto.IsRunnerOnFirst = false;
                    dto.IsRunnerOnThird = true;
                }
                else if (dto.IsRunnerOnFirst)
                {
                    dto.IsRunnerOnFirst  = false;
                    dto.IsRunnerOnSecond = true;
                }
            }
            dto.IsRunnerOnFirst = true;

            return(dto);
        }
        public IHalfInningActions FillDoublePlayActions(IHalfInningActions actions)
        {
            HalfInningActionsDto dto = Mapper.Map <HalfInningActionsDto>(actions);

            if (HasBaseRunner(dto) == true)
            {
                dto.TotalOuts += 2;
            }
            else
            {
                dto.TotalOuts++;
            }

            if (dto.TotalOuts >= 3)
            {
                dto.AdvanceToNextHalfInning = true;
            }
            else
            {
                if (dto.IsRunnerOnFirst)
                {
                    dto.IsRunnerOnFirst = false;
                }
                else if (dto.IsRunnerOnSecond)
                {
                    dto.IsRunnerOnSecond = false;
                }
                else if (dto.IsRunnerOnThird)
                {
                    dto.IsRunnerOnThird = false;
                }
            }

            return(dto);
        }
示例#3
0
        public IHalfInningActions FillSacraficeHitActions(IHalfInningActions actions)
        {
            HalfInningActionsDto dto = Mapper.Map <HalfInningActionsDto>(actions);

            dto.TotalOuts++;

            if (dto.TotalOuts >= 3)
            {
                dto.AdvanceToNextHalfInning = true;
            }
            else
            {
                if (dto.IsRunnerOnThird)
                {
                    dto.IsRunnerOnThird = false;
                    dto.TotalRuns++;
                }
                if (dto.IsRunnerOnSecond)
                {
                    dto.IsRunnerOnSecond = false;
                    dto.IsRunnerOnThird  = true;
                }
                if (dto.IsRunnerOnFirst)
                {
                    dto.IsRunnerOnFirst  = false;
                    dto.IsRunnerOnSecond = true;
                }
            }

            return(dto);
        }
        public void BasesEmptyTripleTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto();

            var actions = Service.FillTripleActions(dto);
            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsTrue(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 0);
        }
示例#5
0
        public void BasesEmptyDoublePlayTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto();

            var actions = Service.FillDoublePlayActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsFalse(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalOuts == 1);
        }
示例#6
0
        public void OutTotalTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                TotalOuts = 1
            };

            var actions = Service.FillOutActions(dto);

            Assert.IsTrue(actions.TotalOuts == 2);
        }
示例#7
0
        public void BasesEmptySacraficeHitTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto();

            var actions = Service.FillSacraficeHitActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsFalse(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 0);
            Assert.IsTrue(actions.TotalOuts == 1);
        }
示例#8
0
        public void AdvanceToNextHalfInningTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                TotalOuts = 2
            };

            var actions = Service.FillOutActions(dto);

            Assert.IsTrue(actions.TotalOuts == 3);
            Assert.IsTrue(actions.AdvanceToNextHalfInning);
        }
        public void RunnerOnThirdTripleTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnThird = true
            };

            var actions = Service.FillTripleActions(dto);
            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsTrue(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 1);
        }
示例#10
0
        public IHalfInningActions FillOutActions(IHalfInningActions actions)
        {
            HalfInningActionsDto dto = Mapper.Map <HalfInningActionsDto>(actions);

            dto.TotalOuts++;

            if (dto.TotalOuts >= 3)
            {
                dto.AdvanceToNextHalfInning = true;
            }

            return(dto);
        }
示例#11
0
        public void RunnerOnThirdDoublePlayTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnThird = true
            };

            var actions = Service.FillDoublePlayActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsFalse(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalOuts == 2);
        }
        public void RunnerOnSecondAndThirdWalkTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnSecond = true,
                IsRunnerOnThird  = true
            };

            var actions = Service.FillWalkActions(dto);

            Assert.IsTrue(actions.IsRunnerOnFirst);
            Assert.IsTrue(actions.IsRunnerOnSecond);
            Assert.IsTrue(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 0);
        }
        public void RunnerOnFirstAndSecondHomeRunTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnFirst  = true,
                IsRunnerOnSecond = true
            };

            var actions = Service.FillHomeRunActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsFalse(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 3);
        }
示例#14
0
        public void TheBasesLoadedDoubleTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnFirst  = true,
                IsRunnerOnSecond = true,
                IsRunnerOnThird  = true
            };

            var actions = Service.FillDoubleActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsTrue(actions.IsRunnerOnSecond);
            Assert.IsTrue(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 2);
        }
示例#15
0
        public void RunnerOnFirstAndThirdSacraficeHitTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnFirst = true,
                IsRunnerOnThird = true
            };

            var actions = Service.FillSacraficeHitActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsTrue(actions.IsRunnerOnSecond);
            Assert.IsFalse(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 1);
            Assert.IsTrue(actions.TotalOuts == 1);
        }
示例#16
0
        public void RunnerOnThirdTwoOutsSacraficeHitTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto
            {
                IsRunnerOnThird = true,
                TotalOuts       = 2
            };

            var actions = Service.FillSacraficeHitActions(dto);

            Assert.IsFalse(actions.IsRunnerOnFirst);
            Assert.IsFalse(actions.IsRunnerOnSecond);
            Assert.IsTrue(actions.IsRunnerOnThird);
            Assert.IsTrue(actions.TotalRuns == 0);
            Assert.IsTrue(actions.TotalOuts == 3);
            Assert.IsTrue(actions.AdvanceToNextHalfInning == true);
        }
示例#17
0
        public IHalfInningActions GetHalfInningActions(List <IGameInningTeamBatter> gameInningTeamBatters)
        {
            IHalfInningActions dto = new HalfInningActionsDto();

            foreach (var batter in gameInningTeamBatters.OrderBy(x => x.Sequence))
            {
                switch ((EventType)batter.EventType)
                {
                case EventType.Single:
                    dto = Single.FillSingleActions(dto);
                    break;

                case EventType.Double:
                    dto = Double.FillDoubleActions(dto);
                    break;

                case EventType.Triple:
                    dto = Triple.FillTripleActions(dto);
                    break;

                case EventType.HomeRun:
                    dto = HomeRun.FillHomeRunActions(dto);
                    break;

                case EventType.Out:
                    dto = Out.FillOutActions(dto);
                    break;

                case EventType.DoublePlay:
                    dto = DoublePlay.FillDoublePlayActions(dto);
                    break;

                case EventType.SacraficeHit:
                    dto = SacraficeHit.FillSacraficeHitActions(dto);
                    break;

                case EventType.TwoBaseSingle:
                    dto = TwoBaseSingle.FillTwoBaseSingleActions(dto);
                    break;
                }
            }

            return(dto);
        }
        private bool HasBaseRunner(HalfInningActionsDto dto)
        {
            bool hasBaseRunner = false;

            if (dto.IsRunnerOnFirst)
            {
                hasBaseRunner = true;
            }
            if (dto.IsRunnerOnSecond)
            {
                hasBaseRunner = true;
            }
            if (dto.IsRunnerOnThird)
            {
                hasBaseRunner = true;
            }

            return(hasBaseRunner);
        }
示例#19
0
        public IHalfInningActions FillHomeRunActions(IHalfInningActions actions)
        {
            HalfInningActionsDto dto = Mapper.Map <HalfInningActionsDto>(actions);

            if (dto.IsRunnerOnThird)
            {
                dto.IsRunnerOnThird = false;
                dto.TotalRuns++;
            }
            if (dto.IsRunnerOnSecond)
            {
                dto.IsRunnerOnSecond = false;
                dto.TotalRuns++;
            }
            if (dto.IsRunnerOnFirst)
            {
                dto.IsRunnerOnFirst = false;
                dto.TotalRuns++;
            }
            dto.TotalRuns++;

            return(dto);
        }
示例#20
0
        public void AdvanceToNextHalfInningTest()
        {
            HalfInningActionsDto dto = new HalfInningActionsDto()
            {
                TotalOuts = 2
            };
            var actions = Service.FillDoublePlayActions(dto);

            Assert.IsTrue(actions.AdvanceToNextHalfInning);
            Assert.IsTrue(actions.TotalOuts == 3);

            dto.TotalOuts       = 1;
            dto.IsRunnerOnFirst = true;

            actions = Service.FillDoublePlayActions(dto);
            Assert.IsTrue(actions.AdvanceToNextHalfInning);
            Assert.IsTrue(actions.TotalOuts == 3);

            dto.TotalOuts = 2;
            actions       = Service.FillDoublePlayActions(dto);
            Assert.IsTrue(actions.AdvanceToNextHalfInning);
            Assert.IsTrue(actions.TotalOuts == 4);
        }
示例#21
0
 private bool AreBasesLoaded(HalfInningActionsDto dto)
 {
     return(dto.IsRunnerOnFirst && dto.IsRunnerOnSecond && dto.IsRunnerOnThird);
 }