protection_bypass allows to dig chessboard always

This commit is contained in:
Wuzzy 2023-07-21 09:27:54 +02:00
parent 24ef28e0a5
commit 086a4e8f41
2 changed files with 10 additions and 3 deletions

View File

@ -430,6 +430,9 @@ cant 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

View File

@ -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)