示例#1
0
        public GameBoard(Player playerOne, Player playerTwo)
        {
            this.playerOne = playerOne;
            this.playerTwo = playerTwo;

            for (int i = 0; i < gameData.Length; i++)
            {
                gameData[i] = ' ';
            }
        }
 private void LoadPlayers()
 {
     playerOne = LoadOnePlayer("Prvi igrač (nick): ");
     if (playerOne != null)
     {
         playerTwo = LoadOnePlayer("Drugi igrač (nick): ");
     }
 }
示例#3
0
        private bool WonPlayer(Player player)
        {
            bool won = false;
            won |= CheckRow(0, player.Icon);
            won |= CheckRow(1, player.Icon);
            won |= CheckRow(2, player.Icon);

            won |= CheckColumn(0, player.Icon);
            won |= CheckColumn(1, player.Icon);
            won |= CheckColumn(2, player.Icon);

            won |= CheckDiagonals(playerOne.Icon);

            return won;
        }
        internal Player AddPlayer(string nick)
        {
            if (GetPlayer(nick) != null)
            {
                string message = String.Format(
                    "Igrač s nadimkom {0} već postoji!",
                    nick);
                throw new Exception(message);
            }

            Player player = new Player(nick);
            playerList.Add(player);

            Save();

            return player;
        }