Exemple #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);
        }
Exemple #2
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);
 }
Exemple #3
0
        internal RestoShamState(RestoShamState parentState)
        {
            TemporaryBuffs = new List <TemporaryBuff>();
            SpellStates    = new List <SpellState>(parentState.SpellStates.Count);
            TidalWavesBuff = parentState.TidalWavesBuff;
            ManaPool       = parentState.ManaPool;
            FightTime      = parentState.FightTime;

            foreach (SpellState ss in parentState.SpellStates)
            {
                SpellStates.Add(ss.Clone());
            }
        }
Exemple #4
0
 public bool Equals(RestoShamState other)
 {
     return(this._StateId == other._StateId);
 }
Exemple #5
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);
        }