Exemplo n.º 1
0
 /// <summary>
 /// Sets the skill to trained status for a character
 /// </summary>
 /// <param name="skill"></param>
 public bool TrainSkill(Skill skill, uint creditsSpent)
 {
     if (Skills[skill].Status != SkillStatus.Trained && Skills[skill].Status != SkillStatus.Specialized)
     {
         if (PropertiesInt[PropertyInt.AvailableSkillCredits] >= creditsSpent)
         {
             Skills[skill]         = new CharacterSkill(this, skill, SkillStatus.Trained, 0, 0);
             AvailableSkillCredits = PropertiesInt[PropertyInt.AvailableSkillCredits] - creditsSpent;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
Arquivo: Player.cs Projeto: sr314/ACE
        /// <summary>
        /// spends the xp on this skill.
        /// </summary>
        /// <remarks>
        ///     Known Issues:
        ///         1. +10 skill throws an exception when it would go outside the bounds of ranks list
        ///         2. the client doesn't increase the "next point" amount properly when using +10
        ///         3. no fireworks for hitting max ranks
        /// </remarks>
        /// <returns>0 if it failed, total investment of the next rank if successful</returns>
        private uint SpendSkillXp(CharacterSkill skill, uint amount)
        {
            uint result = 0u;
            ExperienceExpenditureChart chart;

            if (skill.Status == SkillStatus.Trained)
            {
                chart = DatabaseManager.Charts.GetTrainedSkillXpChart();
            }
            else if (skill.Status == SkillStatus.Specialized)
            {
                chart = DatabaseManager.Charts.GetSpecializedSkillXpChart();
            }
            else
            {
                return(result);
            }

            uint rankUps   = 0u;
            uint currentXp = chart.Ranks[Convert.ToInt32(skill.Ranks)].TotalXp;
            uint rank1     = chart.Ranks[Convert.ToInt32(skill.Ranks) + 1].XpFromPreviousRank;
            // TODO this crashes if you try to raise your skill too high
            uint rank10 = chart.Ranks[Convert.ToInt32(skill.Ranks) + 10].TotalXp - chart.Ranks[Convert.ToInt32(skill.Ranks)].TotalXp;

            if (amount == rank1)
            {
                rankUps = 1u;
            }
            else if (amount == rank10)
            {
                rankUps = 10u;
            }

            if (rankUps > 0)
            {
                skill.Ranks           += rankUps;
                skill.ExperienceSpent += amount;
                this.character.SpendXp(amount);
                result = skill.ExperienceSpent;
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// spends the xp on this skill.
        /// </summary>
        /// <returns>0 if it failed, total investment of the next rank if successful</returns>
        private uint SpendSkillXp(CharacterSkill skill, uint amount)
        {
            uint result = 0u;
            ExperienceExpenditureChart chart;

            if (skill.Status == SkillStatus.Trained)
            {
                chart = DatabaseManager.Charts.GetTrainedSkillXpChart();
            }
            else if (skill.Status == SkillStatus.Specialized)
            {
                chart = DatabaseManager.Charts.GetSpecializedSkillXpChart();
            }
            else
            {
                return(result);
            }

            //do not advance if we cannot spend xp to rank up our skill by 1 point
            if (skill.Ranks >= (chart.Ranks.Count - 1))
            {
                return(result);
            }

            uint rankUps      = 0u;
            uint currentXp    = chart.Ranks[Convert.ToInt32(skill.Ranks)].TotalXp;
            uint rank1        = chart.Ranks[Convert.ToInt32(skill.Ranks) + 1].XpFromPreviousRank;
            uint rank10       = 0u;
            int  rank10Offset = 0;

            if (skill.Ranks + 10 >= (chart.Ranks.Count))
            {
                rank10Offset = 10 - (Convert.ToInt32(skill.Ranks + 10) - (chart.Ranks.Count - 1));
                rank10       = chart.Ranks[Convert.ToInt32(skill.Ranks) + rank10Offset].TotalXp - chart.Ranks[Convert.ToInt32(skill.Ranks)].TotalXp;
            }
            else
            {
                rank10 = chart.Ranks[Convert.ToInt32(skill.Ranks) + 10].TotalXp - chart.Ranks[Convert.ToInt32(skill.Ranks)].TotalXp;
            }

            if (amount == rank1)
            {
                rankUps = 1u;
            }
            else if (amount == rank10)
            {
                if (rank10Offset > 0u)
                {
                    rankUps = Convert.ToUInt32(rank10Offset);
                }
                else
                {
                    rankUps = 10u;
                }
            }

            if (rankUps > 0)
            {
                skill.Ranks           += rankUps;
                skill.ExperienceSpent += amount;
                this.character.SpendXp(amount);
                result = skill.ExperienceSpent;
            }

            return(result);
        }