public string Register(string name, string aiType = "human") { if (_player1 == null) { _player1 = new PlayerWrapper(name, aiType); _player1.ReceiveStones("B"); return("B"); } else if (_player2 == null) { _player2 = new PlayerWrapper(name, aiType); _player2.ReceiveStones("W"); return("W"); } throw new InvalidOperationException("Invalid call to Register in Referee: Cannot register more than two players"); }
public string Register(string name) { if (_players_set == 0) { _player1.Register(name); _player1.ReceiveStones("B"); _current_player = _player1; _players_set++; return("B"); } else if (_players_set == 1) { _player2.Register(name); _player2.ReceiveStones("W"); _players_set++; return("W"); } throw new InvalidOperationException("Invalid call to Register in Referee: Cannot register more than two players"); }
//Sets fields for Referee and gives each player a stone public string AssignPlayer() { if (_players_set == 0) { Console.Write("Assigning " + _player1.GetName() + ": "); _current_player = _player1; _players_set++; _player1.ReceiveStones("B"); Console.WriteLine("Successful"); return("B"); } else if (_players_set == 1) { Console.Write("Assigning " + _player2.GetName() + ": "); _players_set++; _player2.ReceiveStones("W"); Console.WriteLine("Successful"); return("W"); } throw new InvalidOperationException("Invalid call to AssignPlayer in Referee: Cannot assign more than two players"); }