place ko blockers as appropriate

master
capitalthree 1 year ago
parent 655ffa5c9a
commit 7ab28611c5
  1. 43
      rules.lua
  2. 9
      stones.lua

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

@ -140,10 +140,10 @@ local function reg(name, basename, basedef)
node_box = {
type = "fixed",
fixed = {
{-7/16, -7/16, -7/16, 7/16, -5/16, -5/16},
{7/16, -7/16, -7/16, 5/16, -5/16, 7/16},
{7/16, -7/16, 7/16, -7/16, -5/16, 5/16},
{-7/16, -7/16, 7/16, -5/16, -5/16, -7/16},
{-5/16, -6/16, -5/16, 5/16, -5/16, -4/16},
{5/16, -6/16, -5/16, 4/16, -5/16, 5/16},
{5/16, -6/16, 5/16, -5/16, -5/16, 4/16},
{-5/16, -6/16, 5/16, -4/16, -5/16, -5/16},
}
},
@ -157,7 +157,6 @@ local function reg(name, basename, basedef)
groups = {
snappy = 1,
falling_node = 1,
stack_as_node = 1,
ko_stone = 1,
cheat = 1,

Loading…
Cancel
Save