void PopulateData() { if (!Hosting) { return; } // Populates data for all rounds in the instance of this game // Sets questions and randomly assigns roles, making sure that every player is the decider // Randomly sets the order players will pitch their proposals // Randomly sets the order agenda items appear when bonus points are being awarded Round[] rounds = new Round[3]; List <string> deciderOrder = PlayerNames.ToShuffled(); for (int i = 0; i < rounds.Length; i++) { // Create the round and set the question rounds[i] = new Round(); // -- Roles // Randomize the roles Queue <Role> deckRoles = new Queue <Role> (Game.Decks.Deck.Roles.ToList <Role> ().ToShuffled()); PlayerRole[] roles = new PlayerRole[PlayerCount]; for (int j = 0; j < roles.Length; j++) { // Create the role string playerName = PlayerNames[j]; roles[j] = new PlayerRole(); roles[j].PlayerName = playerName; // Check if this player is the Decider for this round if (deciderOrder[i] == playerName) { roles[j].Title = "Decider"; } else { Role role = deckRoles.Dequeue(); roles[j].Title = role.Title; roles[j].AgendaItems = new AgendaItem[role.AgendaItems.Length]; } } rounds[i].Roles = roles; // -- Pitch // Randomly set the pitch order rounds[i].PitchOrder = PlayerNames .ToShuffled() .FindAll(x => x != rounds[i].Decider) .ToArray <string> (); // -- Agenda Items // Randomly set the agenda item order List <int[]> items2 = new List <int[]> (); for (int j = 0; j < roles.Length; j++) { PlayerRole r = roles[j]; if (r.Title == "Decider") { continue; } int playerIndex = System.Array.FindIndex(Players, x => x.Name == r.PlayerName); for (int k = 0; k < r.AgendaItems.Length; k++) { items2.Add(new int[] { playerIndex, k }); } } rounds[i].AgendaItemOrder = items2.ToShuffled().ToArray <int[]> (); } instance.Rounds = rounds; // PrintData (); // uncomment to print the data constructed above }