//returns whether or not second is open after the play, not whether a runner advanced private bool tryAdvanceFromSecondBase(DefensiveAttributes.POSITION _hitToPosition, Game _game) { if (_game.RunnerOnSecond == null) return true; if (_game.RunnerOnThird != null) return false; if (_game.RunnerOnSecond.Speed >= MINIMUM_SPEED_ADVANCE_FROM_SECOND) { int randomResult = randomOneToThousand(); if (randomResult <= _game.RunnerOnSecond.Speed * 4 - (2 * _game.GetDefenderThrowing(_hitToPosition)) + 100) { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _game.RunnerOnSecond.FirstName + " advances from second!"); _game.advanceRunner(Game.BASE.SECOND, 1); } else if (randomResult <= _game.RunnerOnSecond.Speed * 6 - (2 * _game.GetDefenderThrowing(_hitToPosition)) + 100) { if (!tryField(_hitToPosition, _game)) { doNonROEError(ERROR_TYPE.DEEP_THROWING, _game, _hitToPosition); } else { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _game.RunnerOnSecond.FirstName + " is thrown out trying to advance from second!"); _game.RunnerOnSecond = null; _game.IncreaseOuts(); } } else { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _game.RunnerOnSecond.FirstName + " stays at second!"); return true; } } return false; }
private bool tryThrow(DefensiveAttributes.POSITION _pos, Game _game) { int randomResult = randomOneToThousand(); if (randomResult > _game.GetDefenderThrowing(_pos) * 9 + 100) { return false; } return true; }
private void doLineDrive(PositionPlayer _batter, Pitcher _pitcher, DefensiveAttributes.POSITION _hitToPosition, Game _game) { if (isAHit(BABIP_ON_LINE_DRIVES, _game.GetDefenderRange(_hitToPosition))) { switch (determineHitStrenght(_batter, BALL_HEIGHT.LINE_DRIVE, _game.GetDefenderRange(_hitToPosition), _game.GetDefenderThrowing(_hitToPosition))) { case HIT_TYPE.SINGLE: doSingle(_batter, _pitcher, _hitToPosition, _game); break; case HIT_TYPE.DOUBLE: doDouble(_batter, _pitcher, _hitToPosition, _game); break; case HIT_TYPE.TRIPLE: doTriple(_batter, _pitcher, _hitToPosition, _game); break; default: doSingle(_batter, _pitcher, _hitToPosition, _game); break; } } else { if (!tryField(_hitToPosition, _game)) { doROEError(ERROR_TYPE.DEEP_FIELDING, _game, _batter, _hitToPosition); } else { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " lines out to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + "."); _game.IncreaseOuts(); if (_game.Outs != 0 && (_hitToPosition == DefensiveAttributes.POSITION.CENTER_FIELDER || _hitToPosition == DefensiveAttributes.POSITION.LEFT_FIELDER || _hitToPosition == DefensiveAttributes.POSITION.RIGHT_FIELDER)) { tryAdvanceFromThirdBase(_hitToPosition, _game); if (_game.Outs != 0) { tryAdvanceFromSecondBase(_hitToPosition, _game); } } } } //Temp counter.linedrives++; }