public Shot(Club club, ShotCategory catergory, DateTime date) { this.Club = club; this.InitPlace = null; this.Target = null; this.RealShot = null; this.Date = date; this.ShotType = catergory; this.PenalityCount = 0; }
/** * Classify the shot depending on the variation between the targeted shot and the real shot */ private ShotCategory determineShotCategory() { ShotCategory sc = ShotCategory.ChipShot; //shots added in HoleFinishedPage => not real shots => you don't want to count it in stats if (Target == null || RealShot == null || InitPlace == null) { return(sc); } double index = StatistiquesGolf.getPlayerIndex(); double psmd = this.getPerfectShotMaxDist(index); double gsmd = this.getGoodShotMaxDist(index); double ulsmdg = 10 + this.Club.DistanceMoyenne * 10 / 100; //unexpected good shot min dist gap double ssd = this.Club.DistanceMoyenne * 2 / 3; //short shot dist double rstd = this.RealShotTargetDist(); double td = this.TargetDist(); double rsd = this.RealShotDist(); double shotAngle = this.GetShotAngle(rstd, td, rsd, true); if (td <= 30.0 && !this.isPutt())//if the player targeted a place with a short distance { sc = ShotCategory.ChipShot; } else if (rstd <= psmd) //if in the perfect shot circle { sc = ShotCategory.PerfectShot; } else if (rstd <= gsmd) //if in the good shot circle { sc = ShotCategory.GoodShot; } else if (rsd - td > ulsmdg && shotAngle < 7) //if player shot much further than he expected and with a small dispertion { sc = ShotCategory.UnexpectedLongShot; } else //bad shot { if (rsd < ssd)//if player failed his shot and his ball traveled a short distance { sc = ShotCategory.FailedShot; } else if (shotAngle > 10) //if player didn't shot straigth { sc = ShotCategory.NotStraightShot; } else { sc = ShotCategory.TolerableShot; } } System.Diagnostics.Debug.WriteLine("\n Category : " + sc + "\n Index : " + index + "\n ugsmdg : " + ulsmdg + "\n DistMoyClub : " + Club.DistanceMoyenne + "\n rstd : " + rstd + "\n td : " + td + "\n rsd : " + rsd + "\n shotAngle : " + shotAngle + "\n psmd : " + psmd + "\n gsmd : " + gsmd); return(sc); }