Skip to content

Commit

Permalink
improve: changing exhaust functions to kv (#2055)
Browse files Browse the repository at this point in the history
changing exhaust functions to kv:
- player:setExhaustion(scope, seconds)
- player:getExhaustion(scope)
- player:hasExhaustion(scope)

---------

Co-authored-by: Luan Santos <github@luan.sh>
  • Loading branch information
luanluciano93 and luan committed Jan 11, 2024
1 parent ea4c6e8 commit 9aaee3b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions data/libs/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -631,16 +631,17 @@ function Player:calculateLootFactor(monster)
}
end

function Player:setExhaustion(key, seconds)
return self:setStorageValue(key, os.time() + seconds)
function Player:setExhaustion(scope, seconds)
return self:kv():scoped("exhaustion"):set(scope, os.time() + seconds)
end

function Player:getExhaustion(key)
return math.max(self:getStorageValue(key) - os.time(), 0)
function Player:getExhaustion(scope)
local exhaustionKV = self:kv():scoped("exhaustion"):get(scope) or 0
return math.max(exhaustionKV - os.time(), 0)
end

function Player:hasExhaustion(key)
return self:getExhaustion(key) > 0 and true or false
function Player:hasExhaustion(scope)
return self:getExhaustion(scope) > 0 and true or false
end

function Player:setFiendish()
Expand Down

0 comments on commit 9aaee3b

Please sign in to comment.