Example #1
0
        private State <Spell> CastSpell(RestoShamState restoState, SpellState ss)
        {
            RestoShamState next = new RestoShamState(restoState);

            next.CastSpell(ss.TrackedSpell.SpellId, _MP5);
            next.GenerateStateName();

            lock (_TargetStates)
            {
                //if (ss.TrackedSpell.SpellId == 1)
                //{
                RestoShamState existing = _TargetStates.FirstOrDefault(i => i.Name == next.Name);
                if (existing != null)
                {
                    return(existing);
                }
                _TargetStates.Add(next);
                //}
            }
            // Does this state already exist?

            /*lock (_TargetStates)
             * {
             *  foreach (RestoShamState rss in _TargetStates.Where(i => i.TidalWavesBuff == next.TidalWavesBuff && i.TemporaryBuffs.Count == next.TemporaryBuffs.Count && i.ManaPool == next.ManaPool && i.FightTime == next.FightTime))
             *  {
             *      if (rss.StatesMatch(next))
             *          return rss;
             *  }
             *  _TargetStates.Add(next);
             * }*/
            return(next);
        }
Example #2
0
        public SpellState Clone()
        {
            SpellState clone = new SpellState(TrackedSpell, Priority);

            clone._ActiveOnTarget = _ActiveOnTarget;
            clone._Cooldown       = _Cooldown;
            return(clone);
        }
Example #3
0
 internal bool StatesMatch(RestoShamState other)
 {
     foreach (SpellState ss in GetPrioritySpellStates())
     {
         SpellState st = other.GetSpellState(ss.TrackedSpell.SpellId);
         if (st != ss)
         {
             return(false);
         }
     }
     return(true);
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StateGenerator"/> class.
        /// </summary>
        public StateGenerator(List <Spell> availableSpells, SequenceType sequence, float totalMana, float mp5)
            : base()
        {
            if (availableSpells == null)
            {
                throw new ArgumentNullException("availableSpells");
            }

            _AvailableSpells = availableSpells;
            _TargetStates    = new List <RestoShamState>();
            _SequenceType    = sequence;
            _ManaPool        = Convert.ToInt32(totalMana);
            _MP5             = Convert.ToInt32(mp5);
            _NoOp.Calculate();
            _NoOpState = new SpellState(_NoOp, (byte)_AvailableSpells.Count);
        }
Example #5
0
        private Spell GetModifiedSpell(SpellState castSpell)
        {
            Spell spellCastObject = castSpell.TrackedSpell.Clone();

            if (spellCastObject.ConsumesTidalWaves && TidalWavesBuff > 0)
            {
                if (spellCastObject.TidalWavesBuff.Stats.SpellHaste > 0f)
                {
                    spellCastObject.CastTimeReduction += (spellCastObject.TidalWavesBuff.Stats.SpellHaste * spellCastObject.CastTime);
                }
                else if (spellCastObject.TidalWavesBuff.Stats.SpellCrit > 0f)
                {
                    spellCastObject.CritRateModifier += spellCastObject.TidalWavesBuff.Stats.SpellCrit;
                }

                spellCastObject.Calculate();
            }
            return(spellCastObject);
        }
Example #6
0
        internal Spell GetModifiedSpell(int spellId)
        {
            SpellState castSpell = GetSpellState(spellId);

            return(GetModifiedSpell(castSpell));
        }
Example #7
0
        protected override List <StateTransition <Spell> > GetStateTransitions(State <Spell> state)
        {
            RestoShamState restoState = state as RestoShamState;
            List <StateTransition <Spell> > transitions   = new List <StateTransition <Spell> >();
            StateTransition <Spell>         nopTransition = new StateTransition <Spell>()
            {
                Ability = _NoOp,
                TransitionProbability = 1d,
                TransitionDuration    = _NoOp.CastTime,
                TargetState           = CastSpell(restoState, _NoOpState)
            };

            lock (state)
            {
                bool spellCast = false;

                if (restoState.FightTime > 120f)
                {
                    State <Spell> ss = GetInitialState();
                    spellCast = true;
                    transitions.Add(new StateTransition <Spell>()
                    {
                        Ability = _NoOpState.TrackedSpell,
                        TransitionProbability = 1d,
                        TransitionDuration    = 0f,
                        TargetState           = ss
                    });
                }

                if (!spellCast && restoState.ManaPool <= _AvailableSpells.Min(i => i.ManaCost))
                {
                    SpellState ss = restoState.SpellStates.FirstOrDefault(i => i.TrackedSpell.ManaBack > i.TrackedSpell.ManaCost);
                    if (ss != null)
                    {
                        spellCast = true;
                        transitions.Add(new StateTransition <Spell>()
                        {
                            Ability = ss.TrackedSpell,
                            TransitionProbability = 1d,
                            TransitionDuration    = ss.TrackedSpell.CastTime,
                            TargetState           = CastSpell(restoState, ss)
                        });
                    }
                    else
                    {
                        spellCast = true;
                        transitions.Add(nopTransition);
                    }
                }

                if (!spellCast)
                {
                    foreach (SpellState ss in restoState.GetPrioritySpellStates())
                    {
                        if (!ss.IsActive && !ss.IsOnCooldown)
                        {
                            // cast this spell
                            spellCast = true;
                            transitions.Add(new StateTransition <Spell>()
                            {
                                Ability = ss.TrackedSpell,
                                TransitionProbability = 1d,
                                TransitionDuration    = ss.TrackedSpell.CastTime,
                                TargetState           = CastSpell(restoState, ss)
                            });
                            break;
                        }
                    }
                }

                if (!spellCast)
                {
                    IEnumerable <SpellState> states   = restoState.GetNonPrioritySpellStates();
                    IEnumerable <SpellState> twStates = states.Where(i => i.TrackedSpell.ConsumesTidalWaves);
                    if (restoState.TidalWavesBuff > 0 && twStates.Count() > 0)
                    {
                        SpellState ss = null;
                        if (_SequenceType == SequenceType.Burst)
                        {
                            ss = twStates.OrderByDescending(i => i.TrackedSpell.EPS).First();
                        }
                        else
                        {
                            ss = twStates.OrderByDescending(i => i.TrackedSpell.EPM).First();
                        }

                        transitions.Add(new StateTransition <Spell>()
                        {
                            Ability = ss.TrackedSpell,
                            TransitionProbability = 1d,
                            TransitionDuration    = ss.TrackedSpell.CastTime,
                            TargetState           = CastSpell(restoState, ss)
                        });
                    }
                    else if (states.Count() > 0)
                    {
                        SpellState ss = null;
                        if (_SequenceType == SequenceType.Burst)
                        {
                            ss = states.OrderByDescending(i => i.TrackedSpell.EPS).First();
                        }
                        else
                        {
                            ss = states.OrderByDescending(i => i.TrackedSpell.EPM).First();
                        }

                        transitions.Add(new StateTransition <Spell>()
                        {
                            Ability = ss.TrackedSpell,
                            TransitionProbability = 1d,
                            TransitionDuration    = ss.TrackedSpell.CastTime,
                            TargetState           = CastSpell(restoState, ss)
                        });
                    }
                    else
                    {
                        spellCast = true;
                        transitions.Add(nopTransition);
                    }
                    int transitionCount = transitions.Count;
                    if (transitionCount > 1)
                    {
                        transitions.ForEach(i => i.TransitionProbability = (double)(1d / (double)transitionCount));
                    }
                }
            }

            return(transitions);
        }
Example #8
0
 public SpellState Clone()
 {
     SpellState clone = new SpellState(TrackedSpell, Priority);
     clone._ActiveOnTarget = _ActiveOnTarget;
     clone._Cooldown = _Cooldown;
     return clone;
 }