Exemple #1
0
 public object Any(SolveGame solveGame)
 {
     var response = new SolveGameResponse();
     var dds = new DdsConnect();
     var trickResult = new TrickResult();
     GameReplayer.Replay(solveGame.PBN,
                      (game, player, card) =>
                      {
                          var result = dds.SolveBoard(game);
                          MapCards(result, (suit, rank, score) =>
                          {
                              trickResult[player.FirstLetter].Add(new CardResult
                              {
                                  Suit = suit.ShortName,
                                  Rank = rank.ShortName,
                                  Score = score
                              });
                          });
                      },
                      (number) =>
                      {
                          trickResult.Number = number;
                          response.Tricks.Add(trickResult);
                          trickResult = new TrickResult();
                      }
         );
     return response;
 }
Exemple #2
0
 public object Any(GetCard request)
 {
     var dds = new DdsConnect();
     var game = GameReplayer.Replay(request.PBN);
     var result = dds.SolveBoard(game);
     var card = result.FutureCards.Cards[0];
     return new GetCardResponse
     {
         Rank = card.Rank.ShortName,
         Suit = card.Suit.ShortName,
         Score = result.Scores[0]
     };
 }
Exemple #3
0
 public object Any(GetAllCards getAllCards)
 {
     var dds = new DdsConnect();
     var game = GameReplayer.Replay(getAllCards.PBN);
     var result = dds.SolveBoard(game);
     var response = new GetAllCardsResponse {Nodes = result.Nodes, Cards = new List<CardResult>()};
     for (int i = 0; i < result.FutureCards.Count; i++)
     {
         var card = result.FutureCards.Cards[i];
         response.Cards.Add(new CardResult{ Rank = card.Rank.ShortName, Suit = card.Suit.ShortName, Score = result.Scores[i]});
     }
     response.Cards = response.Cards.OrderByDescending(x=> x.Score).ToList();
     return response;
 }
Exemple #4
0
 public object Any(PlayGame request)
 {
     var dds = new DdsConnect();
     var game = GameReplayer.Replay(request.PBN);
     var player = BridgeHelper.GetNextPlayerPosition(game.Declarer);
     while (game.Tricks.Count != 13)
     {
         var result = dds.SolveBoard(game);
         var card = result.FutureCards.Cards[0];
         player = game.PlayCard(card, player);
     }
     var play = game.Tricks.Select(x => BridgeHelper.DeckToPbnPlay(x.Deck));
     return new PlayGameResponse
     {
         Play =  string.Join("\n",play)
     };
 }