Drop captured go stones when capturing

pull/1/head
Aaron Suen 1 year ago
parent 812bc837ba
commit ce951072b5
  1. 16
      rules.lua

@ -190,15 +190,27 @@ function lc_liberties.handle_placement(pos)
end end
if captured then if captured then
local removed_items = {} -- key = name, value = count
for i,v in pairs(captureses) do for i,v in pairs(captureses) do
if v.capture then if v.capture then
local proximal = {} local proximal = {}
for i2, v2 in pairs(v.stones) do for i2, v2 in pairs(v.stones) do
local old = minetest.get_node(v2).name
removed_items[old] = (removed_items[old] or 0) + 1
nodecore.set_loud(v2, {name = "nc_fire:fire"}) nodecore.set_loud(v2, {name = "nc_fire:fire"})
end end
end
-- todo: spawn itemstack of captured stones somehow end
for k, v in pairs(removed_items) do
local max = minetest.registered_items[k].stack_max
while v > max do
nodecore.item_eject(pos, k .. " " .. max)
v = v - max
end
if v > 0 then
nodecore.item_eject(pos, k .. " " .. v)
end end
end end
else else

Loading…
Cancel
Save