|
|
@ -177,7 +177,7 @@ local function connected_search(pos, final_result, early_termination_filter) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
final_result = final_result() |
|
|
|
final_result = final_result(#group) |
|
|
|
final_result.stones = stones |
|
|
|
final_result.stones = stones |
|
|
|
return final_result |
|
|
|
return final_result |
|
|
|
end |
|
|
|
end |
|
|
@ -222,8 +222,8 @@ local function _check_captures_filter(node, count) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function _check_captures_final() |
|
|
|
local function _check_captures_final(count) |
|
|
|
return {capture = true} |
|
|
|
return {capture = count} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function check_captures(pos) |
|
|
|
local function check_captures(pos) |
|
|
@ -321,17 +321,34 @@ function lc_liberties.handle_placement(pos) |
|
|
|
local node = check_position(new_pos) |
|
|
|
local node = check_position(new_pos) |
|
|
|
if (node:sub(1, 1) == "S") and (node:sub(2, -1) ~= our_stone) then |
|
|
|
if (node:sub(1, 1) == "S") and (node:sub(2, -1) ~= our_stone) then |
|
|
|
local captures = check_captures(new_pos) |
|
|
|
local captures = check_captures(new_pos) |
|
|
|
captured = captured or captures.capture |
|
|
|
if captures.capture then |
|
|
|
|
|
|
|
captured = (captured or 0) + captures.capture |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
captureses[#captureses+1] = captures |
|
|
|
captureses[#captureses+1] = captures |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local allcaptured = {} |
|
|
|
local allcaptured = {} |
|
|
|
|
|
|
|
local ko |
|
|
|
if captured then |
|
|
|
if captured then |
|
|
|
|
|
|
|
if captured == 1 then |
|
|
|
|
|
|
|
for i,v in pairs(neighbor_dirs(pos)) do |
|
|
|
|
|
|
|
local new_stone = check_position(pos + directions[v]) |
|
|
|
|
|
|
|
if (new_stone:sub(2, -1) == our_stone) or (new_stone:sub(1, 1) == "E") then |
|
|
|
|
|
|
|
goto noko |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ko = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::noko:: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
for i,v in pairs(captureses) do |
|
|
|
for i,v in pairs(captureses) do |
|
|
|
if v.capture then |
|
|
|
if v.capture then |
|
|
|
local stone = minetest.get_node(v.stones[next(v.stones)]).name |
|
|
|
local stone = check_position(v.stones[next(v.stones)]):sub(2, -1) -- minetest.get_node().name) |
|
|
|
local count = 0 |
|
|
|
local count = 0 |
|
|
|
|
|
|
|
|
|
|
|
local proximal |
|
|
|
local proximal |
|
|
@ -340,6 +357,11 @@ function lc_liberties.handle_placement(pos) |
|
|
|
for i2, v2 in pairs(v.stones) do |
|
|
|
for i2, v2 in pairs(v.stones) do |
|
|
|
allcaptured[#allcaptured + 1] = v2 |
|
|
|
allcaptured[#allcaptured + 1] = v2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ko then |
|
|
|
|
|
|
|
-- save ko capture position, for adding ko marker in fx phase |
|
|
|
|
|
|
|
ko = {stone = stone, pos = v2} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local under = check_position(v2 + down) |
|
|
|
local under = check_position(v2 + down) |
|
|
|
if (under:sub(1, 1) == "W") and (under:len() > 1) then |
|
|
|
if (under:sub(1, 1) == "W") and (under:len() > 1) then |
|
|
|
nodecore.sound_play("nc_fire_ignite", {gain = 1, pos = pos}) |
|
|
|
nodecore.sound_play("nc_fire_ignite", {gain = 1, pos = pos}) |
|
|
@ -347,6 +369,7 @@ function lc_liberties.handle_placement(pos) |
|
|
|
else |
|
|
|
else |
|
|
|
nodecore.set_loud(v2, {name = "air"}) |
|
|
|
nodecore.set_loud(v2, {name = "air"}) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
count = count + 1 |
|
|
|
count = count + 1 |
|
|
|
if (v2:distance(pos) < 2.3) then |
|
|
|
if (v2:distance(pos) < 2.3) then |
|
|
|
proximal_c = proximal_c + 1 |
|
|
|
proximal_c = proximal_c + 1 |
|
|
@ -356,10 +379,11 @@ function lc_liberties.handle_placement(pos) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
multi_eject(proximal, stone, 3, count) |
|
|
|
multi_eject(proximal, modname .. ":stone_" .. stone, 3, count) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
-- if no capture was made, check for a self-capture and reject the move |
|
|
|
local captures = check_captures(pos) |
|
|
|
local captures = check_captures(pos) |
|
|
|
if captures.capture then |
|
|
|
if captures.capture then |
|
|
|
local stone = minetest.get_node(pos).name |
|
|
|
local stone = minetest.get_node(pos).name |
|
|
@ -379,6 +403,10 @@ function lc_liberties.handle_placement(pos) |
|
|
|
smokecontrol(allcaptured[chosen], 90) |
|
|
|
smokecontrol(allcaptured[chosen], 90) |
|
|
|
allcaptured[chosen] = allcaptured[i] |
|
|
|
allcaptured[chosen] = allcaptured[i] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ko then |
|
|
|
|
|
|
|
nodecore.set_loud(ko.pos, {name = modname .. ":ko_" .. ko.stone}) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing) |
|
|
|
function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing) |
|
|
@ -429,13 +457,12 @@ function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function lc_liberties.handle_dig(pos, node, digger) |
|
|
|
function lc_liberties.handle_dig(pos, node, digger) |
|
|
|
cache = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local control = digger.get_player_control and digger:get_player_control() |
|
|
|
local control = digger.get_player_control and digger:get_player_control() |
|
|
|
if (control and (control.aux1 or control.sneak)) |
|
|
|
if (control and (control.aux1 or control.sneak)) |
|
|
|
~= |
|
|
|
~= |
|
|
|
(minetest.registered_items[node.name].groups.go_territory_marker ~= nil) |
|
|
|
(minetest.registered_items[node.name].groups.go_territory_marker ~= nil) |
|
|
|
then |
|
|
|
then |
|
|
|
|
|
|
|
cache = {} |
|
|
|
|
|
|
|
|
|
|
|
local stone = minetest.get_node(pos).name |
|
|
|
local stone = minetest.get_node(pos).name |
|
|
|
|
|
|
|
|
|
|
|