private static void BuildHelpText()
        {
            foreach (var command in _chatCommands.Values)
            {
                var type      = command.GetType();
                var attribute = type.GetCustomAttribute <CommandDetailsAttribute>();
                if (attribute == null)
                {
                    continue;
                }

                if (attribute.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextPlayer += ColorToken.Green("/" + type.Name.ToLower()) + ColorToken.White(": " + attribute.Description) + "\n";
                }

                if (attribute.Permissions.HasFlag(CommandPermissionType.DM))
                {
                    HelpTextDM += ColorToken.Green("/" + type.Name.ToLower()) + ColorToken.White(": " + attribute.Description) + "\n";
                }

                if (attribute.Permissions.HasFlag(CommandPermissionType.Admin))
                {
                    HelpTextAdmin += ColorToken.Green("/" + type.Name.ToLower() + ColorToken.White(": " + attribute.Description) + "\n");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends a message to a player informing them of the current number of items in the container and the maximum allowed.
        /// If incrementByOne is true, the current count will be increased by one. This is to account for the fact that
        /// the OnAddItem event fires before the item is actually added to the inventory (therefore it would have an off-by-one error)
        /// </summary>
        /// <param name="player">The player receiving the message</param>
        /// <param name="incrementByOne">Increments current item count by one if true, else does nothing.</param>
        protected static void SendItemLimitMessage(NWGameObject player, bool incrementByOne)
        {
            var container = NWGameObject.OBJECT_SELF;
            var limit     = GetItemLimit();
            var count     = _.GetInventoryItemCount(container);

            // The Add event fires before the item exists in the container. Need to increment by one in this scenario.
            if (incrementByOne)
            {
                count++;
            }

            _.SendMessageToPC(player, ColorToken.White("Item Limit: " + (count > limit ? limit : count) + " / ") + ColorToken.Red("" + limit));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Builds text used by the /help command for each authorization level.
        /// This must be called after LoadChatCommands or there will be nothing to process.
        /// </summary>
        private static void BuildHelpText()
        {
            foreach (var command in ChatCommands)
            {
                var text       = command.Key;
                var definition = command.Value;

                if (definition.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextPlayer += ColorToken.Green("/" + text) + ColorToken.White(": " + definition.Description) + "\n";
                }

                if (definition.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextDM += ColorToken.Green("/" + text) + ColorToken.White(": " + definition.Description) + "\n";
                }

                if (definition.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextAdmin += ColorToken.Green("/" + text) + ColorToken.White(": " + definition.Description) + "\n";
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Builds the Skill Details page.
        /// </summary>
        /// <param name="page">The page to build.</param>
        private void SkillDetailsInit(DialogPage page)
        {
            var model    = GetDataModel <Model>();
            var player   = GetPC();
            var playerId = GetObjectUUID(player);

            void BuildHeader()
            {
                var dbPlayer   = DB.Get <Player>(playerId);
                var skill      = Skill.GetSkillDetails(model.SelectedSkill);
                var pcSkill    = dbPlayer.Skills[model.SelectedSkill];
                var requiredXP = Skill.GetRequiredXP(pcSkill.Rank);

                string title;

                if (pcSkill.Rank <= 3)
                {
                    title = "Untrained";
                }
                else if (pcSkill.Rank <= 7)
                {
                    title = "Neophyte";
                }
                else if (pcSkill.Rank <= 13)
                {
                    title = "Novice";
                }
                else if (pcSkill.Rank <= 20)
                {
                    title = "Apprentice";
                }
                else if (pcSkill.Rank <= 35)
                {
                    title = "Journeyman";
                }
                else if (pcSkill.Rank <= 50)
                {
                    title = "Expert";
                }
                else if (pcSkill.Rank <= 65)
                {
                    title = "Adept";
                }
                else if (pcSkill.Rank <= 80)
                {
                    title = "Master";
                }
                else if (pcSkill.Rank <= 100)
                {
                    title = "Grandmaster";
                }
                else
                {
                    title = "Unknown";
                }

                title += " (" + pcSkill.Rank + ")";

                string decayLock = ColorToken.Green("Decay Lock: ") + ColorToken.White("Unlocked");

                if (pcSkill.IsLocked)
                {
                    decayLock = ColorToken.Green("Decay Lock: ") + ColorToken.Red("Locked");
                }

                // Skills which don't contribute to the cap cannot be locked (there's no reason for it.)
                // Display a message explaining this to the player instead.
                string noContributeMessage = string.Empty;

                if (!skill.ContributesToSkillCap)
                {
                    decayLock           = string.Empty;
                    noContributeMessage = ColorToken.Green("This skill does not contribute to your cumulative skill cap.") + "\n\n";
                }

                string unallocatedXP = ColorToken.Green("Unallocated XP: ") + dbPlayer.UnallocatedXP + "\n";

                page.Header =
                    ColorToken.Green("Skill: ") + skill.Name + "\n" +
                    ColorToken.Green("Rank: ") + title + "\n" +
                    ColorToken.Green("Exp: ") + Menu.BuildBar(pcSkill.XP, requiredXP, 100, ColorToken.TokenStart(255, 127, 0)) + "\n" +
                    unallocatedXP +
                    noContributeMessage +
                    decayLock + "\n\n" +
                    ColorToken.Green("Description: ") + skill.Description + "\n";
            }

            void DistributeXP()
            {
                ChangePage(DistributeXPId);
            }

            void ToggleDecayLock()
            {
                var dbPlayer = DB.Get <Player>(playerId);

                dbPlayer.Skills[model.SelectedSkill].IsLocked = !dbPlayer.Skills[model.SelectedSkill].IsLocked;
                DB.Set(playerId, dbPlayer);
            }

            BuildHeader();

            page.AddResponse("Distribute XP", DistributeXP);
            page.AddResponse("Toggle Decay Lock", ToggleDecayLock);
        }