robot_new/game_web/robot_mgr/build/test/trade.lua

12 lines
385 B
Lua
Raw Normal View History

2025-12-18 19:52:18 +08:00
local mgr_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local tag_hp = tonumber(redis.call('hget', KEYS[2],'hp'))
mgr_hp = not mgr_hp and 0 or mgr_hp
tag_hp = not tag_hp and 0 or tag_hp
local hp = tonumber(ARGV[1])
if hp > 0 and mgr_hp <hp then
return 3
else
mgr_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
return {mgr_hp,tag_hp}