Пример #1
0
        private void AddNewTalentOrIncreaseLevelOfExistingTalent(Talent newTalent)
        {
            if (!InvestedTalents.Contains(newTalent))
            {
                InvestedTalents.Add(newTalent);
            }

            /*Reference thing. Don't need the actual Talent stored in the InvestedTalents list to pull the
             * stat increases and putting nowInvestedTalent back into the list is a waste of time
             *
             * todo - maybe figure out how to store nowInvestedTalent as a pointer to the list item
             */
            InvestedTalents.Where(x => x.Profile.Name == newTalent.Profile.Name).First().LevelUp();

            var nowInvestedTalent = InvestedTalents.Where(x => x.Profile.Name == newTalent.Profile.Name).First();


            foreach (var increase in nowInvestedTalent.GetStatIncreaseForLevel(nowInvestedTalent.Profile.CurrentLevel))
            {
                AddStatIncreaseToCharacterAndRecords(increase);
            }

            InvestMoney(newTalent.CostsAtLevel(newTalent.Profile.CurrentLevel));
        }
Пример #2
0
        public void AddTalent(Talent potentialTalent)
        {
            Talent playersTalent;

            if (!ApprovedTalents.Contains(potentialTalent))
            {
                throw new PlayerDoesNotHaveTalent(potentialTalent.Profile.Name + " is not an approved talent for " + this.CharacterStat.Name);
            }
            else if (PlayerAlreadyHaveTalent(potentialTalent))
            {
                playersTalent = InvestedTalents.Where(x => x.Profile.Name == potentialTalent.Profile.Name).First();
            }
            else
            {
                playersTalent = potentialTalent;
            }


            if (PlayerCanAffordCost(playersTalent.CostsAtLevel(playersTalent.Profile.CurrentLevel + 1)))
            {
                AddNewTalentOrIncreaseLevelOfExistingTalent(potentialTalent);
            }
            else
            {
                throw new NotEnoughMoneyToInvest(potentialTalent.Profile.Name + " costs " + potentialTalent.CostsAtLevel(playersTalent.Profile.CurrentLevel + 1));
            }
        }