예제 #1
0
        /**
         * Manages the end of the current hole
         * saveForStatistics : true to save the stats of the current hole, false to not save them
         */
        public void holeFinished(bool saveForStatistics)
        {
            ScoreHole sh = StatistiquesGolf.saveForStats(this, itHole.Current, saveForStatistics);

            ScoreOfThisPartie.add(sh);
            Shots.Clear();
        }
예제 #2
0
 /**
  * Manages the end of this game
  * saveForStatistics : true to save the stats of this game, false to not save them
  */
 public async Task gameFinished(bool saveForStatistics)
 {
     if (saveForStatistics)
     {
         ScoreOfThisPartie.DateFin = DateTime.Now;
         await StatistiquesGolf.saveGameForStats(ScoreOfThisPartie);
     }
 }
예제 #3
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);
        }
예제 #4
0
 /**
  * Initialized the list of average distances with the ones of the clubs in parameter
  * clubs : the list of clubs to compute the average distance
  */
 public async static void calculAverageAsync(List <Club> clubs)
 {
     listAverage = await StatistiquesGolf.getAverageDistanceForClubsAsync(c => clubs.Contains(c), clubs);
 }
예제 #5
0
        /**
         * Computes the number of shots before the ball gets onto the green
         * shots : the list of the shots of a single hole
         * return : the number of shots before the ball gets onto the green
         */
        private static int numberShotsBeforeGreen(List <Shot> shots)
        {
            int puttCount = StatistiquesGolf.nbCoupPutt(shots);

            return(shots.Count - puttCount);
        }
예제 #6
0
        /**
         * Gets the games that wasn't finished yet on a specific golf course
         * golfCourse : the specific golf course
         */
        public static async Task <List <ScorePartie> > getNotFinishedGames(GolfCourse golfCourse)
        {
            List <ScorePartie> allNeededScoreParties = (await StatistiquesGolf.getScoreParties()).Where(sp => sp.scoreHoles[0].Hole.IdGolfC.Equals(golfCourse.Name) && sp.scoreHoles.Count != 9 && sp.scoreHoles.Count != 18).ToList();

            return(allNeededScoreParties);
        }