Example #1
0
        public HtmlProtocols.Board GetBoardResults(int n)
        {
            HtmlProtocols.Board board = new HtmlProtocols.Board();

            int round = n / dealsPerRound;

            board.Number = boards[n].GetBoardNumber();
            board.setHeader(boards[n]);

            StringBuilder res = new StringBuilder();

            for (int i = 0; i < movement.Deals(round); i++)
            {
                String   ns   = "";
                String   ew   = "";
                KopsDeal deal = boards[n].GetDeal(i);

                if (deal.GetNSResult().HasValue)
                {
                    ns = scoringMethod.PrintResult(deal.GetNSResult().Value, 2.0 * maxNumberOfRecords - 2.0);
                }
                else
                {
                    if (deal.tdResult.IndexOf('/') > -1)
                    {
                        ns = deal.tdResult.Split('/')[0] + ".0%";
                    }
                }

                if (deal.GetEWResult().HasValue)
                {
                    ew = scoringMethod.PrintResult(deal.GetEWResult().Value, 2.0 * maxNumberOfRecords - 2.0);
                }
                else
                {
                    if (deal.tdResult.IndexOf('/') > -1)
                    {
                        ew = deal.tdResult.Split('/')[1] + ".0%";
                    }
                }

                HtmlProtocols.Deal printedDeal = new HtmlProtocols.Deal();

                printedDeal.NsNumber = Pairs.GetPairNumber(deal.line ? movement.GetNS(round, i) : movement.GetEW(round, i)).ToString();
                printedDeal.EwNumber = Pairs.GetPairNumber(deal.line ? movement.GetEW(round, i) : movement.GetNS(round, i)).ToString();
                printedDeal.Play     = deal.GetHtml(1);
                printedDeal.NsResult = ns;
                printedDeal.EwResult = ew;

                board.Deals.Add(printedDeal);
            }

            return(board);
        }
Example #2
0
        public String PrintPlayerHistoryRows(int n)
        {
            StringBuilder res = new StringBuilder();

            for (int i = 0; i < boards.Count; i++)
            {
                int    round = i / dealsPerRound;
                int    op    = 0;
                String line  = "";

                KopsDeal          deal   = null;
                Nullable <double> result = null;

                for (int j = 0; j < movement.Deals(round); j++)
                {
                    bool wrongLine = boards[i].GetDeal(j).line;

                    if ((wrongLine && Pairs.GetPairNumber(movement.GetNS(round, j)) == n) ||
                        (!wrongLine && Pairs.GetPairNumber(movement.GetEW(round, j)) == n))
                    {
                        line   = "NS";
                        op     = wrongLine ? movement.GetEW(round, j) : movement.GetNS(round, j);
                        deal   = boards[i].GetDeal(j);
                        result = boards[i].GetDeal(j).GetNSResult();
                    }
                    else if ((wrongLine && Pairs.GetPairNumber(movement.GetEW(round, j)) == n) ||
                             (!wrongLine && Pairs.GetPairNumber(movement.GetNS(round, j)) == n))
                    {
                        line   = "EW";
                        op     = wrongLine ? movement.GetNS(round, j) : movement.GetEW(round, j);
                        deal   = boards[i].GetDeal(j);
                        result = boards[i].GetDeal(j).GetEWResult();
                    }
                }
                if (op != 0)
                {
                    if (i % dealsPerRound == 0)
                    {
                        int pairInternalNumber = Pairs.GetInternalPairNumber(Pairs.GetPairNumber(op));
                        res.AppendFormat(KopsHelper.GetLocalInfo(), @"<tr><td class=""right nbr1"" rowspan=""{0}"">{1}</td>
                         <td class=""nbr"" rowspan=""{0}"">{2}</td>
                            <td class=""right nbr"" rowspan=""{0}"">{3}</td>
                             <td class=""nbr"" rowspan=""{0}"">{4}</td>",
                                         dealsPerRound,
                                         Pairs.GetPairNumber(op),
                                         Pairs.GetPairNames(pairInternalNumber),
                                         Pairs.GetPairRank(pairInternalNumber) > 0 ?
                                         String.Format(KopsHelper.GetLocalInfo(), "{0:0.0}",
                                                       Pairs.GetPairRank(pairInternalNumber)) : "",
                                         Pairs.GetPairRegion(pairInternalNumber));
                    }
                    else
                    {
                        res.Append("<tr>");
                    }

                    res.AppendFormat(KopsHelper.GetLocalInfo(), @"<td class=""right"">{0}</td><td>{1}</td>{2}<td class=""right"">{3}</td></tr>",
                                     boards[i].GetBoardNumber(),
                                     line, deal.GetHtml(line.Equals("NS") ? 1 : -1).print(),
                                     result.HasValue ? scoringMethod.PrintResult(result.Value, 2.0 * maxNumberOfRecords - 2.0) :
                                     "");
                }
            }

            return(res.ToString());
        }