Exemplo n.º 1
0
 private void InitializeVotes()
 {
     Votes = new Vote[(int)VoteNumber.Last + 1];
     for (int i = 0; i < Votes.Length; i++)
     {
         Votes[i] = new Vote();
     }
     VoteNumber = VoteNumber.First;
 }
Exemplo n.º 2
0
        private void AnimateCommand(BaseCommand command)
        {
            Write_ScrollView(command.LogConsole(GameModel));
            Persistence.Save(GameModel, "Last.save");

            if (command is PickTeamCommand)
            {
                foreach (Player player in GameModel.Players)
                {
                    PlayerToController[player].PlayerVote =
                        VoteType.Unknown;
                    PlayerToController[player].IsPicked =
                        ((PickTeamCommand)command).TeamPlayerIds.Contains(player.Id);
                }
            }
            if (command is EvaluateTeamVote)
            {
                foreach (Player player in GameModel.Players)
                {
                    MissionNumber missNum = ((EvaluateTeamVote)command).MissionNumber;
                    VoteNumber    voteNum = ((EvaluateTeamVote)command).VoteNumber;
                    Vote          vote    = GameModel.Missions[(int)missNum].Votes[(int)voteNum];
                    PlayerToController[player].PlayerVote =
                        vote.VoteOfPlayer[player];
                    PlayerToController[player].IsLeader =
                        GameModel.CurrentLeader == player;
                }
            }
            if (command is EvaluateMissionVote)
            {
                //Debug.Log("Not null missions: " + MissionControllers.Count(a => a != null));
                //Debug.Log("CurrentMission is " + ((GameModel.CurrentMission == null) ? "null" : "not null"));
                MissionNumber missionNumber = ((EvaluateMissionVote)command).MissionNumber;
                Mission       mission       = GameModel.Missions[(int)missionNumber];
                MissionControllers[(int)missionNumber].MissionResult =
                    mission.MissionResult;
            }
            if (command is EvaluateGameResult)
            {
                UpdatePlayers();
            }
            IOController.Refresh();
            UpdateView();
        }
Exemplo n.º 3
0
        public static BaseCommand CommandFromString(String strCommand, GameModel model)
        {
            if (strCommand.StartsWith("EvaluateGameResult "))
            {
                String[]      split      = strCommand.Split(' ');
                MissionResult gameResult = (MissionResult)Int32.Parse(split[1]);
                DefeatType    defeatType = (DefeatType)Int32.Parse(split[2]);

                EvaluateGameResult command = new EvaluateGameResult();
                command.GameResult   = gameResult;
                command.DefeatReason = defeatType;

                return(command);
            }

            if (strCommand.StartsWith("EvaluateMissionVote "))
            {
                String[]            split         = strCommand.Split(' ');
                MissionNumber       missionNumber = (MissionNumber)Int32.Parse(split[1]);
                EvaluateMissionVote command       = new EvaluateMissionVote(missionNumber);
                return(command);
            }

            if (strCommand.StartsWith("EvaluateTeamVote "))
            {
                String[]         split         = strCommand.Split(' ');
                MissionNumber    missionNumber = (MissionNumber)Int32.Parse(split[1]);
                VoteNumber       voteNumber    = (VoteNumber)Int32.Parse(split[2]);
                EvaluateTeamVote command       = new EvaluateTeamVote(missionNumber, voteNumber);
                return(command);
            }

            if (strCommand.StartsWith("PickTeam "))
            {
                String[] split     = strCommand.Split(' ');
                int      leaderId  = Int32.Parse(split[1]);
                string   teamCode  = split[2];
                int      playerNum = teamCode.Length;

                HashSet <int> playerTeamIds = new HashSet <int>();
                for (int i = 0; i < teamCode.Length; i++)
                {
                    if (teamCode[i] == '1')
                    {
                        playerTeamIds.Add(i);
                    }
                }

                PickTeamCommand command = new PickTeamCommand(leaderId, playerTeamIds, playerNum);
                return(command);
            }

            if (strCommand.StartsWith("VoteMission "))
            {
                String[]           split       = strCommand.Split(' ');
                int                playerId    = Int32.Parse(split[1]);
                MissionResult      missionVote = (MissionResult)Int32.Parse(split[2]);
                VoteMissionCommand command     = new VoteMissionCommand(playerId, missionVote);
                return(command);
            }

            if (strCommand.StartsWith("VoteTeam "))
            {
                String[]        split    = strCommand.Split(' ');
                int             playerId = Int32.Parse(split[1]);
                VoteType        teamVote = (VoteType)Int32.Parse(split[2]);
                VoteTeamCommand command  = new VoteTeamCommand(playerId, teamVote);
                return(command);
            }

            if (strCommand.StartsWith("ChangePlayer "))
            {
                String[]            split      = strCommand.Split(' ');
                int                 playerId   = Int32.Parse(split[1]);
                PlayerType          playerType = (PlayerType)Int32.Parse(split[2]);
                String              playerName = split[3];
                ChangePlayerCommand command    = new ChangePlayerCommand(playerId, playerType, playerName);
                return(command);
            }

            throw new ArgumentException("Command string not found: " + strCommand);
        }
Exemplo n.º 4
0
        public int CompareTo(IAnswer otherAnswer)
        {
            // implement your custom comparison here...

            return(VoteNumber.CompareTo(otherAnswer.VoteNumber)); // e.g.
        }
Exemplo n.º 5
0
 public EvaluateTeamVote(MissionNumber missNum, VoteNumber voteNum)
 {
     MissionNumber = missNum;
     VoteNumber    = voteNum;
 }