Esempio n. 1
0
        //Instantierar objekt som AI-spelaren behöver för att fungera
        public override void setupAI(ChessBoard chessboard, GameView gw)
        {
            this.chessboard = chessboard;
            this.rules = new RulesEngine(chessboard);
            this.board = chessboard.get();
            this.gw = gw;

        }
Esempio n. 2
0
        //Initierar spelare utifrån vad som har valts i menyerna
        public void GameSetup(string gamemode, bool isNewGame, string color)
        {
            if (isNewGame)
            {
                ds.removeFile();
            }

            board = new ChessBoard(ds);
            List<Player> players = new List<Player>();

            if (gamemode == "singleplayer")
            {
                switch (color)
                {
                    case "white":
                        playerwhite = new HumanPlayer("white");
                        playerblack = new CPUPlayer("black");
                        playerblack.setupAI(board, this);
                        players.Add(playerwhite);
                        break;

                    case "black":
                        playerwhite = new CPUPlayer("white");
                        playerblack = new HumanPlayer("black");
                        playerwhite.setupAI(board, this);
                        players.Add(playerblack);
                        break;
                }
            }
            else if(gamemode == "multiplayer")
            {
                playerwhite = new HumanPlayer("white");
                playerblack = new HumanPlayer("black");
                players.Add(playerwhite);
                players.Add(playerblack);
            }

            rules = new RulesEngine(board);
            window.setBoard(board.get());
            window.updateTable();
            window.setPlayers(players);
            playerwhite.isPlayersTurn = true;
            playerblack.isPlayersTurn = false;
            gamestatus = "white";
        }