Esempio n. 1
0
 // The Resolve* methods resolve the probabilistic outcome of the current game state.
 // They return true if the Home team should continue the play and attempt a layup, false otherwise.
 private bool Resolve(JumpShot shot, Scoreboard scoreboard) =>
 Resolve(shot.ToString(), _defense / 8)
 .Do(0.341f, () => scoreboard.AddBasket("Shot is good"))
 .Or(0.682f, () => ResolveShotOffTarget(scoreboard))
 .Or(0.782f, () => _ballContest.Resolve(scoreboard))
 .Or(0.843f, () => ResolveFreeThrows(scoreboard, "Shooter is fouled.  Two shots."))
 .Or(() => scoreboard.Turnover($"Charging foul.  {scoreboard.Home} loses ball."));
 // The Resolve* methods resolve the probabilistic outcome of the current game state.
 // They return true if the Visiting team should continue the play and attempt a layup, false otherwise.
 private bool Resolve(JumpShot shot, Scoreboard scoreboard) =>
 Resolve(shot.ToString(), _defense / 8)
 .Do(0.35f, () => scoreboard.AddBasket("Shot is good."))
 .Or(0.75f, () => ResolveBadShot(scoreboard, "Shot is off the rim.", _defense * 6))
 .Or(0.9f, () => ResolveFreeThrows(scoreboard, "Player fouled.  Two shots."))
 .Or(() => _io.WriteLine($"Offensive foul.  {scoreboard.Home}'s ball."));