Beispiel #1
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);
        }