From 086a4e8f41566a7b9ffda341ff26e8d1f0375c58 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 21 Jul 2023 09:27:54 +0200 Subject: [PATCH] protection_bypass allows to dig chessboard always --- CHESS_README.md | 3 +++ src/chess.lua | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHESS_README.md b/CHESS_README.md index 99baaba..00b6e40 100644 --- a/CHESS_README.md +++ b/CHESS_README.md @@ -430,6 +430,9 @@ can’t be stopped by other players. But to prevent two players blocking a chessboard forever, there is a 5-minute timer. If no player makes a move for 5 minutes, then the chessboard can be reset and dug by anyone. +Exception: Players with the `protection_bypass` privilege can always +dig the chessboard. + ## Appendix diff --git a/src/chess.lua b/src/chess.lua index 79c191f..b203af8 100644 --- a/src/chess.lua +++ b/src/chess.lua @@ -3052,10 +3052,14 @@ function realchess.fields(pos, _, fields, sender) end end -function realchess.dig(pos, player) - if not player then +function realchess.can_dig(pos, player) + if not player or not player:is_player() then return false end + -- Protection_bypass priv guarantees digging rights + if minetest.check_player_privs(player, "protection_bypass") then + return true + end local meta = minetest.get_meta(pos) local playerName = player:get_player_name() @@ -3242,7 +3246,7 @@ if ENABLE_CHESS_GAMES then -- Extend chess board node definition if chess games are enabled chessboarddef._tt_help = S("Play a game of Chess against another player or the computer") chessboarddef.on_blast = realchess.blast - chessboarddef.can_dig = realchess.dig + chessboarddef.can_dig = realchess.can_dig chessboarddef.on_construct = realchess.init chessboarddef.on_receive_fields = realchess.fields -- The move logic of Chess is here (at least for players)