コード例 #1
0
        public PlayerPosition PlayCard(Card card, PlayerPosition playerPosition)
        {
            _nextPlayer = BridgeHelper.GetNextPlayerPosition(playerPosition);

            if (_currentTrick.Deck.Count == 0)
            {
                _currentTrick             = new Trick();
                _currentTrick.TrickDealer = playerPosition;
            }


            if (_currentTrick.Deck.Count <= 4)
            {
                card.PlayerPosition = playerPosition;
                _currentTrick.Deck.Cards.Add(card);
            }

            if (_currentTrick.Deck.Count == 4)
            {
                Tricks.Add(_currentTrick);
                var winner = FindWinner(_currentTrick, Contract.Trump);
                _currentTrick.TrickWinner = winner;
                _nextPlayer   = winner;
                _currentTrick = new Trick()
                {
                    TrickDealer = winner
                };
            }

            GameState[playerPosition].RemoveCard(card);

            return(_nextPlayer);
        }
コード例 #2
0
        public BridgeGame(Dictionary <PlayerPosition, Deck> state, PlayerPosition declarer, string contract)
        {
            GameState = state;
            Tricks    = new List <Trick>();
            Declarer  = declarer;
            Dummy     = BridgeHelper.GetNextPlayerPosition(BridgeHelper.GetNextPlayerPosition(declarer));
            Contract  = new Contract(contract, declarer);

            _currentTrick = new Trick()
            {
                TrickDealer = BridgeHelper.GetNextPlayerPosition(declarer)
            };
        }
コード例 #3
0
ファイル: PlayGameService.cs プロジェクト: hefangshi/dds.net
        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)
            });
        }