예제 #1
0
        public void addHole(int Par, int Hcp)
        {
            hole ctHole = new hole();

            ctHole.par = Par;
            ctHole.hcp = Hcp;
            ctHole.nr  = holes.Count() + 1;
            holes.Add(ctHole);
        }
예제 #2
0
        public hole getHolebyNr(int nr)
        {
            hole ret = holes[nr - 1];

            if (ret.nr != nr)
            {
                throw new Exception(String.Format("could not find hole with nr {0}, holes probably wrong sorted", nr));
            }
            return(ret);
        }
예제 #3
0
 public void calculateStblNewHcps(Hcps oldHcps)
 {
     //ToCheck9
     stblPointsForNewHcp.points.Clear();
     foreach (flight ctF in flights.Values)
     {
         foreach (team ctT in ctF.teams.Values)
         {
             foreach (playingBall b in ctT.playingBalls.Values)
             {
                 string playerString = b.GetPlayersString();
                 foreach (Player ctP in b.players.Values)
                 {
                     Double oldHcp = ctP.initialHcp;
                     if (oldHcps != null && oldHcps.hpcs.ContainsKey(ctP.name))
                     {
                         oldHcp = oldHcps.hpcs[ctP.name];
                     }
                     int ctPlayingHcp = (int)Math.Round(courseDefinition.getPlayingHcp(oldHcp), 0);
                     stblPointsForNewHcp.points.Add(ctP.name, new List <int>()
                     {
                         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                     });
                     if (scores.holeResults.ContainsKey(playerString))
                     {
                         for (int holeNr = 1; holeNr <= 18; holeNr++)
                         {
                             hole ctHoleDefinition = courseDefinition.getHolebyNr(holeNr);
                             int  Stbl             = calcStblPointforHole(scores.getScore(playerString, holeNr), ctHoleDefinition.par, ctHoleDefinition.hcp, ctPlayingHcp);
                             if (b.nbOfPlayerForBall == 1)
                             {
                                 stblPointsForNewHcp.points[ctP.name][holeNr - 1] = Stbl;
                             }
                         }
                         if (stblPointsForNewHcp.isValidForStblDay() && b.nbOfPlayerForBall == 1)
                         {
                             NewHcps.hpcs.Add(ctP.name, NewHcps.calcNewHcpASG(oldHcp, stblPointsForNewHcp.getStblPointsForLastHoles(ctP.name)));
                         }
                         else
                         {
                             NewHcps.hpcs.Add(ctP.name, oldHcp);
                         }
                     }
                     else
                     {
                         throw new Exception(String.Format("Could not find holeResults for Player {0}", playerString));
                     }
                 }
             }
         }
     }
 }
예제 #4
0
        public void calculateStbl()
        {
            statHoles.Clear();
            stblPoints.points.Clear();
            foreach (flight ctF in flights.Values)
            {
                foreach (team ctT in ctF.teams.Values)
                {
                    foreach (playingBall b in ctT.playingBalls.Values)
                    {
                        string playerString = b.GetPlayersString();
                        int    ctPlayingHcp = (int)Math.Round(b.GetPlayingHcp(), 0);
                        //stblPoints.points.Add(playerString, new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
                        foreach (Player pbp in b.players.Values) //duplicate for the players of a foursome
                        {
                            if (!stblPoints.points.ContainsKey(pbp.name))
                            {
                                stblPoints.points.Add(pbp.name, new List <int>()
                                {
                                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                                });
                            }
                            if (pbp.name != playerString) //duplicate score for player
                            {
                                if (scores.holeResults.ContainsKey(playerString) && !scores.holeResults.ContainsKey(pbp.name))
                                {
                                    scores.holeResults.Add(pbp.name, scores.holeResults[playerString].CloneJson());
                                }
                            }
                        }
                        if (scores.holeResults.ContainsKey(playerString))
                        {
                            for (int holeNr = 1; holeNr <= 18; holeNr++)
                            {
                                hole ctHoleDefinition = courseDefinition.getHolebyNr(holeNr);
                                int  Stbl             = calcStblPointforHole(scores.getScore(playerString, holeNr), ctHoleDefinition.par, ctHoleDefinition.hcp, ctPlayingHcp);
                                int  StblBrut         = calcStblPointforHole(scores.getScore(playerString, holeNr), ctHoleDefinition.par, 1, 0);
                                int  StblBrut36       = calcStblPointforHole(scores.getScore(playerString, holeNr), ctHoleDefinition.par, 1, 36);
                                //stblPoints.points[playerString][holeNr - 1] = Stbl;
                                foreach (Player pbp in b.players.Values) //duplicate for the players of a foursome
                                {
                                    stblPoints.points[pbp.name][holeNr - 1] = Stbl;

                                    HoleForStat statHole = new HoleForStat
                                    {
                                        playerName = pbp.name,
                                        cpsRecu    = GetAdjustement(ctHoleDefinition.hcp, ctPlayingHcp),
                                        dayNr      = nr,
                                        defHole    = ctHoleDefinition,
                                        Parcours   = courseDefinition.name,
                                        ptsNet     = Stbl,
                                        ptsBrut    = StblBrut,
                                        ptsBrut36  = StblBrut36
                                    };
                                    statHoles.Add(statHole);
                                }
                            }
                        }
                        else
                        {
                            throw new Exception(String.Format("Could not find holeResults for Player {0}", playerString));
                        }
                    }
                }
            }
        }