public IHttpActionResult GetSkill(long skillId)
 {
     try
     {
         return(Ok(_skillService.GetSkill(skillId)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #2
0
        private void LoadSkillResponses()
        {
            Model          vm     = GetDialogCustomData <Model>();
            List <PCSkill> skills = SkillService.GetPCSkillsForCategory(GetPC().GlobalID, vm.SelectedCategoryID);

            ClearPageResponses("SkillListPage");
            foreach (PCSkill pcSkill in skills)
            {
                Skill skill = SkillService.GetSkill(pcSkill.SkillID);
                AddResponseToPage("SkillListPage", skill.Name + " (Lvl. " + pcSkill.Rank + ")", true, skill.ID);
            }
        }
예제 #3
0
        // GET: api/Skills/5
        public GenericResponse <SkillModel> GetSkill(int id)
        {
            var result = new GenericResponse <SkillModel>();
            var skill  = service.GetSkill(id);

            if (skill == null)
            {
                result.StatusCode = 404; //TODO: ENUM THIS
                result.Message    = "NOT FOUND";
            }
            result.Data = skill;
            return(result);
        }
예제 #4
0
        private void LoadSkillDetails()
        {
            Model   vm      = GetDialogCustomData <Model>();
            Skill   skill   = SkillService.GetSkill(vm.SelectedSkillID);
            PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), vm.SelectedSkillID);
            int     req     = SkillService.SkillXPRequirements[pcSkill.Rank];
            string  header  = CreateSkillDetailsHeader(pcSkill, req);

            SetPageHeader("SkillDetailsPage", header);

            if (!skill.ContributesToSkillCap)
            {
                SetResponseVisible("SkillDetailsPage", 2, false);
            }
        }
예제 #5
0
        private void HandleSkillListResponse(int responseID)
        {
            DialogResponse response = GetResponseByID("SkillListPage", responseID);
            int            skillID  = (int)response.CustomData;
            Skill          skill    = SkillService.GetSkill(skillID);
            string         header   = "Are you sure you want to improve your " + skill.Name + " skill?";

            SetPageHeader("ConfirmPage", header);

            Model vm = GetDialogCustomData <Model>();

            vm.SkillID = skillID;
            SetDialogCustomData(vm);
            ChangePage("ConfirmPage");
        }
예제 #6
0
        private void HandleCategoryPageResponse(int responseID)
        {
            DialogResponse response   = GetResponseByID("CategoryPage", responseID);
            int            categoryID = (int)response.CustomData;

            List <PCSkill> pcSkills = SkillService.GetPCSkillsForCategory(GetPC().GlobalID, categoryID);

            ClearPageResponses("SkillListPage");
            foreach (PCSkill pcSkill in pcSkills)
            {
                Skill skill = SkillService.GetSkill(pcSkill.SkillID);
                AddResponseToPage("SkillListPage", skill.Name, true, pcSkill.SkillID);
            }

            ChangePage("SkillListPage");
        }
예제 #7
0
        public async Task GetTest()
        {
            // Arrange
            var skillId = 2;
            var client  = SetupMock_Skill(skillId);
            var config  = new Mock <IConfiguration>();

            client.BaseAddress = new Uri("https://localhost:1111/");
            config.SetupGet(s => s["SkillsURL"]).Returns("https://localhost:1111/");
            var service = new SkillService(null, new NullLogger <SkillService>(), config.Object)
            {
                Client = client
            };

            // Act
            var result = await service.GetSkill(skillId);

            // Assert
            var testItem = TestData.Skills().FirstOrDefault(s => s.Id == result.Id);

            Assert.AreEqual(testItem.Name, result.Name);
            Assert.AreEqual(testItem.XpCost, result.XpCost);
        }
예제 #8
0
        private void LoadDistributeRPXPPage()
        {
            NWPlayer player   = GetPC();
            Player   dbPlayer = DataService.Player.GetByID(player.GlobalID);
            Model    vm       = GetDialogCustomData <Model>();
            Skill    skill    = SkillService.GetSkill(vm.SelectedSkillID);

            string header = ColorTokenService.Green("Roleplay XP Distribution") + "\n\n";

            header += ColorTokenService.Green("Skill: ") + skill.Name + "\n";
            header += ColorTokenService.Green("Available RP XP: ") + dbPlayer.RoleplayXP + "\n";
            header += ColorTokenService.Green("Currently Distributing: ") + vm.RPXPDistributing + " RP XP\n";

            if (vm.IsConfirming)
            {
                SetResponseText("DistributeRPXPPage", 10, "CONFIRM DISTRIBUTE ROLEPLAY XP (" + vm.RPXPDistributing + ")");
            }
            else
            {
                SetResponseText("DistributeRPXPPage", 10, "Distribute Roleplay XP (" + vm.RPXPDistributing + ")");
            }

            SetPageHeader("DistributeRPXPPage", header);
        }
예제 #9
0
        private void HandleDistributeRPXPResponse(int responseID)
        {
            NWPlayer player   = GetPC();
            Player   dbPlayer = DataService.Player.GetByID(player.GlobalID);
            Model    vm       = GetDialogCustomData <Model>();

            int rpXpToDistribute = dbPlayer.RoleplayXP;

            PCSkill pcSkill = SkillService.GetPCSkill(player, vm.SelectedSkillID);
            Skill   skill   = SkillService.GetSkill(vm.SelectedSkillID);
            // Get all player skills and then sum them up by the rank.
            int totalSkillCount = DataService.PCSkill
                                  .GetAllByPlayerID(player.GlobalID)
                                  .Where(x => DataService.Skill.GetByID(x.SkillID).ContributesToSkillCap)
                                  .Sum(s => s.Rank);
            int totalSkillXpToMaxRank = 0;

            //totalSkillCount < SkillService.SkillCap
            for (int x = pcSkill.Rank + 1; x < skill.MaxRank; x++)
            {
                int tempValue;
                if (SkillService.SkillXPRequirements.TryGetValue(x, out tempValue))
                {
                    totalSkillXpToMaxRank += tempValue;
                }
            }

            switch (responseID)
            {
            case 1:     // Select All RP XP
                vm.RPXPDistributing = totalSkillXpToMaxRank;
                break;

            case 2:     // Increase by 1000
                vm.RPXPDistributing += 1000;
                break;

            case 3:     // Increase by 100
                vm.RPXPDistributing += 100;
                break;

            case 4:     // Increase by 10
                vm.RPXPDistributing += 10;
                break;

            case 5:     // Increase by 1
                vm.RPXPDistributing += 1;
                break;

            case 6:     // Decrease by 1000
                vm.RPXPDistributing -= 1000;
                break;

            case 7:     // Decrease by 100
                vm.RPXPDistributing -= 100;
                break;

            case 8:     // Decrease by 10
                vm.RPXPDistributing -= 10;
                break;

            case 9:     // Decrease by 1
                vm.RPXPDistributing -= 1;
                break;

            case 10:     // Distribute Roleplay XP

                // Make sure the player specified how much they want to distribute.
                if (vm.RPXPDistributing <= 0)
                {
                    player.SendMessage("Please specify how much RP XP you'd like to distribute into this skill.");
                    vm.IsConfirming = false;
                }
                else if (vm.RPXPDistributing > totalSkillXpToMaxRank)
                {
                    player.SendMessage("Please lower your distribution amount, current max for this skill is " + totalSkillXpToMaxRank + ".");
                    vm.IsConfirming = false;
                }
                else
                {
                    if (vm.IsConfirming)
                    {
                        // Give the distributed XP to a particular skill.
                        // We disable residency bonuses, DM bonuses, and skill penalties during this distribution because
                        // those are calculated when we give the player RP XP.
                        SkillService.GiveSkillXP(player, vm.SelectedSkillID, vm.RPXPDistributing, false, false);

                        dbPlayer             = DataService.Player.GetByID(player.GlobalID);
                        dbPlayer.RoleplayXP -= vm.RPXPDistributing;
                        DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);
                        vm.IsConfirming     = false;
                        vm.RPXPDistributing = 0;
                    }
                    else
                    {
                        vm.IsConfirming = true;
                    }
                }
                break;
            }

            if (vm.RPXPDistributing > dbPlayer.RoleplayXP)
            {
                vm.RPXPDistributing = dbPlayer.RoleplayXP;
            }
            else if (vm.RPXPDistributing < 0)
            {
                vm.RPXPDistributing = 0;
            }

            LoadDistributeRPXPPage();
        }
예제 #10
0
        private string CreateSkillDetailsHeader(PCSkill pcSkill, int req)
        {
            Player player = DataService.Player.GetByID(pcSkill.PlayerID);
            Skill  skill  = SkillService.GetSkill(pcSkill.SkillID);
            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 = ColorTokenService.Green("Decay Lock: ") + ColorTokenService.White("Unlocked");

            if (pcSkill.IsLocked)
            {
                decayLock = ColorTokenService.Green("Decay Lock: ") + ColorTokenService.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 = ColorTokenService.Green("This skill does not contribute to your cumulative skill cap.") + "\n\n";
            }

            string rpXP = ColorTokenService.Green("Roleplay XP: ") + player.RoleplayXP + "\n";

            Attribute primaryAttribute   = DataService.Attribute.GetByID(skill.Primary);
            Attribute secondaryAttribute = DataService.Attribute.GetByID(skill.Secondary);
            Attribute tertiaryAttribute  = DataService.Attribute.GetByID(skill.Tertiary);
            string    primary            = ColorTokenService.Green("Primary (+" + PlayerStatService.PrimaryIncrease + "): ") + primaryAttribute.Name + "\n";
            string    secondary          = ColorTokenService.Green("Secondary (+" + PlayerStatService.SecondaryIncrease + "): ") + secondaryAttribute.Name + "\n";
            string    tertiary           = ColorTokenService.Green("Tertiary (+" + PlayerStatService.TertiaryIncrease + "): ") + tertiaryAttribute.Name + "\n";

            return
                (ColorTokenService.Green("Skill: ") + skill.Name + "\n" +
                 ColorTokenService.Green("Rank: ") + title + "\n" +
                 ColorTokenService.Green("Exp: ") + MenuService.BuildBar(pcSkill.XP, req, 100, ColorTokenService.TokenStart(255, 127, 0)) + "\n" +
                 rpXP +
                 primary +
                 secondary +
                 tertiary +
                 noContributeMessage +
                 decayLock + "\n\n" +
                 ColorTokenService.Green("Description: ") + skill.Description + "\n");
        }
예제 #11
0
        private void BuildPerkDetails()
        {
            Model vm = GetDialogCustomData <Model>();

            Data.Entity.Perk perk   = PerkService.GetPerkByID(vm.SelectedPerkID);
            PCPerk           pcPerk = PerkService.GetPCPerkByID(GetPC().GlobalID, perk.ID);
            Player           player = PlayerService.GetPlayerEntity(GetPC().GlobalID);
            var perkLevels          = DataService.Where <PerkLevel>(x => x.PerkID == perk.ID).ToList();

            int       rank             = pcPerk?.PerkLevel ?? 0;
            int       maxRank          = perkLevels.Count();
            string    currentBonus     = "N/A";
            string    nextBonus        = "N/A";
            string    price            = "N/A";
            PerkLevel currentPerkLevel = PerkService.FindPerkLevel(perkLevels, rank);
            PerkLevel nextPerkLevel    = PerkService.FindPerkLevel(perkLevels, rank + 1);

            SetResponseVisible("PerkDetailsPage", 1, PerkService.CanPerkBeUpgraded(GetPC(), vm.SelectedPerkID));

            if (rank > 0)
            {
                if (currentPerkLevel != null)
                {
                    currentBonus = currentPerkLevel.Description;
                }
            }
            if (rank + 1 <= maxRank)
            {
                if (nextPerkLevel != null)
                {
                    nextBonus = nextPerkLevel.Description;
                    price     = nextPerkLevel.Price + " SP (Available: " + player.UnallocatedSP + " SP)";
                }
            }
            var perkCategory     = DataService.Get <PerkCategory>(perk.PerkCategoryID);
            var cooldownCategory = perk.CooldownCategoryID == null ?
                                   null :
                                   DataService.Get <CooldownCategory>(perk.CooldownCategoryID);

            string header = ColorTokenService.Green("Name: ") + perk.Name + "\n" +
                            ColorTokenService.Green("Category: ") + perkCategory.Name + "\n" +
                            ColorTokenService.Green("Rank: ") + rank + " / " + maxRank + "\n" +
                            ColorTokenService.Green("Price: ") + price + "\n" +
                            (perk.BaseFPCost > 0 ? ColorTokenService.Green("FP: ") + perk.BaseFPCost : "") + "\n" +
                            (cooldownCategory != null && cooldownCategory.BaseCooldownTime > 0 ? ColorTokenService.Green("Cooldown: ") + cooldownCategory.BaseCooldownTime + "s" : "") + "\n" +
                            ColorTokenService.Green("Description: ") + perk.Description + "\n" +
                            ColorTokenService.Green("Current Bonus: ") + currentBonus + "\n" +
                            ColorTokenService.Green("Next Bonus: ") + nextBonus + "\n";

            if (nextPerkLevel != null)
            {
                List <PerkLevelSkillRequirement> requirements =
                    DataService.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == nextPerkLevel.ID).ToList();
                if (requirements.Count > 0)
                {
                    header += "\n" + ColorTokenService.Green("Next Upgrade Skill Requirements:\n\n");

                    bool hasRequirement = false;
                    foreach (PerkLevelSkillRequirement req in requirements)
                    {
                        if (req.RequiredRank > 0)
                        {
                            PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), req.SkillID);
                            Skill   skill   = SkillService.GetSkill(pcSkill.SkillID);

                            string detailLine = skill.Name + " Rank " + req.RequiredRank;

                            if (pcSkill.Rank >= req.RequiredRank)
                            {
                                header += ColorTokenService.Green(detailLine) + "\n";
                            }
                            else
                            {
                                header += ColorTokenService.Red(detailLine) + "\n";
                            }

                            hasRequirement = true;
                        }
                    }

                    if (requirements.Count <= 0 || !hasRequirement)
                    {
                        header += "None\n";
                    }
                }
            }

            SetPageHeader("PerkDetailsPage", header);
        }
예제 #12
0
        private void BuildPerkDetails()
        {
            Model vm = GetDialogCustomData <Model>();

            Data.Entity.Perk perk   = PerkService.GetPerkByID(vm.SelectedPerkID);
            PCPerk           pcPerk = PerkService.GetPCPerkByID(GetPC().GlobalID, perk.ID);
            Player           player = PlayerService.GetPlayerEntity(GetPC().GlobalID);
            var perkLevels          = DataService.Where <PerkLevel>(x => x.PerkID == perk.ID).ToList();

            int       rank                          = pcPerk?.PerkLevel ?? 0;
            int       maxRank                       = perkLevels.Count();
            string    currentBonus                  = "N/A";
            string    currentFPCost                 = string.Empty;
            string    currentConcentrationCost      = string.Empty;
            string    currentSpecializationRequired = "None";
            string    nextBonus                     = "N/A";
            string    nextFPCost                    = "N/A";
            string    nextConcentrationCost         = string.Empty;
            string    price                         = "N/A";
            string    nextSpecializationRequired    = "None";
            PerkLevel currentPerkLevel              = PerkService.FindPerkLevel(perkLevels, rank);
            PerkLevel nextPerkLevel                 = PerkService.FindPerkLevel(perkLevels, rank + 1);

            SetResponseVisible("PerkDetailsPage", 1, PerkService.CanPerkBeUpgraded(GetPC(), vm.SelectedPerkID));

            // Player has purchased at least one rank in this perk. Show their current bonuses.
            if (rank > 0 && currentPerkLevel != null)
            {
                var currentPerkFeat = DataService.SingleOrDefault <PerkFeat>(x => x.PerkID == vm.SelectedPerkID &&
                                                                             x.PerkLevelUnlocked == currentPerkLevel.Level);
                currentBonus = currentPerkLevel.Description;

                // Not every perk is going to have a perk feat. Don't display this information if not necessary.
                if (currentPerkFeat != null)
                {
                    currentFPCost = currentPerkFeat.BaseFPCost > 0 ? (ColorTokenService.Green("Current FP: ") + currentPerkFeat.BaseFPCost + "\n") : string.Empty;

                    // If this perk level has a concentration cost and interval, display it on the menu.
                    if (currentPerkFeat.ConcentrationFPCost > 0 && currentPerkFeat.ConcentrationTickInterval > 0)
                    {
                        currentConcentrationCost = ColorTokenService.Green("Current Concentration FP: ") + currentPerkFeat.ConcentrationFPCost + " / " + currentPerkFeat.ConcentrationTickInterval + "s\n";
                    }
                }

                // If this perk level has required specialization, change the text to that.
                if (currentPerkLevel.SpecializationID > 0)
                {
                    // Convert ID to enum, then get the string of the enum value. If we ever get a specialization with
                    // more than one word, another process will need to be used.
                    currentSpecializationRequired = ((SpecializationType)currentPerkLevel.SpecializationID).ToString();
                }
            }

            // Player hasn't reached max rank and this perk has another perk level to display.
            if (rank + 1 <= maxRank && nextPerkLevel != null)
            {
                var nextPerkFeat = DataService.SingleOrDefault <PerkFeat>(x => x.PerkID == vm.SelectedPerkID &&
                                                                          x.PerkLevelUnlocked == rank + 1);
                nextBonus = nextPerkLevel.Description;
                price     = nextPerkLevel.Price + " SP (Available: " + player.UnallocatedSP + " SP)";

                if (nextPerkFeat != null)
                {
                    nextFPCost = nextPerkFeat.BaseFPCost > 0 ? (ColorTokenService.Green("Next FP: ") + nextPerkFeat.BaseFPCost + "\n") : string.Empty;

                    // If this perk level has a concentration cost and interval, display it on the menu.
                    if (nextPerkFeat.ConcentrationFPCost > 0 && nextPerkFeat.ConcentrationTickInterval > 0)
                    {
                        nextConcentrationCost = ColorTokenService.Green("Next Concentration FP: ") + nextPerkFeat.ConcentrationFPCost + " / " + nextPerkFeat.ConcentrationTickInterval + "s\n";
                    }
                }

                if (nextPerkLevel.SpecializationID > 0)
                {
                    nextSpecializationRequired = ((SpecializationType)nextPerkLevel.SpecializationID).ToString();
                }
            }
            var perkCategory     = DataService.Get <PerkCategory>(perk.PerkCategoryID);
            var cooldownCategory = perk.CooldownCategoryID == null ?
                                   null :
                                   DataService.Get <CooldownCategory>(perk.CooldownCategoryID);

            string header = ColorTokenService.Green("Name: ") + perk.Name + "\n" +
                            ColorTokenService.Green("Category: ") + perkCategory.Name + "\n" +
                            ColorTokenService.Green("Rank: ") + rank + " / " + maxRank + "\n" +
                            ColorTokenService.Green("Price: ") + price + "\n" +
                            currentFPCost +
                            currentConcentrationCost +
                            (cooldownCategory != null && cooldownCategory.BaseCooldownTime > 0 ? ColorTokenService.Green("Cooldown: ") + cooldownCategory.BaseCooldownTime + "s" : "") + "\n" +
                            ColorTokenService.Green("Description: ") + perk.Description + "\n" +
                            ColorTokenService.Green("Current Bonus: ") + currentBonus + "\n" +
                            ColorTokenService.Green("Requires Specialization: ") + currentSpecializationRequired + "\n" +
                            nextFPCost +
                            nextConcentrationCost +
                            ColorTokenService.Green("Next Bonus: ") + nextBonus + "\n" +
                            ColorTokenService.Green("Requires Specialization: ") + nextSpecializationRequired + "\n";


            if (nextPerkLevel != null)
            {
                List <PerkLevelSkillRequirement> requirements =
                    DataService.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == nextPerkLevel.ID).ToList();
                if (requirements.Count > 0)
                {
                    header += "\n" + ColorTokenService.Green("Next Upgrade Skill Requirements:\n\n");

                    bool hasRequirement = false;
                    foreach (PerkLevelSkillRequirement req in requirements)
                    {
                        if (req.RequiredRank > 0)
                        {
                            PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), req.SkillID);
                            Skill   skill   = SkillService.GetSkill(pcSkill.SkillID);

                            string detailLine = skill.Name + " Rank " + req.RequiredRank;

                            if (pcSkill.Rank >= req.RequiredRank)
                            {
                                header += ColorTokenService.Green(detailLine) + "\n";
                            }
                            else
                            {
                                header += ColorTokenService.Red(detailLine) + "\n";
                            }

                            hasRequirement = true;
                        }
                    }

                    if (requirements.Count <= 0 || !hasRequirement)
                    {
                        header += "None\n";
                    }
                }
            }

            SetPageHeader("PerkDetailsPage", header);
        }
 public async Task <Skill> Get(string id)
 {
     return(await _skillService.GetSkill(id));
 }