Skip to content

Commit

Permalink
Merge pull request #2 from ahmed-debbech/dev
Browse files Browse the repository at this point in the history
Add solved badge
  • Loading branch information
ahmed-debbech authored Jan 6, 2025
2 parents ea6f91e + 9dd15f6 commit 1dc0cdb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/views/assets/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions backend/views/assets/js/local_chess.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function onDrop(source, target, piece, newPos, oldPos, orientation){

showAvilableMoves(source, false)

if(data.BestMoves.length <= movesCount) {$("#status").html("SOLVED"); return 'snapback';}
if(data.BestMoves.length <= movesCount) {$('#solved_badge').css('display', 'block'); $("#status").html("SOLVED"); return 'snapback';}

if(isRightMove(data.BestMoves[movesCount], source+target)){
unHighlight(last_move_cell_start, last_move_cell_end)
Expand All @@ -84,11 +84,11 @@ function onDrop(source, target, piece, newPos, oldPos, orientation){
unHighlight(last_move_cell_start, last_move_cell_end)
movesCount++

if(data.BestMoves.length <= movesCount) {$("#status").html("SOLVED"); return;}
if(data.BestMoves.length <= movesCount) {$('#solved_badge').css('display', 'block'); $("#status").html("SOLVED"); return;}

computerPlays(adaptMove(data.BestMoves[movesCount]))

if(data.BestMoves.length <= movesCount) {$("#status").html("SOLVED"); return;}
if(data.BestMoves.length <= movesCount) {$('#solved_badge').css('display', 'block'); $("#status").html("SOLVED"); return;}

},500)
}else{
Expand All @@ -101,6 +101,7 @@ function onDrop(source, target, piece, newPos, oldPos, orientation){
}

function buildBoard(dd){
$('#solved_badge').css('display', 'none');
data = dd
game = new Chess(data.FEN)
orient = 'white'
Expand Down Expand Up @@ -189,6 +190,8 @@ function highlightHint(start, end) {
.addClass('highlight-hint')
$("#board1").find('.square-' + end )
.addClass('highlight-hint')
unHighlightAvailable(start)
unHighlightAvailable(end)
}
function unHighlightHint(start, end) {
$("#board1").find('.square-' + start )
Expand Down
4 changes: 2 additions & 2 deletions backend/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@
</div>
</div>

<div class="row">
<div id="solved_badge" style="display: none;" class="row">
<div class="col-12">
<div hidden id="solved_badge" class="alert alert-success alert-has-icon">
<div class="alert alert-success alert-has-icon">
<div class="alert-icon"><i class="far fa-thumbs-up"></i></div>
<div class="alert-body">
<div class="alert-title">Well done!</div>
Expand Down

0 comments on commit 1dc0cdb

Please sign in to comment.