コード例 #1
0
ファイル: Referee.cs プロジェクト: Travis393-Team48/testing
        /*
         * Simulates a move being made and updates _board_history, _pass_count, and current_player
         * If the move is illegal, throws an exception adn updates _victors
         */
        public void Play(string point)
        {
            try
            {
                RuleCheckerWrapper.Play(_current_player.GetStone(), point, GetBoardHistory());
            }
            catch (RuleCheckerException)
            {
                if (_current_player == _player1)
                {
                    _victors.Add(_player2);
                }
                else
                {
                    _victors.Add(_player1);
                }
                throw new RefereeException("Invalid Play in Referee: an illegal move has been made");
            }

            //update _board_history
            BoardWrapper b = new BoardWrapper(_board_history[0].GetBoard(), _board_history[0].GetSize());

            b.PlaceStone(_current_player.GetStone(), point);
            b.RemoveDeadStones();
            _board_history.Insert(0, b);
            if (_board_history.Count == 4)
            {
                _board_history.RemoveAt(3);
            }

            _pass_count     = 0;
            _current_player = _current_player == _player1 ? _player2 : _player1;
        }