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); }
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); }