Ejemplo n.º 1
0
        public bool SimulateAtBat(InMatchPositionPlayer _currentBatter, InMatchPitcher _currentPitcher, InMatchTeam _team, Game _game)
        {
            DefensiveAttributes.POSITION hitToPosition;

            switch (getBallHeight(_batter, _pitcher))
            {
                case BALL_HEIGHT.FLY_BALL:
                    hitToPosition = getPositionFlyBallHitTo(_batter);
                    if (tryHomeRun(_batter.Power))
                    {
                        doHomerun(_batter, _pitcher, hitToPosition, _game);
                    }
                    doFlyBall(_batter, _pitcher, hitToPosition, _game);
                    break;

                case BALL_HEIGHT.LINE_DRIVE:
                    hitToPosition = getPositionLineDriveHitTo(_batter);
                    doLineDrive(_batter, _pitcher, hitToPosition, _game);
                    break;

                case BALL_HEIGHT.GROUND_BALL:
                    hitToPosition = getPositionGroundBallHitTo(_batter);
                    doGroundBall(_batter, _pitcher, hitToPosition, _game);
                    break;

            }
            return true;
        }
Ejemplo n.º 2
0
        public Game(InMatchTeam _homeTeam, InMatchTeam _awayTeam)
        {
            atBatSimulator = new AtBatSimulator();
            plateAppearanceSimulator = new PlateAppearanceSimulator();
            baseRunningBatSimulator = new BaseRunningSimulator();
            defensivePlaySimulator = new DefensivePlaySimulator();
            baseStealingSimulator = new BaseStealingSimulator();

            home = _homeTeam;
            away = _awayTeam;
            fieldState = new FieldState();
            gameLog = new GameLog();
            gameLog.startInning(currentInning, homeTeamAtBat);
        }
Ejemplo n.º 3
0
        public bool SimulateBaseStealing(InMatchPositionPlayer _batter, InMatchPitcher _pitcher, InMatchTeam _defense, FieldState _fieldState)
        {
            if (TryPickRunnerOff(_fieldState))
            {
                ApplyPickOff(_fieldState);
                return true;
            }

            if (TryBalk(_fieldState))
            {
                ApplyBalk(_fieldState);
                return true;
            }

            // TODO: passed ball/wild pitches

            int catcherThrowingArm = _defense.GetDefenderThrowing(DefensiveAttributes.POSITION.CATCHER);

            if (TryAttemptSecondBaseSteal(_fieldState, catcherThrowingArm))
            {
                if (TryStealSecondBase(_fieldState, catcherThrowingArm))
                {
                    ApplySuccessfulSecondBaseSteal(_fieldState);
                }
                else
                {
                    ApplyFaildSecondBaseSteal(_fieldState);
                }

                return true;
            }

            if (TryAttemptThirdBaseSteal(_fieldState, catcherThrowingArm))
            {
                if (TryStealThirdBase(_fieldState, catcherThrowingArm))
                {
                    ApplySuccessfulThirdBaseSteal(_fieldState);
                }
                else
                {
                    ApplyFaildThirdBaseSteal(_fieldState);
                }

                return true;
            }

            return false;
        }