private void doTriple(PositionPlayer _batter, Pitcher _pitcher, DefensiveAttributes.POSITION _hitToPosition, Game _game) { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " triples to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + "!"); _game.advanceRunner(Game.BASE.THIRD, 3); _game.advanceRunner(Game.BASE.SECOND, 3); _game.advanceRunner(Game.BASE.FIRST, 3); _game.RunnerOnThird = _batter; //TODO: hit++ (batter) _game.GetAHit(); //TODO: hit++ (pitcher) //TODO: Triple++ (batter) if (!tryField(_hitToPosition, _game)) { doNonROEError(ERROR_TYPE.DEEP_BOBBLE, _game, _hitToPosition); } //Temp counter.triples++; }
private void doDeepError(Game _game) { _game.advanceRunner(Game.BASE.THIRD, 2); _game.advanceRunner(Game.BASE.SECOND, 2); _game.advanceRunner(Game.BASE.FIRST, 2); }
private void doSingle(PositionPlayer _batter, Pitcher _pitcher, DefensiveAttributes.POSITION _hitToPosition, Game _game) { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " singles to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + "!"); _game.advanceRunner(Game.BASE.THIRD, 1); _game.advanceRunner(Game.BASE.SECOND, 1); //TODO: advance extra base? _game.advanceRunner(Game.BASE.FIRST, 1); //TODO: advance extra base? _game.RunnerOnFirst = _batter; //TODO: hit++ (batter) _game.GetAHit(); //TODO: hit++ (pitcher) tryAdvanceFromThirdBase(_hitToPosition, _game); tryAdvanceFromSecondBase(_hitToPosition, _game); //Temp counter.singles++; }
private void doShortError(Game _game) { _game.advanceRunner(Game.BASE.THIRD, 1); _game.advanceRunner(Game.BASE.SECOND, 1); _game.advanceRunner(Game.BASE.FIRST, 1); }
private void doHomerun(PositionPlayer _batter, Pitcher _pitcher, DefensiveAttributes.POSITION _hitToPosition, Game _game) { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " homers to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + "!"); _game.advanceRunner(Game.BASE.THIRD, 3); _game.advanceRunner(Game.BASE.SECOND, 3); _game.advanceRunner(Game.BASE.FIRST, 3); _game.ScoreRun(); //TODO: hit++ (batter) _game.GetAHit(); //TODO: hit++ (pitcher) //TODO: HR++ (batter) //TODO: HR++ (game) //TODO: HR++ (pitcher) //Temp for analysis counter.homeRuns++; }
private void doGroundBall(PositionPlayer _batter, Pitcher _pitcher, DefensiveAttributes.POSITION _hitToPosition, Game _game) { if (isAHit(BABIP_ON_GROUND_BALLS, _game.GetDefenderRange(_hitToPosition))) { doSingle(_batter, _pitcher, _hitToPosition, _game); } else { if (!tryField(_hitToPosition, _game)) { doROEError(ERROR_TYPE.SHORT_FIELDING, _game, _batter, _hitToPosition); } else { if (!tryThrow(_hitToPosition, _game)) { doROEError(ERROR_TYPE.SHORT_THROWING, _game, _batter, _hitToPosition); } else { //must revise this part of the logic if (_game.Outs < 2) { if (_game.RunnerOnFirst != null) { if (!(_game.RunnerOnFirst.Speed * 4 <= randomOneToThousand())) { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " grounds to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + " for a double play!"); _game.RunnerOnFirst = null; _game.IncreaseOuts(); if (_game.Outs == 1) { _game.advanceRunner(Game.BASE.THIRD, 1); _game.advanceRunner(Game.BASE.SECOND, 1); } _game.RunnerOnSecond = null; } else { _game.advanceRunner(Game.BASE.THIRD, 1); _game.advanceRunner(Game.BASE.SECOND, 1); _game.RunnerOnFirst = _batter; _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " grounds to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + " for a fielder's choice!"); } } else { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " grounds out to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + "."); _game.advanceRunner(Game.BASE.THIRD, 1); _game.advanceRunner(Game.BASE.SECOND, 1); } } else { _game.GetLog().addEvent(_game.CurrentHalfInning, _game.HomeTeamAtBat, _batter.FirstName + " grounds out to " + POSITION_TEXT[Convert.ToInt32(_hitToPosition)] + "."); } _game.IncreaseOuts(); } } } //Temp counter.groundballs++; }
//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; }