/// <summary> /// Initializes a new instance of the <see cref="T:StatusQuoBaseball.Gameplay.InningActionEventArgs"/> class. /// </summary> /// <param name="inning">Inning</param> /// <param name="toggleInning">If set to <c>true</c> toggle inning.</param> /// <param name="isInningOver">bool</param> /// <param name="result">GamePlayResult</param> public InningActionEventArgs(Inning inning, bool toggleInning, bool isInningOver, GamePlayResult result) { this.inning = inning; this.toggleInning = toggleInning; this.isInningOver = isInningOver; this.result = result; }
protected void LeftButton_Click(object sender, MouseEventArgs e) { Form1 form = Form1.ActiveForm as Form1; GamePlayResult gameResult = new GamePlayResult(form); if (e.Button == MouseButtons.Left) { MyButton button = (MyButton)sender; if (button.ButtonContainner == "free") { button.Enabled = false; button.BackgroundImage = SetPicture.SetBackgroundPicture(button.ButtonContainner); button.FlatStyle = FlatStyle.Popup; runCuscade.CreateCascadeCell(button.CoordinateY, button.CoordinateX); gameResult.YouWin(); } else if (button.ButtonContainner == "bomb") { gameResult.GameOver(button); } else { button.Enabled = false; button.Checked = true; button.BackgroundImage = SetPicture.SetBackgroundPicture(button.ButtonContainner); button.FlatStyle = FlatStyle.Popup; gameResult.YouWin(); } } }
/// <summary> /// On the game play result. /// </summary> /// <param name="res">GamePlayResult</param> private void OnGamePlayResult(GamePlayResult res) { if (gamePlayResultHandled != null) { gamePlayResultHandled(new GamePlayResultEventArgs(res)); } }
/// <summary> /// Execute the at bat. /// </summary> public void Execute() { int roll = Dice.Roll2d10(); GamePlayResult res = null; try { if (roll <= this.pitcher.PitchingStats.CurrentControl) { PitchResults theResult = this.pitcher.PitchingStats.PitchResults[roll - 1]; res = GamePlayResultFactory.GetResult(this, theResult); } else { BattingResults theResult = this.batter.BattingStats.BattingResults[roll - 1]; res = GamePlayResultFactory.GetResult(this, theResult); } this.inning.Game.Announcer.AnnounceToConsole(String.Format($"And {res.ControllingPlayer} is in control of the at bat.")); this.pitcher.PitchingStatistics.BattersFaced++; this.result = res; this.batter.IsBatting = false; OnGamePlayResult(res); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="T:StatusQuoBaseball.Gameplay.RunScoredEventArgs"/> class. /// </summary> /// <param name="team">Team</param> /// <param name="runner">Player</param> /// <param name="batter">Player</param> /// <param name="pitcher">Player</param> /// <param name="result">GamePlayResult</param> public RunScoredEventArgs(Team team, Player runner, Player batter, Player pitcher, GamePlayResult result) { this.team = team; this.runner = runner; this.batter = batter; this.pitcher = pitcher; this.result = result; }
/// <summary> /// Logs the stat. /// </summary> /// <param name="result">GamePlayResult</param> /// <param name="toIncrement">int</param> public override void LogStat(GamePlayResult result, int toIncrement = 0) { if (result is Error) { this.errors++; } else if (result is Out) { this.putouts++; } else if (result is StealAttempt) { this.stealAttemptsAgainst++; if (((StealAttempt)result).WasSuccessful) { this.stolenBases++; } } }
/// <summary> /// Initializes a new instance of the <see cref="T:StatusQuoBaseball.Gameplay.GamePlayResultEventArgs"/> class. /// </summary> /// <param name="result">GamePlayResult</param> public GamePlayResultEventArgs(GamePlayResult result) { this.result = result; }
/// <summary> /// Will throw System.NotImplementedException. Use LogGameStats instead. /// </summary> /// <param name="result">Result.</param> /// <param name="toIncrement">To increment.</param> public override void LogStat(GamePlayResult result, int toIncrement) { throw new System.NotImplementedException(); }
/// <summary> /// Logs the stat. /// </summary> /// <param name="result">GamePlayResult</param> /// <param name="toIncrement">If set to <c>1</c> is run.</param> public override void LogStat(GamePlayResult result, int toIncrement = 0) { if (toIncrement == 1) { this.runs++; } else if (toIncrement == 2)//rbi { this.runsBattedIn++; if (result is SacrificeFly) { this.sacrificeFlyouts++; result.Pitcher.PitchingStatistics.SacrificeFlyouts++; } } else { this.plateAppearances++; this.atBats++; if (result is HitByPitch) { this.hitByPitches++; this.atBats--; } else if (result is Walk) { this.walks++; this.atBats--; } else if (result is Strikeout) { this.strikeouts++; } else if (result is GroundOut) { this.groundOuts++; } else if (result is Flyout) { this.flyOuts++; } else if (result is PopFlyOut) { this.flyOuts++; } else if (result is DeepFlyOut) { this.flyOuts++; } else if (result is StatusQuoBaseball.Gameplay.Single) { this.singles++; } else if (result is StatusQuoBaseball.Gameplay.Double) { this.doubles++; } else if (result is Triple) { this.triples++; } else if (result is HomeRun) { this.homeruns++; } else if (result is StealAttempt) { this.stealAttempts++; this.plateAppearances--; this.atBats--; if (((StealAttempt)result).WasSuccessful) { this.stolenBases++; } } } }
/// <summary> /// Logs the stat. /// </summary> /// <param name="result">Result.</param> /// <param name="toIncrement">Runs allowed.</param> public override void LogStat(GamePlayResult result, int toIncrement = 0) { if (toIncrement == 1)//temp way to distinguish run scored from other event { this.runsAllowed++; } else { this.atBats++; this.battersFaced++; if (result is Out) { Out theOut = (Out)result; if (!theOut.IsError) { if (result is Strikeout) { this.strikeouts++; } else if (result is GroundOut) { this.groundOuts++; } else if (result is Flyout) { this.flyOuts++; } else if (result is PopFlyOut) { this.flyOuts++; } else if (result is DeepFlyOut) { this.flyOuts++; } //This is taken care of in BattingStatisticsContainer.LogStat //Because it is only a sacrifice fly if a run is driven in. //else if (result is SacrificeFly) //{ // this.sacrificeFlyouts++; //} this.totalOuts++; } } else { if (result is Balk) { this.balks++; this.atBats--; this.battersFaced--; } else if (result is HitByPitch) { this.hitByPitches++; this.atBats--; } else if (result is Walk) { this.walks++; this.atBats--; } else if (result is StatusQuoBaseball.Gameplay.Single) { this.singles++; } else if (result is StatusQuoBaseball.Gameplay.Double) { this.doubles++; } else if (result is Triple) { this.triples++; } else if (result is HomeRun) { this.homeruns++; } else if (result is StealAttempt) { this.totalOuts++; this.atBats--; } } } }