private void CreatePickTeamCmd() { HashSet <int> team = new HashSet <int>(GameController.SelectedPlayers. Select(plCtr => plCtr.PlayerModel.Id)); PickTeamCommand command = new PickTeamCommand(LocalPlayer.Id, team, GameModel.Players.Length); try { command.ValidateCommand(GameModel); } catch (BaseException ex) { if (ex is TeamNumberException) { InfoText.text = "You have to pick EXACTLY " + GameModel.CurrentTeamLength + "players for the mission!"; } return; } GameController.AddCommand(command); }
public static PickTeamCommand GeneratePickTeamCommand(GameModel model, Player leader) { if (model.GamePhase != GamePhase.TeamPicking) { throw new GamePhaseException(); } if (model.CurrentLeader != leader) { throw new NotLeaderException(); } HashSet <Player> pickedTeam = PickATeam(model, leader); LogicalModel <Player> logicalModel = new LogicalModel <Player>(pickedTeam, model.CurrentTeamLength); HashSet <Player> finalTeam = Utilities.PickRandom(logicalModel.PossibleTeams); HashSet <int> finalTeamIds = new HashSet <int>(finalTeam.Select(plr => plr.Id)); PickTeamCommand command = new PickTeamCommand(leader.Id, finalTeamIds, model.Players.Length); return(command); }