Exemple #1
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));
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        public void initialiseScoresForDisplay(List <hole> holes, dailyScores scores)
        {
            playerScoreForDisplay ps;

            ps            = new playerScoreForDisplay();
            ps.playerName = "par";
            foreach (hole ctHole in holes)
            {
                ps.GetType().GetProperty(String.Format("_{0}", ctHole.nr)).SetValue(ps, ctHole.par.ToString());
            }
            playerScoresForDisplay.Add(ps);

            ps            = new playerScoreForDisplay();
            ps.playerName = "hcp";
            foreach (hole ctHole in holes)
            {
                ps.GetType().GetProperty(String.Format("_{0}", ctHole.nr)).SetValue(ps, ctHole.hcp.ToString());
            }
            playerScoresForDisplay.Add(ps);

            foreach (String ctPlayer in scores.holeResults.Keys)
            {
                ps            = new playerScoreForDisplay();
                ps.playerName = ctPlayer;
                foreach (hole ctHole in holes)
                {
                    ps.GetType().GetProperty(String.Format("_{0}", ctHole.nr)).SetValue(ps, scores.getScore(ctPlayer, ctHole.nr).ToString().Replace("0", "X"));
                }
                playerScoresForDisplay.Add(ps);
            }
        }