示例#1
0
        private void AddVisUseToActionList(Ability ability, ConsideredActions alreadyConsidered, IList <string> log)
        {
            Magus mage = (Magus)Character;
            CharacterAbilityBase magicArt = mage.GetAbility(ability);
            double effectiveDesire        = GetDesirabilityOfIncrease(magicArt.GetValueGain(mage.VisStudyRate));

            if (!double.IsNaN(effectiveDesire) && effectiveDesire > 0)
            {
                // see if the mage has enough vis of this type
                double stockpile = mage.GetVisCount(ability);
                double visNeed   = 0.5 + (magicArt.Value / 10.0);

                // if so, assume vis will return an average of 6XP + aura
                if (stockpile > visNeed)
                {
                    log.Add("Studying vis for " + magicArt.Ability.AbilityName + " worth " + effectiveDesire.ToString("0.000"));
                    VisStudying visStudy = new VisStudying(magicArt.Ability, effectiveDesire);
                    alreadyConsidered.Add(visStudy);
                    // TODO: how do we decrement the cost of the vis?
                }
                // putting a limit here to how far the circular loop will go
                else if (ConditionDepth <= 10)
                {
                    List <Ability> visType = new List <Ability>();
                    visType.Add(magicArt.Ability);
                    // Magus magus, uint ageToCompleteBy, double desire, Ability ability, double totalNeeded, ushort conditionDepth
                    VisCondition visCondition =
                        new VisCondition(mage, AgeToCompleteBy - 1, effectiveDesire, ability, visNeed, (ushort)(ConditionDepth + 1));
                    visCondition.AddActionPreferencesToList(alreadyConsidered, log);
                }
            }
        }
示例#2
0
        public virtual void ModifyActionList(Character character, ConsideredActions alreadyConsidered, IList <string> log)
        {
            if (BaseDueDate != null && BaseDueDate == 0)
            {
                return;
            }
            IEnumerable <IBook> readableBooks = character.ReadableBooks;

            foreach (Ability ability in _abilities)
            {
                // Handle Reading
                CharacterAbilityBase charAbility = character.GetAbility(ability);
                var topicalBooks = readableBooks.Where(b => b.Topic == ability);
                HandleReading(character, alreadyConsidered, topicalBooks);

                // Handle Practice
                if (!MagicArts.IsArt(ability))
                {
                    HandlePractice(character, alreadyConsidered, log, ability);
                }
                else if (character.GetType() == typeof(Magus))
                {
                    Magus mage = (Magus)character;
                    HandleVisUse(mage, charAbility, alreadyConsidered, log);
                }

                // TODO: Learning By Training
                // TODO: Learning by Teaching
            }
        }
示例#3
0
        protected void HandleVisUse(Magus mage, CharacterAbilityBase magicArt, ConsideredActions alreadyConsidered, IList <string> log)
        {
            // see if the mage has enough vis of this type
            double stockpile  = mage.GetVisCount(magicArt.Ability);
            double visNeed    = 0.5 + (magicArt.Value / 10.0);
            double increase   = magicArt.GetValueGain(mage.VisStudyRate);
            double baseDesire = CalculateDesire(increase) / (BaseTier + 1);

            if (BaseDueDate != null)
            {
                baseDesire /= (double)BaseDueDate;
            }
            // if so, assume vis will return an average of 6XP + aura
            if (stockpile > visNeed)
            {
                log.Add("Studying vis for " + magicArt.Ability.AbilityName + " worth " + baseDesire.ToString("0.00"));
                VisStudying visStudy = new VisStudying(magicArt.Ability, baseDesire);
                alreadyConsidered.Add(visStudy);
                // TODO: how do we decrement the cost of the vis?
            }
            // putting a limit here to how far the circular loop will go
            else if (baseDesire >= 0.01)
            {
                List <Ability> visType = new List <Ability>();
                visType.Add(magicArt.Ability);
                VisCondition visCondition =
                    new VisCondition(visType, visNeed - stockpile, baseDesire, (byte)(BaseTier + 1), BaseDueDate == null ? null : BaseDueDate - 1);
                visCondition.ModifyActionList(mage, alreadyConsidered, log);
            }
        }
示例#4
0
        private void AddVisUseToActionList(Ability art, ConsideredActions alreadyConsidered, IList <string> log)
        {
            CharacterAbilityBase magicArt = Mage.GetAbility(art);
            double stockpile = Mage.GetVisCount(art);
            double visNeed   = 0.5 + (magicArt.Value / 10.0);

            // if so, assume vis will return an average of 6XP + aura
            if (stockpile > visNeed)
            {
                double      gain            = magicArt.GetValueGain(Mage.VisStudyRate);
                double      effectiveDesire = _desireFunc(gain, ConditionDepth);
                VisStudying visStudy        = new VisStudying(magicArt.Ability, effectiveDesire);
                alreadyConsidered.Add(visStudy);
                // consider the value of finding a better aura to study vis in
                FindNewAuraHelper auraHelper = new FindNewAuraHelper(Mage, AgeToCompleteBy - 1, Desire, (ushort)(ConditionDepth + 1), AllowVimVisUse, _desireFunc);

                // TODO: how do we decrement the cost of the vis?
            }
        }
示例#5
0
 protected void HandleVisUse(Magus mage, CharacterAbilityBase magicArt, ConsideredActions alreadyConsidered, IList<string> log)
 {
     // see if the mage has enough vis of this type
     double stockpile = mage.GetVisCount(magicArt.Ability);
     double visNeed = 0.5 + (magicArt.Value / 10.0);
     double increase = magicArt.GetValueGain(mage.VisStudyRate);
     double baseDesire = CalculateDesire(increase) / (BaseTier + 1);
     if (BaseDueDate != null)
     {
         baseDesire /= (double)BaseDueDate;
     }
     // if so, assume vis will return an average of 6XP + aura
     if (stockpile > visNeed)
     {
         log.Add("Studying vis for " + magicArt.Ability.AbilityName + " worth " + baseDesire.ToString("0.00"));
         VisStudying visStudy = new VisStudying(magicArt.Ability, baseDesire);
         alreadyConsidered.Add(visStudy);
         // TODO: how do we decrement the cost of the vis?
     }
     // putting a limit here to how far the circular loop will go
     else if (baseDesire >= 0.01)
     {
         List<Ability> visType = new List<Ability>();
         visType.Add(magicArt.Ability);
         VisCondition visCondition =
             new VisCondition(visType, visNeed - stockpile, baseDesire, (byte)(BaseTier + 1), BaseDueDate == null ? null : BaseDueDate - 1);
         visCondition.ModifyActionList(mage, alreadyConsidered, log);
     }
 }
示例#6
0
        private void HandleVisUse(Magus mage, CharacterAbilityBase charAbility, double remainingTotal, double desire, ConsideredActions alreadyConsidered, IList<string> log )
        {
            // see if the mage has enough vis of this type
            double stockpile = mage.GetVisCount(charAbility.Ability);
            double visNeed = 0.5 + (charAbility.Value / 10.0);
            double baseDesire = desire * charAbility.GetValueGain(mage.VisStudyRate) / remainingTotal;
            // if so, assume vis will return an average of 6XP + aura
            if (stockpile > visNeed)
            {
                log.Add("Studying vis for " + charAbility.Ability.AbilityName + " worth " + baseDesire.ToString("0.00"));
                VisStudying visStudy = new VisStudying(charAbility.Ability, baseDesire);
                alreadyConsidered.Add(visStudy);
                // TODO: how do we decrement the cost of the vis?
            }
            else if(baseDesire > 0.01 && (DueDate == null || DueDate > 1))
            {
                // only try to extract the vis now if there's sufficient time to do so
                List<Ability> visType = new List<Ability>();
                visType.Add(charAbility.Ability);
                VisCondition visCondition = new VisCondition(visType, visNeed - stockpile, baseDesire, (byte)(Tier + 1), DueDate == null ? null : DueDate - 1);
                visCondition.ModifyActionList(mage, alreadyConsidered, log);
                if(baseDesire > 0.04 && (DueDate == null || DueDate > 4))
                {
                    // we have enough time and interest to consider finding a new aura and building a new lab in it

                }
            }
        }
示例#7
0
        public static Magus GenerateNewApprentice()
        {
            Magus magus = new Magus(Abilities.MagicTheory, Abilities.Latin, Abilities.ArtesLiberales, Abilities.AreaLore);

            NormalizeAttributes(magus);
            magus.GetAbility(Abilities.English).AddExperience(75);
            // randomly assign 45 points to childhood skills in 5 point blocks
            // Area Lore, Athletics, Awareness, Brawl, Charm, Folk Ken, Guile, Stealth, Survival, Swim
            double experienceBlock           = 5.0;
            CharacterAbilityBase charAbility = null;

            for (byte i = 0; i < 9; i++)
            {
                switch (Die.Instance.RollSimpleDie())
                {
                case 1:
                    charAbility = magus.GetAbility(Abilities.AreaLore);
                    break;

                case 2:
                    charAbility = magus.GetAbility(Abilities.Athletics);
                    break;

                case 3:
                    charAbility = magus.GetAbility(Abilities.Awareness);
                    break;

                case 4:
                    charAbility = magus.GetAbility(Abilities.Brawl);
                    break;

                case 5:
                    charAbility = magus.GetAbility(Abilities.Charm);
                    break;

                case 6:
                    charAbility = magus.GetAbility(Abilities.FolkKen);
                    break;

                case 7:
                    charAbility = magus.GetAbility(Abilities.Guile);
                    break;

                case 8:
                    charAbility = magus.GetAbility(Abilities.Stealth);
                    break;

                case 9:
                    charAbility = magus.GetAbility(Abilities.Survival);
                    break;

                case 10:
                    charAbility = magus.GetAbility(Abilities.Swim);
                    break;
                }
                charAbility.AddExperience(experienceBlock);
            }
            // figure out how much older than 5 the child is
            ushort age = (ushort)(20 + Die.Instance.RollDouble() * 80);

            // add experience for the additional time.
            int extraXP = (age - 20) * 4;
            // for now, lets say 10% chance of academics, 20% of martial
            bool isAcademic = Die.Instance.RollSimpleDie() == 1;
            bool isMartial  = Die.Instance.RollSimpleDie() <= 2;

            DistributeExperience(magus, extraXP, isAcademic, isMartial);

            // TODO: how do we initialize the goals of this new apprentice?
            InitializeApprenticeGoals(magus);

            return(magus);
        }
示例#8
0
        public double RateLifetimeBookValue(IBook book, CharacterAbilityBase charAbility = null)
        {
            if (book.Level == 1000)
            {
                return RateSeasonalExperienceGain(book.Topic, book.Quality);
            }
            if (charAbility == null)
            {
                charAbility = GetAbility(book.Topic);
            }

            if (charAbility.Value > book.Level)
            {
                return 0;
            }

            double expValue = charAbility.GetExperienceUntilLevel(book.Level);
            double bookSeasons = expValue / book.Quality;
            return RateSeasonalExperienceGain(book.Topic, book.Quality) * bookSeasons;
        }
示例#9
0
 public bool CanWriteTractatus(CharacterAbilityBase charAbility)
 {
     return charAbility.GetTractatiiLimit() > GetTractatiiWrittenOnTopic(charAbility.Ability);
 }