Пример #1
0
        private EndGameRules InitEndGameRules()
        {
            var ret = new EndGameRules(this, _timerManager, _movesSet, _piecesInfluenceManager);

            ret.GameEndedEvent += (sender, e) =>
            {
                _gameEnded = true;
                GameEndedEvent?.Invoke(this, e);
            };
            return(ret);
        }
Пример #2
0
        internal void InitPieces(IEnumerable <PieceCoordinatePair> pieceCoordinatePairs)
        {
            var allPieces = pieceCoordinatePairs.Select(kvp => kvp.Piece);

            if (!IsValidPiecesSet(allPieces))
            {
                throw new InvalidOperationException();
            }

            _kingsDict[Color.White] = allPieces.Single(p => p is King && p.Color.IsWhite) as King;
            _kingsDict[Color.Black] = allPieces.Single(p => p is King && p.Color.IsBlack) as King;

            foreach (var pair in pieceCoordinatePairs)
            {
                AddPiece(pair);
            }

            _piecesInfluenceManager.AddPieces(allPieces);
            _endGameRules = InitEndGameRules();
        }