public override bool StackEffect(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (stacks.Count <= 1)
            {
                throw new InvalidOperationException("Queue logic based must have a >1 capacity");
            }
            BuffStackItem first = stacks[0];

            stacks.RemoveAt(0);
            BuffStackItem minItem = stacks.MinBy(x => x.TotalBoonDuration());

            if (minItem.TotalBoonDuration() > stackItem.TotalBoonDuration() + ParserHelper.ServerDelayConstant)
            {
                stacks.Insert(0, first);
                return(false);
            }
            wastes.Add(new BuffSimulationItemWasted(minItem.Src, minItem.Duration, minItem.Start));
            if (minItem.Extensions.Count > 0)
            {
                foreach ((AgentItem src, long value) in minItem.Extensions)
                {
                    wastes.Add(new BuffSimulationItemWasted(src, value, minItem.Start));
                }
            }
            stacks[stacks.IndexOf(minItem)] = stackItem;
            stacks.Insert(0, first);
            Sort(log, stacks);
            return(true);
        }
        public override bool FindLowestValue(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (stacks.Count <= 1)
            {
                throw new InvalidDataException("Queue logic based must have a >1 capacity");
            }
            BuffStackItem first   = stacks[0];
            BuffStackItem minItem = stacks.Where(x => x != first).MinBy(x => x.TotalDuration);

            /*if (minItem.TotalDuration > stackItem.TotalDuration + ParserHelper.BuffSimulatorDelayConstant)
             * {
             *  return false;
             * }*/
            wastes.Add(new BuffSimulationItemWasted(minItem.Src, minItem.Duration, minItem.Start));
            if (minItem.Extensions.Any())
            {
                foreach ((AgentItem src, long value) in minItem.Extensions)
                {
                    wastes.Add(new BuffSimulationItemWasted(src, value, minItem.Start));
                }
            }
            stacks[stacks.IndexOf(minItem)] = stackItem;
            Sort(log, stacks);
            return(true);
        }
        public override bool StackEffect(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (stacks.Count == 0)
            {
                return(false);
            }
            BuffStackItem stack = stacks[0];

            if (stack.TotalBoonDuration() <= stackItem.TotalBoonDuration() + ParserHelper.ServerDelayConstant)
            {
                wastes.Add(new BuffSimulationItemWasted(stack.Src, stack.Duration, stack.Start));
                if (stack.Extensions.Count > 0)
                {
                    foreach ((AgentItem src, long value) in stack.Extensions)
                    {
                        wastes.Add(new BuffSimulationItemWasted(src, value, stack.Start));
                    }
                }
                stacks[0] = stackItem;
                Sort(log, stacks);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        protected void Add(long duration, AgentItem src, AgentItem seedSrc, long time, bool atFirst, bool isExtension)
        {
            var toAdd = new BuffStackItem(time, duration, src, seedSrc, isExtension);

            // Find empty slot
            if (!IsFull)
            {
                if (atFirst)
                {
                    BuffStack.Insert(0, toAdd);
                }
                else
                {
                    _logic.Add(Log, BuffStack, toAdd);
                }
            }
            // Replace lowest value
            else
            {
                bool found = _logic.StackEffect(Log, toAdd, BuffStack, WasteSimulationResult);
                if (!found)
                {
                    OverstackSimulationResult.Add(new BuffSimulationItemOverstack(src, duration, time));
                }
            }
        }
Ejemplo n.º 5
0
        public override bool FindLowestValue(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (!stacks.Any())
            {
                return(false);
            }
            BuffStackItem stack = stacks[0];

            //if (stack.TotalDuration <= stackItem.TotalDuration + ParserHelper.BuffSimulatorDelayConstant)
            //{
            wastes.Add(new BuffSimulationItemWasted(stack.Src, stack.Duration, stack.Start));
            if (stack.Extensions.Count > 0)
            {
                foreach ((AgentItem src, long value) in stack.Extensions)
                {
                    wastes.Add(new BuffSimulationItemWasted(src, value, stack.Start));
                }
            }
            stacks.RemoveAt(0);
            Add(log, stacks, stackItem);
            return(true);
            //}
            //else
            //{
            //    return false;
            //}
        }
 protected internal BuffSimulationItemBase(BuffStackItem buffStackItem) : base(buffStackItem.Start, buffStackItem.Duration)
 {
     _src              = buffStackItem.Src;
     _seedSrc          = buffStackItem.SeedSrc;
     _isExtension      = buffStackItem.IsExtension;
     _originalDuration = buffStackItem.Duration;
 }
        public override void Extend(long extension, long oldValue, AgentItem src, long time, uint stackID)
        {
            BuffStackItem toExtend = BuffStack.FirstOrDefault(x => x.StackID == stackID);

            if (toExtend == null)
            {
                throw new EIBuffSimulatorIDException("Extend has failed");
            }
            toExtend.Extend(extension, src);
        }
Ejemplo n.º 8
0
        public override void Add(long duration, AgentItem src, long start, uint stackID, bool addedActive, uint overstackDuration)
        {
            var toAdd = new BuffStackItem(start, duration, src, stackID);

            BuffStack.Add(toAdd);
            //AddedSimulationResult.Add(new BuffCreationItem(src, duration, start, toAdd.ID));
            if (overstackDuration > 0)
            {
                OverrideCandidates.Add((overstackDuration, src));
            }
        }
Ejemplo n.º 9
0
        public override void Add(ParsedEvtcLog log, List <BuffStackItem> stacks, BuffStackItem stackItem)
        {
            if (!stacks.Any())
            {
                stacks.Add(stackItem);
                return;
            }
            int insertIndex = BinarySearchRecursive(stacks, stackItem.TotalDuration, 0, stacks.Count - 1);

            if (insertIndex > stacks.Count - 1)
            {
                stacks.Add(stackItem);
            }
            else
            {
                stacks.Insert(insertIndex, stackItem);
            }
        }
Ejemplo n.º 10
0
        public override void Add(long duration, AgentItem src, long start, uint stackID, bool addedActive, uint overstackDuration)
        {
            var toAdd = new BuffStackItem(start, duration, src);

            // Find empty slot
            if (!IsFull)
            {
                _logic.Add(Log, BuffStack, toAdd);
            }
            // Replace lowest value
            else
            {
                if (!_logic.FindLowestValue(Log, toAdd, BuffStack, WasteSimulationResult))
                {
                    OverstackSimulationResult.Add(new BuffSimulationItemOverstack(src, duration, start));
                }
            }
        }
        public override void Remove(AgentItem by, long removedDuration, int removedStacks, long time, ArcDPSEnums.BuffRemove removeType, uint id)
        {
            switch (removeType)
            {
            case ArcDPSEnums.BuffRemove.All:
                foreach (BuffStackItem stackItem in BuffStack)
                {
                    WasteSimulationResult.Add(new BuffSimulationItemWasted(stackItem.Src, stackItem.Duration, time));
                    if (stackItem.Extensions.Count > 0)
                    {
                        foreach ((AgentItem src, long value) in stackItem.Extensions)
                        {
                            WasteSimulationResult.Add(new BuffSimulationItemWasted(src, value, time));
                        }
                    }
                }
                BuffStack.Clear();
                break;

            case ArcDPSEnums.BuffRemove.Single:
                for (int i = 0; i < BuffStack.Count; i++)
                {
                    BuffStackItem stackItem = BuffStack[i];
                    if (Math.Abs(removedDuration - stackItem.TotalBoonDuration()) < ParserHelper.ServerDelayConstant)
                    {
                        WasteSimulationResult.Add(new BuffSimulationItemWasted(stackItem.Src, stackItem.Duration, time));
                        if (stackItem.Extensions.Count > 0)
                        {
                            foreach ((AgentItem src, long value) in stackItem.Extensions)
                            {
                                WasteSimulationResult.Add(new BuffSimulationItemWasted(src, value, time));
                            }
                        }
                        BuffStack.RemoveAt(i);
                        break;
                    }
                }
                break;

            default:
                break;
            }
            _logic.Sort(Log, BuffStack);
        }
        public override bool StackEffect(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (!stacks.Any())
            {
                return(false);
            }
            BuffStackItem stack = stacks[0];

            wastes.Add(new BuffSimulationItemWasted(stack.Src, stack.Duration, stack.Start));
            if (stack.Extensions.Count > 0)
            {
                foreach ((AgentItem src, long value) in stack.Extensions)
                {
                    wastes.Add(new BuffSimulationItemWasted(src, value, stack.Start));
                }
            }
            stacks[0] = stackItem;
            return(true);
        }
        public override void Add(long duration, AgentItem src, long start, uint id, bool addedActive, uint overstackDuration)
        {
            var toAdd = new BuffStackItem(start, duration, src, ++ID);

            // Find empty slot
            if (BuffStack.Count < Capacity)
            {
                BuffStack.Add(toAdd);
                _logic.Sort(Log, BuffStack);
            }
            // Replace lowest value
            else
            {
                bool found = _logic.StackEffect(Log, toAdd, BuffStack, WasteSimulationResult);
                if (!found)
                {
                    OverstackSimulationResult.Add(new BuffSimulationItemOverstack(src, duration, start));
                }
            }
        }
 protected override void Update(long timePassed)
 {
     if (BuffStack.Count > 0 && timePassed > 0 && _activeStack != null)
     {
         var toAdd = new BuffSimulationItemDuration(_activeStack);
         GenerationSimulation.Add(toAdd);
         long timeDiff = _activeStack.Duration - timePassed;
         long diff;
         long leftOver = 0;
         if (timeDiff < 0)
         {
             diff     = _activeStack.Duration;
             leftOver = timePassed - diff;
         }
         else
         {
             diff = timePassed;
         }
         if (toAdd.End > toAdd.Start + diff)
         {
             toAdd.OverrideEnd(toAdd.Start + diff);
         }
         BuffStackItem oldActive = _activeStack;
         _activeStack.Shift(diff, diff);
         for (int i = 0; i < BuffStack.Count; i++)
         {
             if (BuffStack[i] != oldActive)
             {
                 BuffStack[i].Shift(diff, 0);
             }
         }
         // that means the stack was not an extension, extend duration to match time passed
         if (_activeStack.Duration == 0)
         {
             _activeStack.Shift(0, -leftOver);
         }
         Update(leftOver);
     }
 }
 public abstract bool FindLowestValue(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes);
        public override void Activate(uint stackID)
        {
            BuffStackItem active = BuffStack.Find(x => x.StackID == stackID);

            _activeStack = active ?? throw new InvalidOperationException("Activate has failed");
        }
 public abstract bool StackEffect(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes);
 public virtual void Add(ParsedEvtcLog log, List <BuffStackItem> stacks, BuffStackItem stackItem)
 {
     stacks.Add(stackItem);
     Sort(log, stacks);
 }
 private static uint GetHealing(BuffStackItem stack)
 {
     return(stack.SeedSrc.Healing);
 }
 public static int Compare(BuffStackItem x, BuffStackItem y)
 {
     return(-GetHealing(x).CompareTo(GetHealing(y)));
 }
Ejemplo n.º 21
0
 public override bool FindLowestValue(ParsedEvtcLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
 {
     // no lowest value to find
     return(false);
 }
Ejemplo n.º 22
0
        public override void Remove(AgentItem by, long removedDuration, int removedStacks, long time, ArcDPSEnums.BuffRemove removeType, uint stackID)
        {
            BuffStackItemID toRemove;

            switch (removeType)
            {
            case ArcDPSEnums.BuffRemove.All:
                // remove all due to despawn event
                if (removedStacks == BuffRemoveAllEvent.FullRemoval)
                {
                    BuffStack.Clear();
                    return;
                }
                if (BuffStack.Count != 1)
                {
                    if (BuffStack.Count < removedStacks)
                    {
                        //removedStacks = BuffStack.Count;
                        throw new EIBuffSimulatorIDException("Remove all failed");
                    }
                    // buff cleanse all
                    for (int i = 0; i < removedStacks; i++)
                    {
                        BuffStackItem stackItem = BuffStack[i];
                        WasteSimulationResult.Add(new BuffSimulationItemWasted(stackItem.Src, stackItem.Duration, time));
                        if (stackItem.Extensions.Any())
                        {
                            foreach ((AgentItem src, long value) in stackItem.Extensions)
                            {
                                WasteSimulationResult.Add(new BuffSimulationItemWasted(src, value, time));
                            }
                        }
                    }
                    BuffStack = BuffStack.GetRange(removedStacks, BuffStack.Count - removedStacks);
                    return;
                }
                toRemove = BuffStack[0];
                break;

            case ArcDPSEnums.BuffRemove.Single:
                toRemove = BuffStack.FirstOrDefault(x => x.StackID == stackID);
                break;

            default:
                throw new InvalidDataException("Unknown remove type");
            }
            if (toRemove == null)
            {
                //return;
                throw new EIBuffSimulatorIDException("Remove has failed");
            }
            BuffStack.Remove(toRemove);
            if (removedDuration > ParserHelper.BuffSimulatorDelayConstant)
            {
                // safe checking, this can happen when an inactive stack is being removed but it was actually active
                if (Math.Abs(removedDuration - toRemove.TotalDuration) > ParserHelper.BuffSimulatorDelayConstant && !toRemove.Active)
                {
                    toRemove.Activate();
                    toRemove.Shift(0, Math.Abs(removedDuration - toRemove.TotalDuration));
                }
                // Removed due to override
                //(long duration, AgentItem src)? candidate = OverrideCandidates.FirstOrDefault(x => Math.Abs(x.duration - removedDuration) < ParserHelper.BuffSimulatorDelayConstant);
                if (by == ParserHelper._unknownAgent)
                {
                    //(long duration, AgentItem candSrc) = candidate.Value;
                    //OverrideCandidates.Remove(candidate.Value);
                    WasteSimulationResult.Add(new BuffSimulationItemWasted(toRemove.Src, toRemove.Duration, time));
                    if (toRemove.Extensions.Any())
                    {
                        foreach ((AgentItem src, long value) in toRemove.Extensions)
                        {
                            WasteSimulationResult.Add(new BuffSimulationItemWasted(src, value, time));
                        }
                    }
                }
                // Removed due to a cleanse
                else
                {
                    WasteSimulationResult.Add(new BuffSimulationItemWasted(toRemove.Src, toRemove.Duration, time));
                    if (toRemove.Extensions.Any())
                    {
                        foreach ((AgentItem src, long value) in toRemove.Extensions)
                        {
                            WasteSimulationResult.Add(new BuffSimulationItemWasted(src, value, time));
                        }
                    }
                }
            }
        }
 public BuffSimulationItemDuration(BuffStackItem other) : base(other.Start, other.Duration)
 {
     _src         = other.Src;
     _seedSrc     = other.SeedSrc;
     _isExtension = other.IsExtension;
 }