/// <summary> /// /// </summary> /// <param name="thrower">Player</param> /// <param name="result">result</param> public void IncompletePass(Player thrower, PassPlayResult result) { this.attempts++; this.completionPct = CalculatePercentage(this.attempts, this.completions); switch (result) { case PassPlayResult.Sack: this.timesSacked++; break; case PassPlayResult.Incomplete: break; case PassPlayResult.Interception: this.interceptions++; break; } }
/// <summary> /// /// </summary> /// <returns></returns> public override int Execute() { int pass = Dice.Roll("d100"); bool isTd = false; int qbRating = thrower.PlayerSkills.Pass + this.defense.TeamDefense.PassRushRating; //check for auto td or interception if (pass == 1) { //auto td playLength = cc.GetAutoTDDistance(); if (playLength == 0) { Console.WriteLine(); } playLength = cc.MoveBallPass(this, false, false, false); if (playLength == 0) { Console.WriteLine(); } isTd = true; gamePassStats.CompletePass(thrower, principalBallcarrier, playLength, true); gameReceiverStats.AddRun(playLength, isTd, false); ((PassPlayStatSheet)this.thrower.Stats[StatTypes.Pass]).CompletePass(thrower, principalBallcarrier, playLength, true); ((CarryStatSheet)this.principalBallcarrier.Stats[StatTypes.Receive]).AddRun(playLength, isTd, false); } else if (pass == 100) { //auto interception //go to interception module OnInterceptionOccurred(cc, thrower); } else if (pass <= qbRating)//thrower pass rating here { playLength = Dice.Roll(principalBallcarrier.PlayerSkills.Receive); if (playLength == 0) { Console.WriteLine(); } playLength = cc.MoveBallPass(this, false, false, false); if (playLength == 0) { Console.WriteLine(); } gamePassStats.CompletePass(thrower, principalBallcarrier, playLength, false); gameReceiverStats.AddRun(playLength, false, false); ((PassPlayStatSheet)this.thrower.Stats[StatTypes.Pass]).CompletePass(thrower, principalBallcarrier, playLength, false); ((CarryStatSheet)this.principalBallcarrier.Stats[StatTypes.Receive]).AddRun(playLength, false, false); } else { //incomplete pass PassPlayResult res = this.defense.TeamDefense.PassDefense(Dice.Roll("d12")); gamePassStats.IncompletePass(thrower, res); ((PassPlayStatSheet)this.thrower.Stats[StatTypes.Pass]).IncompletePass(thrower, res); switch (res) { case PassPlayResult.Sack: string rollString = String.Format("d{0}", defense.TeamDefense.MaxSackLoss); bool isFumble = CheckFumble(thrower); playLength = -(Dice.Roll(rollString)); playLength = cc.MoveBallRun(this, isFumble); gameRunStats.AddRun(playLength, false, isFumble); ((CarryStatSheet)this.thrower.Stats[StatTypes.Run]).AddRun(playLength, false, isFumble); break; case PassPlayResult.Incomplete: playLength = 0; cc.MoveBallPass(this, false, false, false); break; case PassPlayResult.Interception: OnInterceptionOccurred(cc, thrower); break; } } return(playLength); }