public static MyList <Role> get_roles_for_game(int players_num) { int num_evil; if (players_num < 7) { num_evil = 2; } else if (players_num < 9) { num_evil = 3; } else { num_evil = 4; } int num_good = players_num - num_evil; MyList <Role> available_good_roles = good_roles(players_num); MyList <Role> available_evil_roles = evil_roles(players_num); MyList <Role> good_roles_in_game = available_good_roles.pop_random_sample(num_good); MyList <Role> evil_roles_in_game = available_evil_roles.pop_random_sample(num_evil); bool tristan_in_game = good_roles_in_game.Contains(TRISTAN); bool iseult_in_game = good_roles_in_game.Contains(ISEULT); if (tristan_in_game && !iseult_in_game) { good_roles_in_game.Remove(TRISTAN); available_good_roles.Remove(ISEULT); good_roles_in_game.Add(available_good_roles.pop_random()); } if (!tristan_in_game && iseult_in_game) { available_good_roles.Remove(TRISTAN); good_roles_in_game.Remove(ISEULT); good_roles_in_game.pop_random(); good_roles_in_game.Add(TRISTAN); good_roles_in_game.Add(ISEULT); } return(good_roles_in_game.Concat(evil_roles_in_game)); }
static MyList <string> get_players_names() { int players_num = get_players_num(); MyList <string> players_names = new MyList <string>(); while (players_names.Count < players_num) { Console.WriteLine("enter the name of player #{0}", players_names.Count + 1); String name = Console.ReadLine(); if (players_names.Contains(name)) { Console.WriteLine("names must be unique"); } else { players_names.Add(name); } } return(players_names); }