예제 #1
0
        public static int SubjectiveDuration(Dream dream)
        {
            if (dream == null)
            {
                return(0);
            }

            return(dream.Depth == 0
                ? SubjectiveDuration(dream.InnerDream)
                : dream.Ticks + SubjectiveDuration(dream.InnerDream));
        }
예제 #2
0
        public static IEnumerable <string> DreamLevelDescriptions(Dream dream)
        {
            if (dream == null)
            {
                yield break;
            }

            if (dream.ZeroSleep || dream.Depth > 0)
            {
                yield return(dream.InnerDream != null
                    ? dream.Description + ", "
                    : dream.Description + "\n\n");
            }

            foreach (var description in DreamLevelDescriptions(dream.InnerDream))
            {
                yield return(description);
            }
        }
예제 #3
0
        public static Dream Sleep(Queue <char> stream, Dream dream, int wrapFactor)
        {
            if (stream.Count == 0)
            {
                return(dream);
            }

            switch (stream.Dequeue())
            {
            case 'D':
                if (dream.InnerDream == null)
                {
                    dream.InnerDream = new Dream
                    {
                        Depth      = dream.Depth + 1,
                        OuterDream = dream
                    };
                }
                Sleep(stream, dream.InnerDream, wrapFactor);
                break;

            case 'W':
                dream.OuterDream.InnerDreamTicks = Math.Ceiling((double)(dream.Ticks + dream.InnerDreamTicks) / wrapFactor);
                Sleep(stream, dream.OuterDream, wrapFactor);
                break;

            case 'T':
                dream.Ticks++;
                Sleep(stream, dream, wrapFactor);
                break;

            default:
                break;
            }

            return(dream);
        }