function jumpingPlayer(y, x) {
  // Defining if this new move makes it a king
  kingPlayer = counterInPlay.concat(counterInPlay)
  //Create an XX king
  if (counterInPlay == "X" && y == 7) {
    $('#b' + x + y).off().val(kingPlayer)
    table[y][x] = kingPlayer;
    //Create a YY king
  } else if (counterInPlay == "Y" && y == 0) {
    $('#b' + x + y).off().val(kingPlayer)
    table[y][x] = kingPlayer;
  } else {
    //Not a king
    //Changes table layout
    table[y][x] = table[selectedY][selectedX];
    //Changes Display
    $('#b' + x + y).val($('#b' + selectedX + selectedY).val())
  }

  //Changes the previous location value to blank
  $('#b' + selectedX + selectedY).off().val("  ")
  table[selectedY][selectedX] = 0;

  //takePlayer will see if a piece was taken in the move. Will also check if second overtake is on
  //Returns a statement saying if the second overtake is on
  var secondOvertake = takePlayer(selectedY, selectedX, y, x)
  //If no double overtake is on: move is ended and the counterInPlay is changed
  if (doubleTakeIndicator == 0) {
    changePlayer();
    resetTurn();
    // If not, the values are switched and the the tiles are active for another click.
  } else {
    selectedY = y;
    selectedX = x;
  }

  //Send updated table to the server
  fetch('/move', {
      method: 'POST',
      headers: new Headers({
        'Content-Type': 'application/json'
      }),
      body: JSON.stringify({
        table
      })
    })
    .catch(err => console.log(err));

}
/**
 * @function jumpingPlayer - Moving piece from previous location (selected x/y) to new desired location (x/y)
 */
@function jumpingPlayer - Moving piece from previous location (selected x/y) to new desired location (x/y)
@function jumpingPlayer - Moving piece from previous location ( selected x / y ) to new desired location ( x / y )
function jumpingPlayer(y, x) {
  kingPlayer = counterInPlay.concat(counterInPlay)
  if (counterInPlay == "X" && y == 7) {
    $('#b' + x + y).off().val(kingPlayer)
    table[y][x] = kingPlayer;
  } else if (counterInPlay == "Y" && y == 0) {
    $('#b' + x + y).off().val(kingPlayer)
    table[y][x] = kingPlayer;
  } else {
    table[y][x] = table[selectedY][selectedX];
    $('#b' + x + y).val($('#b' + selectedX + selectedY).val())
  }
  $('#b' + selectedX + selectedY).off().val("  ")
  table[selectedY][selectedX] = 0;
  var secondOvertake = takePlayer(selectedY, selectedX, y, x)
  if (doubleTakeIndicator == 0) {
    changePlayer();
    resetTurn();
  } else {
    selectedY = y;
    selectedX = x;
  }
  fetch('/move', {
      method: 'POST',
      headers: new Headers({
        'Content-Type': 'application/json'
      }),
      body: JSON.stringify({
        table
      })
    })
    .catch(err => console.log(err));
}
function jumpingPlayer ( y , x ) { kingPlayer = counterInPlay . concat ( counterInPlay ) if ( counterInPlay == "X" && y == 7 ) { $ ( '#b' + x + y ) . off ( ) . val ( kingPlayer ) table [ y ] [ x ] = kingPlayer ; } else if ( counterInPlay == "Y" && y == 0 ) { $ ( '#b' + x + y ) . off ( ) . val ( kingPlayer ) table [ y ] [ x ] = kingPlayer ; } else { table [ y ] [ x ] = table [ selectedY ] [ selectedX ] ; $ ( '#b' + x + y ) . val ( $ ( '#b' + selectedX + selectedY ) . val ( ) ) } $ ( '#b' + selectedX + selectedY ) . off ( ) . val ( "  " ) table [ selectedY ] [ selectedX ] = 0 ; var secondOvertake = takePlayer ( selectedY , selectedX , y , x ) if ( doubleTakeIndicator == 0 ) { changePlayer ( ) ; resetTurn ( ) ; } else { selectedY = y ; selectedX = x ; } fetch ( '/move' , { method : 'POST' , headers : new Headers ( { 'Content-Type' : 'application/json' } ) , body : JSON . stringify ( { table } ) } ) . catch ( err => console . log ( err ) ) ; }
@function jumpingPlayer - Moving piece from previous location (selected x/y) to new desired location (x/y)
@function jumpingPlayer - Moving piece from previous location ( selected x / y ) to new desired location ( x / y )
// Defining if this new move makes it a king //Create an XX king //Create a YY king //Not a king //Changes table layout //Changes Display //Changes the previous location value to blank //takePlayer will see if a piece was taken in the move. Will also check if second overtake is on //Returns a statement saying if the second overtake is on //If no double overtake is on: move is ended and the counterInPlay is changed // If not, the values are switched and the the tiles are active for another click. //Send updated table to the server