Skip to content

Commit

Permalink
Code optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
chamodshehanka committed Jul 17, 2018
1 parent cdedd93 commit ef317e9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/chessController.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,20 @@ function drag(ev) {

function drop(ev) {
ev.preventDefault();
var i;
var data = ev.dataTransfer.getData("text");
var droppingId=ev.target.id;
var legalMove=false;
var id="#"+droppingId;
var droppingSquareId=$(id).parent().attr("id");

for (var i=0;i<squareSuggestions.length;i++){
for (i=0;i<squareSuggestions.length;i++){
if (droppingId===squareSuggestions[i] || droppingSquareId===squareSuggestions[i]){
legalMove=true;
}
}

for (var i=0;i<attackSuggestions.length;i++){
for (i=0;i<attackSuggestions.length;i++){
if (droppingId===attackSuggestions[i] || droppingSquareId===attackSuggestions[i]){
legalMove=true;
}
Expand Down

0 comments on commit ef317e9

Please sign in to comment.