Esempio n. 1
0
        public Setup_GS(Lobby lobby, ConcurrentDictionary <ChallengeTracker, object> challengeTrackers, bool useSingleColor, int numLayersPerTeam, int numTeamsPerPrompt, int numRounds, TimeSpan?setupTimer = null, TimeSpan?drawingTimer = null) : base(lobby)
        {
            this.SubChallenges  = challengeTrackers;
            this.UseSingleColor = useSingleColor;
            this.LayersPerTeam  = numLayersPerTeam;
            this.TeamsPerPrompt = numTeamsPerPrompt;
            this.PromptTimer    = setupTimer;
            this.DrawingTimer   = drawingTimer;
            this.NumRounds      = numRounds;

            // Cap the values at 2 teams using maximal colors (attempts to use all players).
            this.LayersPerTeam  = Math.Min(this.LayersPerTeam, this.Lobby.GetAllUsers().Count() / 2);
            this.TeamsPerPrompt = Math.Min(this.TeamsPerPrompt, this.Lobby.GetAllUsers().Count() / this.LayersPerTeam);

            State getChallenges = GetChallengesUserState();

            this.Entrance.Transition(getChallenges);
            getChallenges.AddExitListener(() => this.AssignPrompts());
            getChallenges.Transition(() =>
            {
                var getDrawings = new MultiStateChain(GetDrawingsUserStateChain, exit: new WaitForUsers_StateExit(this.Lobby), stateDuration: drawingTimer);
                getDrawings.Transition(this.Exit);
                return(getDrawings);
            });

            this.Legacy_UnityView = new Legacy_UnityView(this.Lobby)
            {
                ScreenId = new StaticAccessor <TVScreenId> {
                    Value = TVScreenId.WaitForUserInputs
                },
                Instructions = new StaticAccessor <string> {
                    Value = "Complete all the prompts on your devices."
                },
            };
        }
Esempio n. 2
0
        public Setup_GS(Lobby lobby, List <Prompt> promptsToPopulate, TimeSpan?writingTimeDuration, TimeSpan?drawingTimeDuration, int numRounds, int maxPlayersPerPrompt, int numDrawingsPerUser)
            : base(
                lobby: lobby,
                exit: new WaitForUsers_StateExit(lobby))
        {
            this.PromptsToPopulate   = promptsToPopulate;
            this.WritingTimeDuration = writingTimeDuration;
            this.DrawingTimeDuration = drawingTimeDuration.MultipliedBy(numDrawingsPerUser); // TODO, this is incorrect in edge case where we have too many users and maxPlayersPerPrompt is exceeded.
            this.NumRounds           = numRounds;
            this.MaxPlayersPerPrompt = maxPlayersPerPrompt;
            this.NumDrawingsPerUser  = numDrawingsPerUser;
            State getChallenges = GetChallengesUserState();

            this.Entrance.Transition(getChallenges);
            getChallenges.AddExitListener(() => this.AssignPrompts());
            getChallenges.Transition(() =>
            {
                StateExit waitForDrawings = new WaitForUsers_StateExit(
                    lobby: this.Lobby,
                    waitingPromptGenerator: (User user) =>
                {
                    return(Prompts.DisplayText("Waiting for others to draw.")(user));
                });
                var getDrawings = new MultiStateChain(GetDrawingsUserStateChain, exit: waitForDrawings, stateDuration: DrawingTimeDuration);
                getDrawings.Transition(this.Exit);
                return(getDrawings);
            });

            this.Legacy_UnityView = new Legacy_UnityView(this.Lobby)
            {
                ScreenId = new StaticAccessor <TVScreenId> {
                    Value = TVScreenId.WaitForUserInputs
                },
                Instructions = new StaticAccessor <string> {
                    Value = "Complete all the prompts on your devices."
                },
            };
        }
        public ContestantCreation_GS(Lobby lobby, RoundTracker roundTracker, TimeSpan?creationDuration)
            : base(
                lobby: lobby,
                exit: new WaitForUsers_StateExit(lobby))
        {
            this.RoundTracker = roundTracker;
            TimeSpan?multipliedCreationDuration = creationDuration.MultipliedBy(roundTracker.UsersToAssignedPrompts.Values.ToList()[0].Count);

            MultiStateChain contestantsMultiStateChain = new MultiStateChain(MakePeopleUserStateChain, stateDuration: multipliedCreationDuration);

            this.Entrance.Transition(contestantsMultiStateChain);
            contestantsMultiStateChain.Transition(this.Exit);

            this.Legacy_UnityView = new Legacy_UnityView(this.Lobby)
            {
                ScreenId = new StaticAccessor <TVScreenId> {
                    Value = TVScreenId.WaitForUserInputs
                },
                Instructions = new StaticAccessor <string> {
                    Value = "Make your contestants on your devices."
                },
            };
        }
Esempio n. 4
0
        public AnswerQuestion_GS(Lobby lobby, Dictionary <User, List <Question> > usersToAssignedQuestions, TimeSpan?answerTimeDuration = null) : base(lobby, answerTimeDuration)
        {
            List <State> GetAnswerUserStateChain(User user)
            {
                List <State> stateChain = new List <State>();

                foreach (Question question in usersToAssignedQuestions.GetValueOrDefault(user, new List <Question>()))
                {
                    stateChain.Add(new SimplePromptUserState(
                                       promptGenerator: (User user) => new UserPrompt()
                    {
                        UserPromptId = UserPromptId.FriendQuiz_AnswerQuestion,
                        Title        = "Answer this question as best you can",
                        Description  = question.Text,
                        SubPrompts   = new SubPrompt[]
                        {
                            new SubPrompt
                            {
                                Slider = new SliderPromptMetadata
                                {
                                    Min         = question.MinBound,
                                    Max         = question.MaxBound,
                                    Range       = false,
                                    ShowTooltip = question.Numeric?SliderTooltipType.Always:SliderTooltipType.Hide,
                                    Value       = new int[] { (question.MinBound + question.MaxBound) / 2 },
                                    Ticks       = question.TickValues.ToArray(),
                                    TicksLabels = question.TickLabels.ToArray()
                                }
                            },
                            new SubPrompt
                            {
                                Prompt  = "Select Abstain if you do not want to share your answer. Select Answer if you do",
                                Answers = new string[] { "Answer", "Abstain" }
                            }
                        },
                        SubmitButton = true
                    },
                                       formSubmitHandler: (User user, UserFormSubmission input) =>
                    {
                        if ((input.SubForms?[1]?.RadioAnswer ?? 1) == 1)
                        {
                            question.Abstained = true;
                        }
                        else
                        {
                            question.MainAnswer = input.SubForms[0].Slider?[0] ?? 0;
                        }
                        return(true, string.Empty);
                    }));
                }
                return(stateChain);
            }

            MultiStateChain askQuestions = new MultiStateChain(GetAnswerUserStateChain, exit: new WaitForUsers_StateExit(lobby));

            this.Entrance.Transition(askQuestions);
            askQuestions.Transition(this.Exit);

            this.UnityView = new UnityView(lobby)
            {
                ScreenId     = TVScreenId.WaitForUserInputs,
                Instructions = new UnityField <string> {
                    Value = "Answer all the questions on your phones"
                },
            };
        }