Exemplo n.º 1
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
            }
        }
Exemplo n.º 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
            }
        }
Exemplo n.º 3
0
        public void ModifyActionList(Magus mage, ConsideredActions alreadyConsidered, IList <string> log)
        {
            double dueDateDesire = _desirePerPoint / (Tier + 1);

            if (DueDate != null)
            {
                if (DueDate == 0)
                {
                    log.Add("Has Covenant Condition failed");
                    return;
                }
                dueDateDesire /= (double)DueDate;
            }

            double currentAura = mage.Covenant.Aura.Strength;
            double auraCount   = mage.KnownAuras.Count;
            double areaLore    = mage.GetAbility(Abilities.AreaLore).Value;

            areaLore += mage.GetCastingTotal(MagicArtPairs.InVi) / 10;
            areaLore += mage.GetAttribute(AttributeType.Perception).Value;
            double probOfBetter = 1 - (currentAura * currentAura * auraCount / (5 * areaLore));
            double maxAura      = Math.Sqrt(5.0 * areaLore / auraCount);
            double averageGain  = maxAura * probOfBetter / 2.0;

            if (probOfBetter > 0)
            {
                double desire = dueDateDesire * averageGain;
                log.Add("Finding a better aura to build a lab in worth " + desire.ToString("0.00"));
                alreadyConsidered.Add(new FindAura(Abilities.AreaLore, desire));
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        private void HandleAuras(Magus mage, ConsideredActions alreadyConsidered, IList <string> log)
        {
            double greatestAura = mage.KnownAuras.Select(a => a.Strength).Max();
            double currentAura  = mage.Covenant.Aura.Strength;

            if (greatestAura > currentAura)
            {
                Aura bestAura = mage.KnownAuras.Where(a => a.Strength == greatestAura).First();
                if (mage.Laboratory == null)
                {
                    // just move the covenant right now
                    log.Add("Since no lab built, moving to better aura.");
                    mage.FoundCovenant(bestAura);
                }
                else
                {
                    // how do we want to rate the value of moving and having to build a new lab?
                    // it seems like basically the same as any other single-season activity
                    double gain          = greatestAura - currentAura;
                    double dueDateDesire = CalculateDesire(gain) / (BaseTier + 1);
                    if (BaseDueDate != null)
                    {
                        if (BaseDueDate == 0)
                        {
                            return;
                        }
                        dueDateDesire /= (double)(BaseDueDate - 1);
                    }
                    log.Add("Moving to new aura (to boost lab total) worth " + dueDateDesire.ToString("0.00"));
                    alreadyConsidered.Add(new BuildLaboratory(bestAura, Abilities.MagicTheory, dueDateDesire));
                }
            }
            else
            {
                double auraCount = mage.KnownAuras.Count;
                double areaLore  = mage.GetAbility(Abilities.AreaLore).Value;
                areaLore += mage.GetCastingTotal(MagicArtPairs.InVi) / 10;
                areaLore += mage.GetAttribute(AttributeType.Perception).Value;
                double probOfBetter = 1 - (currentAura * currentAura * auraCount / (5 * areaLore));
                double maxAura      = Math.Sqrt(5.0 * areaLore / auraCount);
                double averageGain  = maxAura * probOfBetter / 2.0;

                double dueDateDesire = CalculateDesire(averageGain) / (BaseTier + 1);
                if (BaseDueDate != null)
                {
                    if (BaseDueDate == 0)
                    {
                        return;
                    }
                    dueDateDesire /= (double)(BaseDueDate - 1);
                }

                if (probOfBetter > 0)
                {
                    log.Add("Finding a better aura to build a lab in worth " + dueDateDesire.ToString("0.00"));
                    alreadyConsidered.Add(new FindAura(Abilities.AreaLore, dueDateDesire));
                }
            }
        }
Exemplo n.º 6
0
        protected void HandlePractice(Character character, ConsideredActions alreadyConsidered, IList <string> log, Ability ability)
        {
            // Handle Practice
            // For now, assume 4pt practice on everything
            // after lots of math, the right equation is:
            // Desire * (labTotal + increase)/(labTotal + increase + level)
            double increase = character.GetAbility(ability).GetValueGain(4);
            double desire   = CalculateDesire(increase) / (BaseTier + 1);

            if (BaseDueDate != null)
            {
                desire /= (double)BaseDueDate;
            }
            Practice practiceAction = new Practice(ability, desire);

            log.Add("Practicing " + ability.AbilityName + " worth " + (desire).ToString("0.00"));
            alreadyConsidered.Add(practiceAction);
        }
Exemplo n.º 7
0
        protected void HandleReading(Character character, ConsideredActions alreadyConsidered, IEnumerable <IBook> topicalBooks)
        {
            if (topicalBooks.Any())
            {
                var bestBook =
                    (from book in topicalBooks
                     orderby character.GetBookLevelGain(book),
                     book.Level ascending
                     select book).First();
                double increase = character.GetBookLevelGain(bestBook);
                double desire   = CalculateDesire(increase) / (BaseTier + 1);
                if (BaseDueDate != null)
                {
                    desire /= (double)BaseDueDate;
                }

                Reading readingAction = new Reading(bestBook, desire);
                alreadyConsidered.Add(readingAction);
            }
        }
Exemplo n.º 8
0
 protected void HandlePractice(Character character, ConsideredActions alreadyConsidered, IList<string> log, Ability ability)
 {
     // Handle Practice
     // For now, assume 4pt practice on everything
     // after lots of math, the right equation is:
     // Desire * (labTotal + increase)/(labTotal + increase + level)
     double increase = character.GetAbility(ability).GetValueGain(4);
     double desire = CalculateDesire(increase) / (BaseTier + 1);
     if (BaseDueDate != null)
     {
         desire /= (double)BaseDueDate;
     }
     Practice practiceAction = new Practice(ability, desire);
     log.Add("Practicing " + ability.AbilityName + " worth " + (desire).ToString("0.00"));
     alreadyConsidered.Add(practiceAction);
 }
Exemplo n.º 9
0
        private void HandleAuras(Magus mage, ConsideredActions alreadyConsidered, IList<string> log)
        {
            double greatestAura = mage.KnownAuras.Select(a => a.Strength).Max();
            double currentAura = mage.Covenant.Aura.Strength;
            if (greatestAura > currentAura)
            {
                Aura bestAura = mage.KnownAuras.Where(a => a.Strength == greatestAura).First();
                if (mage.Laboratory == null)
                {
                    // just move the covenant right now
                    log.Add("Since no lab built, moving to better aura.");
                    mage.FoundCovenant(bestAura);
                }
                else
                {
                    // how do we want to rate the value of moving and having to build a new lab?
                    // it seems like basically the same as any other single-season activity
                    double gain = greatestAura - currentAura;
                    double dueDateDesire = CalculateDesire(gain) / (BaseTier + 1);
                    if (BaseDueDate != null)
                    {
                        if (BaseDueDate == 0)
                        {
                            return;
                        }
                        dueDateDesire /= (double)(BaseDueDate - 1);
                    }
                    log.Add("Moving to new aura (to boost lab total) worth " + dueDateDesire.ToString("0.00"));
                    alreadyConsidered.Add(new BuildLaboratory(bestAura, Abilities.MagicTheory, dueDateDesire));
                }
            }
            else
            {
                double auraCount = mage.KnownAuras.Count;
                double areaLore = mage.GetAbility(Abilities.AreaLore).Value;
                areaLore += mage.GetCastingTotal(MagicArtPairs.InVi) / 10;
                areaLore += mage.GetAttribute(AttributeType.Perception).Value;
                double probOfBetter = 1 - (currentAura * currentAura * auraCount / (5 * areaLore));
                double maxAura = Math.Sqrt(5.0 * areaLore / auraCount);
                double averageGain = maxAura * probOfBetter / 2.0;

                double dueDateDesire = CalculateDesire(averageGain) / (BaseTier + 1);
                if (BaseDueDate != null)
                {
                    if (BaseDueDate == 0)
                    {
                        return;
                    }
                    dueDateDesire /= (double)(BaseDueDate - 1);
                }

                if (probOfBetter > 0)
                {
                    log.Add("Finding a better aura to build a lab in worth " + dueDateDesire.ToString("0.00"));
                    alreadyConsidered.Add(new FindAura(Abilities.AreaLore, dueDateDesire));
                }
            }
        }
Exemplo n.º 10
0
        public void ModifyActionList(Magus mage, ConsideredActions alreadyConsidered, IList<string> log)
        {
            double dueDateDesire = _desirePerPoint / (Tier + 1);
            if (DueDate != null)
            {
                if (DueDate == 0)
                {
                    log.Add("Has Covenant Condition failed");
                    return;
                }
                dueDateDesire /= (double)DueDate;
            }

            double currentAura = mage.Covenant.Aura.Strength;
            double auraCount = mage.KnownAuras.Count;
            double areaLore = mage.GetAbility(Abilities.AreaLore).Value;
            areaLore += mage.GetCastingTotal(MagicArtPairs.InVi) / 10;
            areaLore += mage.GetAttribute(AttributeType.Perception).Value;
            double probOfBetter = 1 - (currentAura * currentAura * auraCount / (5 * areaLore));
            double maxAura = Math.Sqrt(5.0 * areaLore / auraCount);
            double averageGain = maxAura * probOfBetter / 2.0;

            if (probOfBetter > 0)
            {
                double desire = dueDateDesire * averageGain;
                log.Add("Finding a better aura to build a lab in worth " + desire.ToString("0.00"));
                alreadyConsidered.Add(new FindAura(Abilities.AreaLore, desire));
            }
        }
Exemplo n.º 11
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);
     }
 }
Exemplo n.º 12
0
        protected void HandleReading(Character character, ConsideredActions alreadyConsidered, IEnumerable<IBook> topicalBooks)
        {
            if (topicalBooks.Any())
            {
                var bestBook =
                    (from book in topicalBooks
                     orderby character.GetBookLevelGain(book),
                             book.Level ascending
                     select book).First();
                double increase = character.GetBookLevelGain(bestBook);
                double desire = CalculateDesire(increase) / (BaseTier + 1);
                if (BaseDueDate != null)
                {
                    desire /= (double)BaseDueDate;
                }

                Reading readingAction = new Reading(bestBook, desire);
                alreadyConsidered.Add(readingAction);
            }
        }