Beispiel #1
0
        private void BuildPerkDetails()
        {
            Model vm = GetDialogCustomData <Model>();

            Data.Entity.Perk perk   = _perk.GetPerkByID(vm.SelectedPerkID);
            PCPerk           pcPerk = _perk.GetPCPerkByID(GetPC().GlobalID, perk.ID);
            Player           player = _player.GetPlayerEntity(GetPC().GlobalID);
            var perkLevels          = _data.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 = _perk.FindPerkLevel(perkLevels, rank);
            PerkLevel nextPerkLevel    = _perk.FindPerkLevel(perkLevels, rank + 1);

            SetResponseVisible("PerkDetailsPage", 1, _perk.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     = _data.Get <PerkCategory>(perk.PerkCategoryID);
            var cooldownCategory = perk.CooldownCategoryID == null ? null : _data.Get <CooldownCategory>(perk.CooldownCategoryID);

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

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

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

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

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

                            hasRequirement = true;
                        }
                    }

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

            SetPageHeader("PerkDetailsPage", header);
        }