Exemple #1
0
        public Board(Board cpyBoard)
        {
            _players = new[] {
                new Player(cpyBoard.Players[0].Kind) {
                    CurrentToken = cpyBoard._players[0].CurrentToken},
                new Player(cpyBoard.Players[1].Kind) {
                    CurrentToken = cpyBoard._players[1].CurrentToken},
            };

            int idx = -1;
            foreach(var field in cpyBoard.FieldBoard)
            {
                idx++;
                if (field == null)
                    continue;
                if (field.Type == typeof(Move))
                    _board[idx] = new Move(idx);
                else
                {
                    var token = field as Token;
                    var newToken = new Token(token.Color);
                    newToken.IsFlipped = token.IsFlipped;
                    _board[idx] = newToken;
                }
            }

            CurrentTurn = _players.First(pl => pl.Color == cpyBoard.CurrentTurn.Color);
        }
Exemple #2
0
        public Player(PlayerKind kind)
        {
            Kind = kind;
            Color = (PlayerColor)_playerCount;
            CurrentToken = new Token(Color) { IsFlipped = true };

            _playerCount = (_playerCount + 1) % 2;
        }
Exemple #3
0
        private void InitBoard()
        {
            for (int i = 1; i <= 6; i++)
            {
                for (int j = 1; j <= 5; j += 2)
                {
                    var encodedIdx = 8 * i + j;
                    if ((i % 2) == 1)
                    {
                        _board[encodedIdx] = new Token(PlayerColor.red);
                        _board[encodedIdx + 1] = new Token(PlayerColor.yellow);
                    }
                    else
                    {
                        _board[encodedIdx + 1] = new Token(PlayerColor.red);
                        _board[encodedIdx] = new Token(PlayerColor.yellow);
                    }
                }
            }

            for (int i = 1; i < 63; i++)
                if (_board[i] == null && i != 7 && i != 56)
                    _board[i] = new Move(i);
        }