Exemplo n.º 1
0
        /// <summary>
        /// Copies the IsStillInCompetition, Abandoned, Forfait and Excluded values from all fencers in given poule round
        /// to the internal ranking.
        /// </summary>
        /// <param name="pouleRound"></param>
        private void registerEliminationOnRankList(FRCPouleRound pouleRound)
        {
            FRCFencer fencer;

            pouleRound.resetFencerIndex();

            for (int i = 0; i < pouleRound.amountOfFencers(); i++)
            {
                fencer = pouleRound.getNextFencer();
                for (int j = 0; j < rankListAllPouleRounds.Count; j++)
                {
                    if (fencer.ID == rankListAllPouleRounds[j].ID)
                    {
                        if (rankListAllPouleRounds[j].IsStillInTheCompetition)
                        {
                            rankListAllPouleRounds[j].IsStillInTheCompetition = fencer.IsStillInTheCompetition;
                        }

                        //These abandoned, excluded, forfait assignments are probably unnecessary, but they are not wrong and it works.
                        if (!rankListAllPouleRounds[j].Abandoned)
                        {
                            rankListAllPouleRounds[j].Abandoned = fencer.Abandoned;
                        }
                        if (!rankListAllPouleRounds[j].Excluded)
                        {
                            rankListAllPouleRounds[j].Excluded = fencer.Excluded;
                        }
                        if (!rankListAllPouleRounds[j].Forfait)
                        {
                            rankListAllPouleRounds[j].Forfait = fencer.Forfait;
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks which format is used for tableau ranking.
        /// </summary>
        /// <param name="lastPouleRound">The last poule round.</param>
        private void checkTableauRankFormat(FRCPouleRound lastPouleRound)
        {
            lastPouleRound.sortFencerPouleRanking();
            interpreter.Tableau.sortFencerInitialRanking();
            sortRankListAllPouleRounds();
            FRCFencer pouleFencer, tableauFencer;

            //Compare ranking from last poule round with initial ranking for the tableau.
            for (int i = 0; i < lastPouleRound.amountOfFencers(); i++)
            {
                pouleFencer = lastPouleRound.getNextFencer();
                //Skips all eliminated, excluded, abandoned and scratched fencers.
                if (!pouleFencer.IsStillInTheCompetition)
                {
                    continue;
                }

                tableauFencer = interpreter.Tableau.getNextFencer();
                if (tableauFencer.ID != pouleFencer.ID)
                {
                    lastPouleRound.resetFencerIndex();
                    interpreter.Tableau.resetFencerIndex();
                    qualifyLastRankAll = true;
                    return;
                }
            }

            int  lastPhaseFinalRanking = -1;
            bool different             = false;

            //Compare ranking from last poule round with internal summing ranking of all poule rounds.
            for (int i = 0; i < rankListAllPouleRounds.Count; i++)
            {
                pouleFencer = lastPouleRound.getNextFencer();

                if (different)
                {
                    if (pouleFencer.PhaseFinalRanking == lastPhaseFinalRanking)
                    {
                        different = false;
                        continue;
                    }
                    lastPouleRound.resetFencerIndex();
                    qualifyLastRankLast = true;
                    return;
                }

                //Skips all eliminated, excluded, abandoned and scratched fencers.
                if (pouleFencer.IsStillInTheCompetition && rankListAllPouleRounds[i].IsStillInTheCompetition)
                {
                    if (rankListAllPouleRounds[i].ID != pouleFencer.ID)
                    {
                        different = true;
                    }
                }
                lastPhaseFinalRanking = pouleFencer.PhaseFinalRanking;
            }

            //If the last fencer is different.
            if (different)
            {
                qualifyLastRankLast = true;
                return;
            }

            lastPouleRound.resetFencerIndex();
            qualifyAllRankAll = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prints the result of given poule round.
        /// </summary>
        /// <param name="pouleRound"></param>
        private void printRankingAfterPouleRound(FRCPouleRound pouleRound)
        {
            //Starting on a new page if the given page is not empty.
            if (currentYCoordinate > pageTopSize)
            {
                currentYCoordinate = 810;
            }

            XGraphics graphics = XGraphics.FromPdfPage(getCurrentPage());
            XFont     font1 = new XFont(FONT_TYPE, 11, XFontStyle.Bold);
            XFont     font2 = new XFont(FONT_TYPE, 10);
            double    font1Height = font1.GetHeight();
            double    font2Height = font2.GetHeight();
            double    x = DEFAULT_START_X;
            FRCFencer fencer, fencerInList;
            int       amountOfFencers = pouleRound.amountOfFencers();

            for (int i = 0; i < pouleRound.amountOfFencers(); i++)
            {
                fencer       = pouleRound.getNextFencer();
                fencerInList = getFencerMatchingID(fencer.ID);
                if (fencerInList.Forfait || fencerInList.Excluded)
                {
                    amountOfFencers--;
                }
            }
            string title = FRCPrinterConstants.RANKING_OF_POULES + ", " + FRCPrinterConstants.ROUND + " " + FRCPrinterConstants.NUMBER +
                           " " + pouleRound.RoundNumber.ToString() + " (" + amountOfFencers.ToString() + " " + FRCPrinterConstants.FENCERS_LOWER + ")";

            graphics.DrawString(title, font1, XBrushes.Black, x, currentYCoordinate);
            currentYCoordinate += font1Height * 2;
            x += 5;
            graphics.DrawString(FRCPrinterConstants.RANK, font2, XBrushes.Black, x, currentYCoordinate);
            graphics.DrawString(FRCPrinterConstants.NAME, font2, XBrushes.Black, x + 45, currentYCoordinate);
            graphics.DrawString(FRCPrinterConstants.CLUB, font2, XBrushes.Black, x + 235, currentYCoordinate);
            graphics.DrawString(FRCPrinterConstants.V_M, font2, XBrushes.Black, x + 330, currentYCoordinate);
            graphics.DrawString(FRCPrinterConstants.HS_HR, font2, XBrushes.Black, x + 365, currentYCoordinate);
            graphics.DrawString(FRCPrinterConstants.HS, font2, XBrushes.Black, x + 400, currentYCoordinate);
            graphics.DrawString(FRCPrinterConstants.Q_E, font2, XBrushes.Black, x + 425, currentYCoordinate);
            currentYCoordinate += font2Height * 2;

            //Added since the meaning of RangFinal is not consistent for all versions of EnGarde
            for (int i = 0; i < pouleRound.amountOfFencers(); i++)
            {
                fencer       = pouleRound.getNextFencer();
                fencerInList = getFencerMatchingID(fencer.ID);
                pouleRound.CopyPouleResult(fencerInList);
            }
            pouleRound.calculateFencerPouleRanking();

            pouleRound.sortFencerPouleRanking();
            for (int i = 0; i < pouleRound.amountOfFencers(); i++)
            {
                fencer = pouleRound.getNextFencer();
                //fencerInList = getFencerMatchingID(fencer.ID);
                //Skip if the fencer got scratch or exclusion.
                if (fencer.Forfait || fencer.Excluded)
                {
                    continue;
                }
                //Skip if the fencer does not have a status, since that is odd and happens sometime.
                if (fencer.NoStatusException == true)
                {
                    continue;
                }

                double totalY = currentYCoordinate + font2Height * 1.3;
                graphics = checkYCoordinate(graphics, totalY);

                string pr   = fencer.PhaseFinalRanking.ToString();
                string name = fencer.LastName.ToUpper() + " " + fencer.FirstName;
                string club = fencer.Club;
                string ind  = (fencer.HitsGivenInPoule - fencer.HitsTakenInPoule).ToString();
                string hs   = fencer.HitsGivenInPoule.ToString();
                string qe;
                string vm_s = fencer.VM_String;
                if (fencer.IsStillInTheCompetition)
                {
                    qe = FRCPrinterConstants.QUALIFIED;
                }
                else if (fencer.Abandoned)
                {
                    qe   = FRCPrinterConstants.ABANDONED;
                    ind  = " ";
                    hs   = "";
                    vm_s = "";
                }
                else
                {
                    qe           = FRCPrinterConstants.ELIMINATED;
                    qualifiedEnd = true;
                }

                if (name.Length > 37)
                {
                    name = name.Remove(37);
                }
                if (club.Length > 15)
                {
                    club = club.Remove(15);
                }

                if (qualifiedEnd && !eliminatedStarted)
                {
                    XPen pen = new XPen(XColors.Black, 0.5);
                    graphics = checkYCoordinate(graphics, totalY + font2Height * 0.5);
                    //currentYCoordinate += font2Height * 0.25;
                    graphics.DrawLine(pen, x, currentYCoordinate - font2Height * 0.7, x + 470, currentYCoordinate - font2Height * 0.7);
                    currentYCoordinate += font2Height * 0.5;
                    eliminatedStarted   = true;
                }

                graphics.DrawString(pr, font2, XBrushes.Black, x + 15 - pr.Length * 5, currentYCoordinate);
                graphics.DrawString(name, font2, XBrushes.Black, x + 45, currentYCoordinate);
                graphics.DrawString(club, font2, XBrushes.Black, x + 235, currentYCoordinate);
                graphics.DrawString(vm_s, font2, XBrushes.Black, x + 330, currentYCoordinate);
                if (ind[0] == '-')
                {
                    graphics.DrawString(ind, font2, XBrushes.Black, x + 374 - (ind.Length - 1) * 5, currentYCoordinate);
                }
                else
                {
                    graphics.DrawString(ind, font2, XBrushes.Black, x + 377 - ind.Length * 5, currentYCoordinate);
                }
                graphics.DrawString(hs, font2, XBrushes.Black, x + 412 - hs.Length * 5, currentYCoordinate);
                graphics.DrawString(qe, font2, XBrushes.Black, x + 425, currentYCoordinate);

                currentYCoordinate += font2Height * 1.3;
            }

            qualifiedEnd      = false;
            eliminatedStarted = false;
            graphics.Dispose();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Intreprets the information of the poule round from the xml file.
        /// </summary>
        private void interpretPouleRound()
        {
            if (reader.Name == TOUR_DE_POULES)
            {
                pouleRoundIntro = true;
                poulePhase      = true;
                FRCPouleRound pr = new FRCPouleRound();
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == ID)
                    {
                        pr.RoundNumber = int.Parse(reader.Value);
                    }
                    else if (reader.Name == NB_DE_POULES)
                    {
                        pr.NumOfPoules = int.Parse(reader.Value);
                    }
                    else if (reader.Name == NB_QUALIFIES_PAR_INDICE)
                    {
                        pr.NumOfQualifiers = int.Parse(reader.Value);
                    }

                    //Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                }

                pouleRound.Add(pr);
            } //Checks that TIREUR or EQUIPE appears during the intro of the poule round.
            else if ((reader.Name == TIREUR || reader.Name == EQUIPE) && (pouleRoundIntro))
            {
                FRCCompetitor athlete;
                if (isIndividualCompetition)
                {
                    athlete = new FRCFencer();
                }
                else
                {
                    athlete = new FRCTeam();
                }

                int i = -1;

                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == REF)
                    {
                        athlete.ID = int.Parse(reader.Value);
                        if (isIndividualCompetition) //Copying info from this.fencer if individual competition
                        {
                            for (i = 0; i < this.fencer.Count; i++)
                            {
                                if (athlete.ID == this.fencer[i].ID)
                                {
                                    athlete = (FRCFencer)this.fencer[i].Clone();
                                    break;
                                }
                            }
                        }
                        else //Copying info from this.team if team competition
                        {
                            for (i = 0; i < this.team.Count; i++)
                            {
                                if (athlete.ID == this.team[i].ID)
                                {
                                    athlete = (FRCTeam)this.team[i].Clone();
                                    break;
                                }
                            }
                        }
                    }
                    else if (reader.Name == RANG_INITIAL)
                    {
                        athlete.PhaseInitialRanking = int.Parse(reader.Value);
                        //Sets initial ranking of the competitor.
                        if (isIndividualCompetition)
                        {
                            if (fencer[i].InitialRanking == -1)
                            {
                                fencer[i].InitialRanking = int.Parse(reader.Value);
                            }
                        }
                        else
                        {
                            if (team[i].InitialRanking == -1)
                            {
                                team[i].InitialRanking = int.Parse(reader.Value);
                            }
                        }
                    }
                    else if (reader.Name == RANG_FINAL)
                    {
                        athlete.PhaseFinalRanking = int.Parse(reader.Value);
                    }
                    else if (reader.Name == STATUT)
                    {
                        athlete.NoStatusException = false;
                        if (reader.Value == "Q")
                        {
                            athlete.IsStillInTheCompetition = true;
                        }
                        else if (reader.Value == "N")
                        {
                            athlete.IsStillInTheCompetition = false;
                        }
                        else if (reader.Value == "A")
                        {
                            athlete.IsStillInTheCompetition = false;
                            athlete.Abandoned = true;
                            if (isIndividualCompetition)
                            {
                                fencer[i].Abandoned = true;
                            }
                            else
                            {
                                team[i].Abandoned = true;
                            }
                        }
                        else if (reader.Value == "F")
                        {
                            athlete.IsStillInTheCompetition = false;
                            athlete.Forfait = true;
                            if (isIndividualCompetition)
                            {
                                fencer[i].Forfait = true;
                            }
                            else
                            {
                                team[i].Forfait = true;
                            }
                        }
                        else if (reader.Value == "E")
                        {
                            athlete.IsStillInTheCompetition = false;
                            athlete.Excluded = true;
                            if (isIndividualCompetition)
                            {
                                fencer[i].Excluded = true;
                            }
                            else
                            {
                                team[i].Excluded = true;
                            }
                        }
                    }
                    //Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                }
                if (isIndividualCompetition)
                {
                    pouleRound[pouleRound.Count - 1].addFencer((FRCFencer)athlete);
                }
                else
                {
                    pouleRound[pouleRound.Count - 1].addTeam((FRCTeam)athlete);
                }
            }
        }