From 0b7da940d671aa3e0ae108522e07dd24a9f29e54 Mon Sep 17 00:00:00 2001 From: unknown <danielsahlin8@gmail.com> Date: Tue, 13 Oct 2020 14:21:40 +0200 Subject: [PATCH] update --- script.js | 18 ++++++++++++------ stylesheet.css | 9 +++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index d8885cf..ef28b2a 100644 --- a/script.js +++ b/script.js @@ -2,6 +2,7 @@ // https://github.com/jhlywa/chess.js var board = null; +var $board = $('#myBoard'); var game = new Chess(); var whiteSquareGrey = '#a9a9a9' var blackSquareGrey = '#696969' @@ -246,8 +247,10 @@ var tipGame = new Chess(); function generateTip() { //$('#middle').html('Whites turn'); //$('#smove').html(suggestMove); - colorSquare(suggestMove.from, '#83FF33'); - colorSquare(suggestMove.to, '#83FF33'); + $board.find('.square-' + suggestMove.from).addClass('highlight-white'); + $board.find('.square-' + suggestMove.to).addClass('highlight-white'); + //colorSquare(suggestMove.from, '#83FF33'); + //colorSquare(suggestMove.to, '#83FF33'); // Explain suggested move var gameFEN = game.fen(); @@ -257,12 +260,12 @@ function generateTip() { tipGame.setTurn('w'); // change back to white to generate moves var moves = tipGame.moves({square: suggestMove.to, verbose: true, legal: false}); - $('#tip').html('Suggested move is the green square.') + $('#tip').html('Suggested move is the yellow outline.') moves.forEach((item, i) => { if(item.flags === 'c') { - colorSquare(item.to, '#FF5E33'); - $('#tip').html('Moving to green square attacks red squares.') + $board.find('.square-' + item.to).addClass('highlight-red'); + $('#tip').html('Moving to yellow attacks red squares.') } }); @@ -274,7 +277,7 @@ function generateTip() { if(def[key].indexOf(suggestMove.piece + suggestMove.to) !== -1) { - colorSquare(key.slice(-2), '#3399ff') + $board.find('.square-' + key.slice(-2)).addClass('highlight-blue'); } }); @@ -337,6 +340,9 @@ function onChange() { } function onDrop (source, target) { + $board.find('.square-' + '55d63').removeClass('highlight-blue'); + $board.find('.square-' + '55d63').removeClass('highlight-red'); + $board.find('.square-' + '55d63').removeClass('highlight-white'); removeGreySquares(); // see if the move is legal diff --git a/stylesheet.css b/stylesheet.css index 7a89dfa..a701c11 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -33,3 +33,12 @@ body { float: left; } +.highlight-white{ + box-shadow: inset 0 0 3px 3px yellow; +} +.highlight-blue{ + background-color: blue; +} +.highlight-red{ + background-color: red; +} \ No newline at end of file -- GitLab