Ejemplo n.º 1
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";
        }
Ejemplo n.º 2
0
 //Lyssnar efter gjorda drag i ui
 public void onMoveCompleted(int[] newMove, Player currentPlayer)
 {
     if (currentPlayer.Color == gamestatus)
     {
         makeMove(newMove[0], newMove[1], newMove[2], newMove[3]);
     }
 }