/// <summary> /// /// </summary> /// <param name="play">KickoffReturnPlay</param> /// <param name="isFumble">bool</param> /// <returns>int</returns> public int MoveBallKickoffReturn(KickoffReturnPlay play, bool isFumble) { MoveChainsVariables var = MoveChains(play, isFumble); play.PlayLength = var.playLength; if (!var.isTd) { if (var.isSafety) { OnSafetyOccurred(play); if (isFumble) { OnFumbleOccurred(play.PrincipalBallcarrier, var.playLength); } } else { if (isFumble) { OnFumbleOccurred(play.PrincipalBallcarrier, var.playLength); } else { SetFirstDown(); this.game.GameAnnouncer.ReportGameEvent(play.PlayReport); } } } else { OnTouchdownScored(play); } return(var.playLength); }
/// <summary> /// /// </summary> /// <param name="play">Play</param> /// <param name="isFumble">bool</param> /// <returns>MoveChainsVariables</returns> private MoveChainsVariables MoveChains(Play play, bool isFumble) { MoveChainsVariables var = new MoveChainsVariables(); var.playLength = play.PlayLength; var.isTd = false; var.isFumble = isFumble; var.isSafety = false; if (currentDirection == Direction.Left) { if ((currentIndex - var.playLength) <= 0) { //td here! var.playLength = (currentIndex + 1); currentIndex = -1; var.isTd = true; } else if ((currentIndex - var.playLength) > 99) { //safety! var.isSafety = true; var.playLength = 99 - currentIndex; currentIndex = -1; } else { currentIndex -= var.playLength; } } else if (currentDirection == Direction.Right) { if ((currentIndex + var.playLength) > 99) { var.playLength = (100 - currentIndex) - 1; currentIndex = -1; var.isTd = true; } else if ((currentIndex + var.playLength) <= 0) { //safety! var.isSafety = true; var.playLength = currentIndex + 1; currentIndex = -1; } else { currentIndex += var.playLength; } } return(var); }
/// <summary> /// /// </summary> /// <param name="play">Play</param> /// <param name="isFumble">bool</param> /// <returns>int</returns> public int MoveBallRun(Play play, bool isFumble) { MoveChainsVariables var = MoveChains(play, isFumble); play.PlayLength = var.playLength; if (!var.isTd) { Player tempBallcarrier = play.PrincipalBallcarrier; if (var.isSafety) { OnSafetyOccurred(play); if (isFumble) { OnFumbleOccurred(tempBallcarrier, var.playLength); } } else { if (isFumble) { OnFumbleOccurred(tempBallcarrier, var.playLength); } else { if (CheckDown() > Down.Fourth) { TurnoverOnDowns(); } ReportPlay(play, var.isTd, var.isFumble); } } } else { OnTouchdownScored(play); } return(var.playLength); }
/// <summary> /// Return ball in case of fumble or interception return. /// </summary> /// <param name="defender">Player</param> /// <param name="yards">int</param> /// <returns>int</returns> public int MoveBallDefensiveReturn(Play play) { MoveChainsVariables var = MoveChains(play, Play.CheckFumble(play.PrincipalBallcarrier)); play.PlayLength = var.playLength; if (!var.isTd) { if (var.isFumble) { OnFumbleOccurred(play.PrincipalBallcarrier, var.playLength); } else { SetFirstDown(); this.game.GameAnnouncer.ReportGameEvent(play.PlayReport.ToString()); } } else { OnTouchdownScored(play); } return(var.playLength); }
/// <summary> /// /// </summary> /// <param name="play">Play</param> /// <param name="isSack">bool</param> /// <param name="isInterception">bool</param> /// <param name="isFumble">bool</param> /// <returns>int</returns> public int MoveBallPass(PassPlay play, bool isSack, bool isInterception, bool isFumble) { MoveChainsVariables var = MoveChains(play, isFumble); play.PlayLength = var.playLength; if (!var.isTd) { if (var.isSafety) { OnSafetyOccurred(play); if (isFumble) { OnFumbleOccurred(play.Thrower, var.playLength); } } else { if (isFumble) { OnFumbleOccurred(play.Thrower, var.playLength); } else { if (CheckDown() > Down.Fourth) { TurnoverOnDowns(); } ReportPassPlay(play, var.isTd, isSack, isInterception, var.isFumble); } } } else { OnTouchdownScored(play); } return(var.playLength); }