robot_new/game_web/web_group/build/test/mgr.lua

25 lines
582 B
Lua
Raw Normal View History

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