Beispiel #1
0
        public async ValueTask <string> RequestBridgeAsync(Stream requesterStream, CancellationToken cancellationToken)
        {
            var bridgeToken = await _serverMapping.CreateNodeTokenAsync(cancellationToken).ConfigureAwait(false);

            var tcsBridge = new BridgeInfo(requesterStream);

            if (!_bridges.TryAdd(bridgeToken, tcsBridge))
            {
                throw new InvalidOperationException("Duplicate bridge token");
            }

            return(bridgeToken);
        }
Beispiel #2
0
        public void PrintBoards(int idx)
        {
            // dodanie rozkladu
            Table rozklad = PrintBoardRozklad(game.boards[idx].rozklad, idx + 1, game.boards[idx].vulnerability);

            rozklad.Rows.LeftIndent = "1.5cm";

            document.LastSection.Add(rozklad);

            // document.LastSection.LastTable.Format.Alignment = ParagraphAlignment.Center;
            document.LastSection.Add(BreakLine.Clone());

            // dodanie DF
            int[,] analizaDF = BridgeInfo.wylicz_DF(ref game.boards[idx].rozklad);

            if (idx == 4)
            {
                rozklad.Rows.LeftIndent = "1.5cm";
            }

            Contract minimax = BridgeInfo.FindOptimalContract(analizaDF, game.boards[idx].vulnerability,
                                                              game.boards[idx].rozklad.dealer);

            Paragraph p = new Paragraph();

            p.AddFormattedText(napisDF, Czcionki.font_header);
            document.LastSection.Add(p);
            document.LastSection.Add(BreakLine.Clone());
            document.LastSection.Add(WriteDeepFinesse(analizaDF));

            document.LastSection.Add(WriteMinimax(minimax));

            // dodanie licytacji
            p = new Paragraph();
            p.AddFormattedText(napisLicytacja, Czcionki.font_header);
            document.LastSection.Add(BreakLine.Clone());
            document.LastSection.Add(p);
            document.LastSection.Add(BreakLine.Clone());
            Table biddingtrening = PrintBiddingTable(game.boards[idx].bidding, game.boards[idx].rozklad.dealer,
                                                     game.boards[idx].players);
            Paragraph p_tmp = new Paragraph();

            p_tmp.AddLineBreak();


            document.LastSection.Add(PrintConsolationBidding(idx));
            document.LastSection.Add(BreakLine.Clone());
            // linie z komentarzami
            document.LastSection.Add(AddCommentLines());
        }
Beispiel #3
0
        public void Calculate()
        {
            this.Streams.Clear();
            this.Bridges.Clear();

            var x = this.InnerMargin.Left;
            var xDiff = (this.CanvasWidth - this.InnerMargin.Left - this.InnerMargin.Right) / (this.StreamCount - 1);
            var y1 = this.InnerMargin.Top;
            var y2 = this.CanvasHeight - this.InnerMargin.Bottom;
            var yLen = y2 - y1;
            var blockLen = yLen / this.BlockCount;
            var prevBridges = new List<int>();
            var curBridges = new List<int>();

            for (int i = 0; i < this.StreamCount; i++)
            {
                // 縦線情報の生成
                var infStream = new StreamInfo
                {
                    Index = i,
                    Line = new LineInfo
                    {
                        X1 = x,
                        Y1 = y1,
                        X2 = x,
                        Y2 = y2
                    }
                };
                this.Streams.Add(infStream);

                // 横線情報の生成
                if (i < this.StreamCount - 1)
                {
                    var branchCount = _random.Next(this.MaxBranchCount - 1) + 1;
                    curBridges.Clear();
                    for (int i2 = 0; i2 < branchCount; i2++)
                    {
                        var bIndex = _random.Next(this.BlockCount - 1);
                        while (curBridges.Contains(bIndex) || prevBridges.Contains(bIndex))
                        {
                            bIndex = _random.Next(this.BlockCount - 1);
                        }
                        curBridges.Add(bIndex);

                        var yBridge = y1 + (bIndex + 1) * blockLen;
                        var infBridge = new BridgeInfo
                        {
                            Target = infStream,
                            Line = new LineInfo
                            {
                                X1 = x,
                                Y1 = yBridge,
                                X2 = x + xDiff,
                                Y2 = yBridge
                            }
                        };

                        this.Bridges.Add(infBridge);
                    }

                    prevBridges.Clear();
                    prevBridges.AddRange(curBridges);
                }

                x += xDiff;
            }

            // 横線情報の生成
            //var dList = new List<double>();
            //for (int i1 = 0; i1 < 3; i1++)
            //{
            //	for (int i2 = 0; i2 < this.StreamCount - 1; i2++)
            //	{
            //		var d = _random.NextDouble();
            //		while (dList.Contains(d))
            //		{
            //			d = _random.NextDouble();
            //		}
            //		dList.Add(d);

            //		var position = yLen * d;
            //		var index1 = _random.Next(this.StreamCount - 1);
            //		var stream1 = this.Streams[index1];
            //		var stream2 = this.Streams[index1 + 1];
            //		this.Bridges.Add(new BridgeInfo
            //		{
            //			Stream1 = stream1,
            //			Stream2 = stream2,
            //			Position = position,
            //			Line = new LineInfo
            //			{
            //				X1 = stream1.Line.X1,
            //				Y1 = position + this.InnerMargin.Top,
            //				X2 = stream2.Line.X1,
            //				Y2 = position + this.InnerMargin.Top
            //			}
            //		});
            //	}
            //}
        }
Beispiel #4
0
        public Document Print()
        {
            document = new Document();
            document.AddSection();
            // Ustawienia
            napisTytulowy = vugraph.title.title;
            date          = game.date;
            document.LastSection.PageSetup = SetMargin();
            document.LastSection.Headers.Primary.Add(SetHeader());
            document.LastSection.Footers.Primary.Add(SetFooter());

            //strona 1
            Paragraph FirstPageTitle = new Paragraph();

            rezultatMeczuVu += vugraph.title.team1 + " - " + vugraph.title.team2;
            int[] wynikMeczu = BridgeInfo.wylicz_mecz(ref vugraph.boards, ref vugraph.boards_closed);
            rezultatMeczuVu += " " + wynikMeczu[0].ToString() + ":" + wynikMeczu[1].ToString();
            FirstPageTitle.AddFormattedText(rezultatMeczuVu, Czcionki.font_header);
            FirstPageTitle.AddLineBreak();
            FirstPageTitle.AddLineBreak();
            document.LastSection.Add(FirstPageTitle);
            FirstPageTitle = new Paragraph();
            FirstPageTitle.AddFormattedText(napisPorownania, Czcionki.font_normal);
            FirstPageTitle.AddLineBreak();
            FirstPageTitle.AddLineBreak();
            document.LastSection.Add(FirstPageTitle);

            Paragraph TabelaTitle = new Paragraph();

            TabelaTitle.AddFormattedText(
                napisMecz + "nr 1 : " + PrepareTableTitle(game.boards[0].players, vugraph.boards[0].players),
                Czcionki.font_red);
            TabelaTitle.AddLineBreak();
            TabelaTitle.AddLineBreak();
            document.LastSection.Add(TabelaTitle);

            document.LastSection.Add(MakeMatchScoreTable(game.boards, vugraph.boards));

            //strona 2
            document.AddSection();
            TabelaTitle = new Paragraph();
            TabelaTitle.AddFormattedText(
                napisMecz + "nr 2 : " + PrepareTableTitle(game.boards[0].players, vugraph.boards_closed[0].players),
                Czcionki.font_red);
            TabelaTitle.AddLineBreak();
            TabelaTitle.AddLineBreak();
            document.LastSection.Add(TabelaTitle);

            document.LastSection.Add(MakeMatchScoreTable(game.boards, vugraph.boards_closed));

            // strony z rozdaniami
            licytacja_szerokosc_kolumny = 1.375;
            for (int i = 0; i < game.boards.Count; i++)
            {
                document.AddSection();
                PrintBoards(i);
            }
            //document.LastSection.Add(PrintBoardRozklad(main.boards[0].rozklad, 1, vulnerabilties.none));

            //Paragraph p = new Paragraph();
            //p.AddFormattedText("Liczba lew do wziecia", Czcionki.font_normal);
            //document.LastSection.Add(p);



            //string[] a = {"a","b","c","d","E"};
            //p = new Paragraph();
            //p.AddFormattedText("LICYTACJA", Czcionki.font_header);
            //document.LastSection.Add(p);
            //document.LastSection.Add(PrintBiddingTable(main.boards[0].bidding,positions.N,a));

            //document.LastSection.Add(AddCommentLines());


            return(document);
        }