From a5866b2e42ed58173683a4c9d05ff85bd5fb17ff Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 11 Jul 2023 07:01:58 +0200 Subject: [PATCH] Chess: Show arrow to current player --- src/chess.lua | 16 ++++++++++------ textures/chess_turn_black.png | Bin 0 -> 239 bytes textures/chess_turn_white.png | Bin 0 -> 239 bytes 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 textures/chess_turn_black.png create mode 100644 textures/chess_turn_white.png diff --git a/src/chess.lua b/src/chess.lua index 1b82f92..de701ec 100644 --- a/src/chess.lua +++ b/src/chess.lua @@ -625,15 +625,19 @@ local function update_formspec(meta) local m_sel_idx = meta:get_int("move_no") or 1 local eaten_img = meta:get_string("eaten_img") local lastMove = meta:get_string("lastMove") - local turnBlack = minetest.colorize("#000001", (lastMove == "white" and playerBlack ~= "") and - playerBlack .. "..." or playerBlack) - local turnWhite = minetest.colorize("#000001", (lastMove == "black" and playerWhite ~= "") and - playerWhite .. "..." or playerWhite) + -- arrow to show whose turn it is + local blackArr = (lastMove == "white" and "image[1,0.2;0.7,0.7;chess_turn_black.png]") or "" + local whiteArr = ((lastMove == "" or lastMove == "black") and "image[1,9.05;0.7,0.7;chess_turn_white.png]") or "" + local turnBlack = minetest.colorize("#000001", playerBlack) + local turnWhite = minetest.colorize("#000001", playerWhite) + -- display the word "check" if the player is in check local check_s = minetest.colorize("#FF0000", "\\["..FS("check").."\\]") local formspec = fs .. "label[1.9,0.3;" .. turnBlack .. (black_king_attacked and " " .. check_s or "") .. "]" .. + blackArr .. "label[1.9,9.15;" .. turnWhite .. (white_king_attacked and " " .. check_s or "") .. "]" .. + whiteArr .. "table[8.9,1.05;5.07,3.75;moves;" .. moves .. ";"..m_sel_idx.."]" .. eaten_img @@ -701,11 +705,11 @@ local function update_moves_table(meta) -- Castling if pieceFrom:sub(11,14) == "king" and ((curPlayerIsWhite and from_y == 7 and to_y == 7) or (not curPlayerIsWhite and from_y == 0 and to_y == 0)) then moves_out = moves_out .. MOVES_LIST_SYMBOL_EMPTY .. "," - -- queenside castling / shortside castling + -- queenside castling if to_x == 2 then -- write "0-0-0" moves_out = moves_out .. "0-0-0" - -- kingside castling / shortside castling + -- kingside castling elseif to_x == 6 then -- write "0-0" moves_out = moves_out .. "0-0" diff --git a/textures/chess_turn_black.png b/textures/chess_turn_black.png new file mode 100644 index 0000000000000000000000000000000000000000..00f7c746e44750955728747ec92a0bb31a0406ad GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`+dN$yLo7}&y{yaEVj$q~@cO|b z2AQ_o6CMcqR=EVlpJ%mTIQZb8;H6OI8!3rqSGGK>&HVLv&-a|$Yz-X-Jj@KS*Apcd z6^4fPJm#3tD3iQ}(KV3a!Zuw8KE;6RreQ863k4i5o20qSDQ0-FX0eX9uu}Oh)`@eB z^944}`68Rd^sP31UOL0~zjjZ2|8UqG-QJ-3k8{oItSJXZYKy nw=|_s-`b+DdEfj0U5s`tf0HuLz5Le(^Z|pXtDnm{r-UW|ik4q# literal 0 HcmV?d00001 diff --git a/textures/chess_turn_white.png b/textures/chess_turn_white.png new file mode 100644 index 0000000000000000000000000000000000000000..6ede5a93e705b69ffd7f4ce348dc6d1767c5ee70 GIT binary patch literal 239 zcmVQ-!p^a^&CB6-ymK2QftlQj1b@{zvp+4mg)RVAfF z&Y5|h@eH*%gg{COpa7+58Xr(q6#!k=0hG3Fsp}dqqP8#yAjarMR73!<*+vM#h3J#+ zL9~>@7eqZL{e-xHWm#C)6+r&qhkl7)fw%Y;5D`~=3*?+#@ddE!+_sHrnp`n}p63a` pIF0}^41+tq?BF;K`@-%R;0J