void CheckPos()
    {
        numberCorrectPos = 0;


        for (int i = 1; i < 9; i++)
        {
            if (Board.instance.slots[i].content && Board.instance.slots[i].content.numberCode == i)
            {
                numberCorrectPos++;
            }

            if (i == 3 && i == numberCorrectPos && firstStop)
            {//start first stop
                firstStop = false;
                inGame    = false;
                OnFirstStop?.Invoke(this, EventArgs.Empty);
            }
        }

        if (numberCorrectPos == 8)
        {
            inGame = false;
            OnQuestion?.Invoke(this, EventArgs.Empty);
        }
    }
예제 #2
0
파일: Logging.cs 프로젝트: vvvvpm/uppm
        /// <summary>
        /// When user input is needed anywhere during using uppm this method should be called.
        /// It invokes <see cref="OnQuestion"/> where the implementer can either block uppm with user query or use the default value.
        /// </summary>
        /// <param name="question">Question to be asked from user</param>
        /// <param name="possibilities">If null any input will be accepted. Otherwise input is compared to these possible entries ignoring case. If no match is found question will be asked again.</param>
        /// <param name="defaultValue">This value is used when user submits an empty input or in a potential unattended mode.</param>
        /// <param name="source">Optional logger which asks the question</param>
        /// <returns>User answer or default</returns>
        public static string AskUser(
            string question,
            IEnumerable <string> possibilities = null,
            string defaultValue = "",
            ILogging source     = null)
        {
            var possarray = possibilities?.ToArray();

            L.Information(question);
            L.Information("    ({Possibilities})", possarray.Humanize("or"));
            L.Information("    (default is {DefaultValue})", defaultValue);

            var args = new AskUserEventArgs
            {
                Question = question,
                Default  = defaultValue
            };

            OnQuestion?.Invoke(source, args);
            if (possarray != null &&
                !possarray.Any(p => p.EqualsCaseless(args.Answer)))
            {
                L.Warning("Invalid answer submitted for question: {Answer}\n    Asking again.", args.Answer);
                AskUser(question, possarray, defaultValue, source);
            }

            var res = string.IsNullOrWhiteSpace(args.Answer) ? defaultValue : args.Answer;

            L.Debug("{Answer} is answered", res);
            return(res);
        }