robot_new/game_web/web_group/build/pro/trade.lua

12 lines
385 B
Lua

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}