public override bool StackEffect(ParsedLog 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() + GeneralHelper.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 StackEffect(ParsedLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (stacks.Count == 0)
            {
                return(false);
            }
            BuffStackItem stack = stacks[0];

            if (stack.TotalBoonDuration() <= stackItem.TotalBoonDuration() + GeneralHelper.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);
            }
        }
Exemplo n.º 3
0
        protected void Add(long duration, AgentItem src, AgentItem seedSrc, long time, bool atFirst, bool isExtension)
        {
            var toAdd = new BuffStackItem(time, duration, src, seedSrc, ++ID, isExtension);

            // Find empty slot
            if (BuffStack.Count < Capacity)
            {
                if (atFirst)
                {
                    BuffStack.Insert(0, toAdd);
                }
                else
                {
                    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, time));
                }
            }
        }
Exemplo n.º 4
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));
            }
        }
Exemplo n.º 5
0
        public override void Remove(AgentItem by, long removedDuration, int removedStacks, long time, ParseEnum.BuffRemove removeType, uint id)
        {
            switch (removeType)
            {
            case ParseEnum.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 ParseEnum.BuffRemove.Single:
                for (int i = 0; i < BuffStack.Count; i++)
                {
                    BuffStackItem stackItem = BuffStack[i];
                    if (Math.Abs(removedDuration - stackItem.TotalBoonDuration()) < GeneralHelper.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);
        }
Exemplo n.º 6
0
        public override bool StackEffect(ParsedLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes)
        {
            if (stacks.Count == 0)
            {
                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);
        }
Exemplo n.º 7
0
        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));
                }
            }
        }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
 public abstract bool StackEffect(ParsedLog log, BuffStackItem stackItem, List <BuffStackItem> stacks, List <BuffSimulationItemWasted> wastes);
Exemplo n.º 10
0
        public override void Activate(uint stackID)
        {
            BuffStackItem active = BuffStack.Find(x => x.StackID == stackID);

            _activeStack = active ?? throw new InvalidOperationException("Error Encountered: Activate has failed");
        }
 public BuffSimulationItemDuration(BuffStackItem other) : base(other.Start, other.Duration)
 {
     _src         = other.Src;
     _seedSrc     = other.SeedSrc;
     _isExtension = other.IsExtension;
 }
 public static int Compare(BuffStackItem x, BuffStackItem y)
 {
     return(-GetHealing(x).CompareTo(GetHealing(y)));
 }
 private static uint GetHealing(BuffStackItem stack)
 {
     return(stack.SeedSrc.Healing);
 }