Exemplo n.º 1
0
        public void Tournament_SavePbn()
        {
            var original = TournamentLoad("WC2005final01.pbn");
            var allPass  = new BoardResult("", original.Boards[0], new Participant("test1", "test1", "test1", "test1"));

            allPass.Auction.Record(Bid.C("p"));
            allPass.Auction.Record(Bid.C("p"));
            allPass.Auction.Record(Bid.C("p"));
            allPass.Auction.Record(Bid.C("p"));
            original.Boards[0].Results.Add(allPass);
            var partialPlay = new BoardResult("", original.Boards[0], new Participant("test2", "test2", "test2", "test2"));

            partialPlay.HandleBidDone(Seats.North, Bid.C("1S"));
            partialPlay.HandleBidDone(Seats.East, Bid.C("p"));
            partialPlay.HandleBidDone(Seats.South, Bid.C("p"));
            partialPlay.HandleBidDone(Seats.West, Bid.C("p"));
            partialPlay.HandleCardPlayed(Seats.East, Suits.Hearts, Ranks.King);
            partialPlay.HandleCardPlayed(Seats.South, Suits.Hearts, Ranks.Two);
            partialPlay.HandleCardPlayed(Seats.West, Suits.Hearts, Ranks.Three);
            partialPlay.HandleCardPlayed(Seats.North, Suits.Hearts, Ranks.Ace);
            partialPlay.HandleCardPlayed(Seats.North, Suits.Spades, Ranks.Ace);
            original.Boards[0].Results.Add(partialPlay);
            var partialAuction = new BoardResult("", original.Boards[0], new Participant("test3", "test3", "test3", "test3"));

            partialAuction.Auction.Record(Bid.C("1S"));
            partialAuction.Auction.Record(Bid.C("p"));
            partialAuction.Auction.Record(Bid.C("p"));
            original.Boards[0].Results.Add(partialAuction);
            Pbn2Tournament.Save(original, File.Create("t1.pbn"));
            var copy = TournamentLoad("t1.pbn");

            Assert.AreEqual(original.EventName, copy.EventName, "EventName");
            Assert.AreEqual <DateTime>(original.Created, copy.Created, "Created");
            Assert.AreEqual <int>(original.Boards.Count, copy.Boards.Count, "Boards.Count");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read a pbn file
        /// </summary>
        /// <param name="fileStream"></param>
        /// <returns></returns>
        public static async Task <Tournament> LoadAsync(Stream fileStream)
        {
            using (var sr = new StreamReader(fileStream))
            {
                string content = await sr.ReadToEndAsync();

                return(Pbn2Tournament.Load(content));
            }
        }
Exemplo n.º 3
0
        public async Task Tournament_Load_uBid()
        {
            var originalTournament = await TournamentLoader.LoadAsync(File.OpenRead("uBidParscore.pbn"));

            Assert.IsFalse(originalTournament.AllowOvercalls, "OvercallsAllowed");
            Pbn2Tournament.Save(originalTournament, File.Create("t1.pbn"));
            var newFile = await File.OpenText("t1.pbn").ReadToEndAsync();

            Assert.IsTrue(newFile.Contains("DoubleDummyTricks"), "DoubleDummyTricks");
            //Assert.IsTrue(newFile.Contains("OptimumResultTable"), "OptimumResultTable");
        }
Exemplo n.º 4
0
 public static void Save(Stream fileStream, Tournament tournament)
 {
     Pbn2Tournament.Save(tournament, fileStream);
 }