private static BaseCommand GenerateVoteMissionCommand(GameModel model, Player player) { if (model.GamePhase != GamePhase.MissionVoting) { throw new GamePhaseException(model.GamePhase.ToString()); } if (!model.CurrentMission.Team.Contains(player)) { throw new NotOnTeamException(); } if (model.CurrentMission.MissionVoteOf[player] != MissionResult.Unknown) { throw new TwiceVoteException(); } MissionResult missionVote = (Character.IsGoodRole(player.Role)) ? MissionResult.Succeed : MissionResult.Fail; VoteMissionCommand command = new VoteMissionCommand(player.Id, missionVote); return(command); }
private void CreateMissionVoteCmd(MissionResult missionVote) { VoteMissionCommand command = new VoteMissionCommand(LocalPlayer.Id, missionVote); try { command.ValidateCommand(GameModel); } catch (BaseException ex) { if (ex is VoteTypeException) { InfoText.text = "You character alignment is Good. You must vote with Succeed!"; } return; } GameController.AddCommand(command); }