Chess: Add messages for common invalid moves
This commit is contained in:
parent
930915ea64
commit
286ad00b84
@ -2231,42 +2231,43 @@ function realchess.move(meta, from_list, from_index, to_list, to_index, playerNa
|
|||||||
local thisMove -- Will replace lastMove when move is legal
|
local thisMove -- Will replace lastMove when move is legal
|
||||||
|
|
||||||
if pieceFrom:find("white") then
|
if pieceFrom:find("white") then
|
||||||
|
if playerWhite ~= "" and playerWhite ~= playerName then
|
||||||
|
send_message(playerName, S("Someone else plays white pieces!"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if pieceTo:find("white") then
|
if pieceTo:find("white") then
|
||||||
-- Don't replace pieces of same color
|
-- Don't replace pieces of same color
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if lastMove == "white" then
|
if lastMove == "white" then
|
||||||
-- let the other invocation decide in case of a capture
|
send_message(playerName, S("It's not your turn!"))
|
||||||
return pieceTo == "" and 0 or 1
|
return
|
||||||
end
|
|
||||||
|
|
||||||
if playerWhite ~= "" and playerWhite ~= playerName then
|
|
||||||
send_message(playerName, S("Someone else plays white pieces!"))
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
playerWhite = playerName
|
playerWhite = playerName
|
||||||
thisMove = "white"
|
thisMove = "white"
|
||||||
|
|
||||||
elseif pieceFrom:find("black") then
|
elseif pieceFrom:find("black") then
|
||||||
|
if playerBlack ~= "" and playerBlack ~= playerName then
|
||||||
|
send_message(playerName, S("Someone else plays black pieces!"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if pieceTo:find("black") then
|
if pieceTo:find("black") then
|
||||||
-- Don't replace pieces of same color
|
-- Don't replace pieces of same color
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if lastMove == "black" then
|
if lastMove == "black" then
|
||||||
-- let the other invocation decide in case of a capture
|
send_message(playerName, S("It's not your turn!"))
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
if playerBlack ~= "" and playerBlack ~= playerName then
|
|
||||||
send_message(playerName, S("Someone else plays black pieces!"))
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if lastMove == "" then
|
if lastMove == "" then
|
||||||
-- Nobody has moved yet, and Black cannot move first
|
-- Nobody has moved yet, and Black cannot move first
|
||||||
|
send_message(playerName, S("Black cannot move first!"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user