Exemple #1
0
        public SubMission GetNewSubMission(SubMission previous)
        {
            if (SubMissions.Count() == 0)
            {
                return(null);
            }

            var selection = SubMissions.ElementAt(new Random().Next(0, SubMissions.Count()));

            if (selection != previous)
            {
                return(selection);
            }

            return(GetNewSubMission(previous));
        }
Exemple #2
0
        private async Task nextAsync()
        {
            var rng = new Random();

            var missionstring = "Er ging iets goed mis. Hier staat geen opdracht.";

            foreach (var sub in activeSubMissions)
            {
                sub.Duration--;
            }

            var subm = activeSubMissions.FirstOrDefault(x => x.Duration < 1);

            if (subm != null)
            {
                // deactivate submission
                missionstring = string.Format(subm.SubMission.Deactivation, subm.Players.ToArray());
                activeSubMissions.Remove(subm);
            }
            else if (rng.Next(0, 8) == 1 && (Settings.MissionCount - MissionsPassed > 1))
            {
                // activate new sub mission
                var selectedSubMission = pack.GetNewSubMission(lastSubMission);
                this.lastSubMission = selectedSubMission;
                var maxSelection = Settings.Players.Count() - (selectedSubMission.SubjectCount - 1);

                // using ToList to get a NEW list without shuffling the original list.
                var players = Settings.Players.ToList().OrderBy(x => rng.Next());
                // Get correct amount of random players, and shuffle selection
                var subjects = Settings.Players.GetRange(rng.Next(0, maxSelection), selectedSubMission.SubjectCount).OrderBy(x => rng.Next()).ToList();

                var active = new ActiveSubMission(subjects, selectedSubMission, rng.Next(1, Settings.MissionCount - MissionsPassed));
                activeSubMissions.Add(active);

                missionstring = string.Format(selectedSubMission.Activation, subjects.ToArray());
            }
            else
            {
                // regular mission
                var miss = pack.BuildNewMissionString(Settings, lastMission);
                missionstring = miss.Item1;
                lastMission   = miss.Item2;
            }

            await CurrentText.SetValueAsync(missionstring);
        }
Exemple #3
0
 public ActiveSubMission(List <string> players, SubMission submission, int duration)
 {
     this.Players    = players;
     this.SubMission = submission;
     this.Duration   = duration;
 }