local K=require(script.Parent.Parent.LootPool)local N=require(script.Parent.Parent.Config)local y=setmetatable({},K)y.__index=y local function l(K,N)return(100/K.rolls)/100 end function y.new(N,L)local J=K.new(N)J._sample=L or l J._rolls=0 J._modified={}return setmetatable(J,y)end function y.reset(K)K._rolls=0 table.clear(K._modified)end function y.roll(K)local y=K:_roll()K._rolls+=1 for y,l in y do for y,L in ipairs(K._items)do if L.weight==N.get("\103\117\097\114\097\110\116\101\101\100\082\111\108\108\087\101\105\103\104\116")then continue end if L.rolls==nil and L==l then L.weight*=K._sample(L)end end end return y end return y
local LootPool = require(script.Parent.Parent.LootPool)
local Config = require(script.Parent.Parent.Config)

local GuaranteedReplacementPool = setmetatable({}, LootPool)
GuaranteedReplacementPool.__index = GuaranteedReplacementPool

local function defaultSampler(item, _state)
    return 100 / item.rolls / 100
end

function GuaranteedReplacementPool.new(data, sampler)
    local self = LootPool.new(data)

    self._sample = sampler or defaultSampler
    self._rolls = 0
    self._modified = {}

    return setmetatable(self, GuaranteedReplacementPool)
end

function GuaranteedReplacementPool:reset()
    self._rolls = 0
    table.clear(self._modified)
end

function GuaranteedReplacementPool:roll() -- override
    local results = self:_roll()
    self._rolls += 1

    for _, result in results do
        for _, item in ipairs(self._items) do
            -- don't count guaranteed items
            if item.weight == Config.get("guaranteedRollWeight") then
                continue
            end

            if item.rolls == nil and item == result then
                item.weight *= self._sample(item)
            end
        end
    end

    return results
end

return GuaranteedReplacementPool