Ejemplo n.º 1
0
 public async Task Play()
 {
     _referee = new Referee(Convert.ToInt32(textBoxHexBoardSize.Text));
     //_referee.GameOver += GameOver;
     //_referee.PlayerMadeMove += PlayerMadeMove;
     _referee.NewGame(Convert.ToInt32(textBoxHexBoardSize.Text));
     _referee.AddPlayer(configuration.PlayerConfigs.FirstOrDefault(x => x.name == comboBoxPlayer1Type.SelectedItem), 1);
     _referee.Player1.RelayInformation += PerformanceInformationRelayed;
     _referee.AddPlayer(configuration.PlayerConfigs.FirstOrDefault(x => x.name == comboBoxPlayer2Type.SelectedItem), 2);
     _referee.Player2.RelayInformation += PerformanceInformationRelayed;
     player1Metrics.Text = "";
     player2Metrics.Text = "";
     await StartGame();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates players.
        /// </summary>
        /// <param name="referee">The referee.</param>
        /// <param name="playerFactory">The player factory.</param>
        private static void CreatePlayers(Referee referee, PlayerFactory playerFactory)
        {
            int playersCount = ViewService.GetPlayersCount();

            if (playersCount == 0)
            {
                Close();
            }

            for (int i = 1; i <= playersCount; i++)
            {
                string name = ViewService.GetPlayerName(i);
                if (name.Length == 0)
                {
                    Close();
                }

                int playerType = ViewService.GetPlayerType(i);
                if (playerType == 0)
                {
                    Close();
                }

                referee.AddPlayer(
                    playerFactory.CreatePlayer(
                        name: name,
                        id: i,
                        playerType: (Config.PlayersTypes)(playerType - 1),
                        referee: referee));
            }

            referee.SetRandomPlayerOrder();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a preset referee
        /// </summary>
        /// <returns>The referee with all types players</returns>
        internal Referee GetReferee()
        {
            var referee       = new Referee();
            var playerFactory = new PlayerFactory();

            int i = 0;

            foreach (var playerType in Enum.GetValues(typeof(Config.PlayersTypes)))
            {
                referee.AddPlayer(
                    playerFactory.CreatePlayer(
                        name: playerType.ToString(),
                        id: i,
                        playerType: (Config.PlayersTypes)playerType,
                        referee: referee)
                    );
                i++;
            }

            return(referee);
        }