commit 7cd53d2e892eb3e26bb577ee15cc0e2059464910 Author: capitalthree Date: Thu Nov 16 00:28:23 2023 -0600 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a09c56d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea diff --git a/goban.lua b/goban.lua new file mode 100644 index 0000000..9be518d --- /dev/null +++ b/goban.lua @@ -0,0 +1,15 @@ +-- LUALOCALS < --------------------------------------------------------- +local include, nodecore + = include, nodecore +-- LUALOCALS > --------------------------------------------------------- + +nodecore.register_concrete_pattern({description = "Crossy"}) +nodecore.register_concrete_pattern({description = "Starcrossy"}) +nodecore.register_concrete_pattern({description = "Edgy", paramtype2 = "4dir"}) +nodecore.register_concrete_pattern({description = "Corny", paramtype2 = "4dir"}) + + +--nodecore.register_concrete_pattern({description = "Crossy", groups = {goban = 1}}) +--nodecore.register_concrete_pattern({description = "Starcrossy", groups = {goban = 1}}) +--nodecore.register_concrete_pattern({description = "Edgy", paramtype2 = "4dir", groups = {goban = 1}}) +--nodecore.register_concrete_pattern({description = "Corny", paramtype2 = "4dir", groups = {goban = 1}}) diff --git a/init.lua b/init.lua new file mode 100755 index 0000000..4806ff7 --- /dev/null +++ b/init.lua @@ -0,0 +1,9 @@ +-- LUALOCALS < --------------------------------------------------------- +local include, nodecore + = include, nodecore +-- LUALOCALS > --------------------------------------------------------- + + +include("goban") +include("rules") +include("stones") \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100755 index 0000000..99bc8d4 --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = lc_liberties +description = A minimalistic approach to enabling the game of go. +depends = nc_api_all, nc_concrete diff --git a/rules.lua b/rules.lua new file mode 100644 index 0000000..9550c46 --- /dev/null +++ b/rules.lua @@ -0,0 +1,81 @@ +-- LUALOCALS < --------------------------------------------------------- +local include, nodecore, pairs, string, table += include, nodecore, pairs, string, table +local string_lower += string.lower + +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() + +--nodecore.gametime + +local cache = {} + +local relativeNeighbors = { + vector.new(1, 0, 0), + vector.new(0, 0, 1), + vector.new(-1, 0, 0), + vector.new(0, 0, -1) +} + +function check_position(pos) + local hash = minetest.hash_node_position(pos) + if cache[hash] then + return cache[hash] + end + + local ret = minetest.get_node(pos) + print_r(ret) + print_r(minetest.registered_items[ret.name]) + print(pos) + cache[hash] = ret + return ret +end + +function check_captures(pos) + minetest.chat_send_all(tostring(pos)) + nodecore.node_sound(pos, "dug") + + check_position(pos + vector.new(0, -1, 0)) + + local neighbors = {} + + for i,v in ipairs(relativeNeighbors) do + neighbors[i] = pos + v + end + +end + +function surrounded_group(pos) + local group = {} + local queue = {} +end + + + + + +function print_r ( t ) + local print_r_cache={} + local function sub_print_r(t,indent) + if (print_r_cache[tostring(t)]) then + print(indent.."*"..tostring(t)) + else + print_r_cache[tostring(t)]=true + if (type(t)=="table") then + for pos,val in pairs(t) do + if (type(val)=="table") then + print(indent.."["..pos.."] => "..tostring(t).." {") + sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) + print(indent..string.rep(" ",string.len(pos)+6).."}") + else + print(indent.."["..pos.."] => "..tostring(val)) + end + end + else + print(indent..tostring(t)) + end + end + end + sub_print_r(t," ") +end \ No newline at end of file diff --git a/stones.lua b/stones.lua new file mode 100644 index 0000000..d0602a8 --- /dev/null +++ b/stones.lua @@ -0,0 +1,103 @@ +-- LUALOCALS < --------------------------------------------------------- +local include, nodecore, pairs, string + = include, nodecore, pairs, string +local string_lower + = string.lower +-- LUALOCALS > --------------------------------------------------------- + +include("rules") + +local modname = minetest.get_current_modname() + +local function reg(name, basename, basedef) + local piecename = modname .. ":stone_" .. string_lower(name) + if minetest.registered_nodes[piecename] then return end + local desc = basedef.description or name + + local nodeDesc + + local nameStone = string.match(desc, "(.*)stone$") + if nameStone then + nodeDesc = nameStone + elseif desc == "Stone" then + nodeDesc = "Go" + else + nodeDesc = desc + end + nodeDesc = nodeDesc .. " Stone" + + minetest.register_node(":" .. piecename, { + description = nodeDesc, + drawtype = "nodebox", + + node_box = { + type = "fixed", + fixed = { + {-3/16, -8/16, -3/16, 3/16, -7/16, 3/16}, + {-5/16, -7/16, -5/16, 5/16, -6/16, 5/16}, + {-6/16, -6/16, -6/16, 6/16, -4/16, 6/16}, + {-7/16, -4/16, -7/16, 7/16, -2/16, 7/16}, + {-6/16, -2/16, -6/16, 6/16, 0/16, 6/16}, + {-5/16, 0/16, -5/16, 5/16, 1/16, 5/16}, + {-3/16, 1/16, -3/16, 3/16, 2/16, 3/16}, + } + }, + + selection_box = { + type = "fixed", + fixed = {-7/16, -8/16, -7/16, 7/16, 2/16, 7/16} + }, + + + tiles = { + basedef.tiles[1] + }, + + paramtype = "light", + sunlight_propagates = true, + groups = { + snappy = 1, + falling_node = 1, + falling_repose = 1, + }, + sounds = basedef.sounds, + + on_construct = check_captures + }) + + nodecore.register_craft({ + label = "shave " .. string_lower(desc) .. " into stones", + action = "pummel", + toolgroups = {choppy = 3}, + nodes = { + { + match = "nc_concrete:" .. name .. "_starcrossy_ply", + --match = {groups = {goban = 1}}, + replace = "air" + } + }, + items = {{name = piecename, count = 3, scatter = 4}}, + }) +end + +local function buildall() + for _, v in ipairs(nodecore.registered_concrete_etchables) do + local basedef = v.name and v.basename and minetest.registered_nodes[v.basename] + if basedef then + reg(v.name, v.basename, basedef) + end + end +end + +do + local old_reg_etch = nodecore.register_concrete_etchable + local function helper(...) + buildall() + return ... + end + nodecore.register_concrete_etchable = function(...) + return helper(old_reg_etch(...)) + end +end + +buildall() diff --git a/textures/nc_concrete_pattern_corny.png b/textures/nc_concrete_pattern_corny.png new file mode 100644 index 0000000..684164a Binary files /dev/null and b/textures/nc_concrete_pattern_corny.png differ diff --git a/textures/nc_concrete_pattern_crossy.png b/textures/nc_concrete_pattern_crossy.png new file mode 100644 index 0000000..cb9c78c Binary files /dev/null and b/textures/nc_concrete_pattern_crossy.png differ diff --git a/textures/nc_concrete_pattern_edgy.png b/textures/nc_concrete_pattern_edgy.png new file mode 100644 index 0000000..0bce4f5 Binary files /dev/null and b/textures/nc_concrete_pattern_edgy.png differ diff --git a/textures/nc_concrete_pattern_starcrossy.png b/textures/nc_concrete_pattern_starcrossy.png new file mode 100644 index 0000000..44af38b Binary files /dev/null and b/textures/nc_concrete_pattern_starcrossy.png differ