Пример #1
0
        public override string OnWriteMenu(InfoService service, BaseUser user = null)
        {
            bool showTooltips = user?.Config?.Tooltips ?? true;

            var menu = new StringBuilder();

            menu.AppendLine(GetMenuHeader(showTooltips));
            menu.Append(GetMenuGuides());
            menu.Append(GetMenuCategories(service));

            return(menu.ToString());
        }
Пример #2
0
        private IEnumerable <CommandNode> GetAvailableActions(InfoService service, ModuleInfo core, User user)
        {
            var  actions = new List <CommandNode>();
            bool canMove = Engine.CanMove(user.Husk, out string notification);

            if (!string.IsNullOrWhiteSpace(notification))
            {
                user.Notifier.Append(notification);
            }

            Husk husk   = user.Husk;
            bool canAct = Engine.CanAct(ref husk, user.Brain);

            user.Husk = husk;
            // This is compiling all of the available actions together
            foreach (CommandInfo action in core?.Commands)
            {
                if (actions.Any(x => x.Name == action.Name))
                {
                    continue;
                }

                var precondition = action.Preconditions.FirstOrDefault <OnlyWhenAttribute>();

                if (precondition != null)
                {
                    if (!precondition.Judge(user.Brain, user.Stats))
                    {
                        continue;
                    }
                }

                var bind = action.Attributes.FirstOrDefault <BindToRegionAttribute>();

                if (bind != null)
                {
                    if (!canMove || !canAct)
                    {
                        continue;
                    }

                    if (!bind.Judge(user.Husk))
                    {
                        continue;
                    }
                }

                actions.Add(new CommandNode(service.GetCommands(action.Name, core)));
            }

            return(actions);
        }
Пример #3
0
        public string GetActions(InfoService service, User user)
        {
            var  segment      = new StringBuilder();
            bool showTooltips = user?.Config?.Tooltips ?? true;

            segment.AppendLine("**Actions**");

            if (user?.Husk == null)
            {
                if (user.Brain.HasFlag(DesyncFlags.Initialized))
                {
                    return("*\"I couldn't seem to establish a connection to you.\"*");
                }

                return("");
            }

            if (showTooltips)
            {
                segment.AppendLine("> *This is everything that you are able to execute.*");
            }

            segment.Append("• ");

            Locator location = user.Husk.Location;

            bool hasDestination = user.Husk.Destination != null;

            if (hasDestination)
            {
                location = user.Husk.Destination;
            }

            segment.AppendLine(Engine.WriteLocationInfo(location.Id, hasDestination));

            ModuleInfo core    = service.InternalModules.FirstOrDefault(x => x.Name == "Actions");
            var        actions = GetAvailableActions(service, core, user);

            // This is now writing each action
            if (actions.Count() > 0)
            {
                segment.AppendJoin(" • ", actions.Select(x => WriteAction(x)));
            }
            else
            {
                segment.Append("No available actions to execute.");
            }

            return(segment.ToString());
        }
Пример #4
0
        private string GetMenuCategories(InfoService service)
        {
            if (service.Modules.Any())
            {
                return("");
            }

            var segment = new StringBuilder();
            var modules = service.GetBaseModules().Select(x => new ModuleNode(x));

            foreach (ModuleNode module in modules)
            {
                segment.Append(GetCategory(module));
            }

            return(segment.ToString());
        }
Пример #5
0
 public abstract string OnWriteMenu(InfoService service, BaseUser user = null);