public static int validateChip(int player, int chip){
int isValid=0;
int noValid=1;
int validAndShifed=2;
int previousChip=gameBoard[player].pop();
DominoeChip prevChip=Dominoes.get(previousChip);
DominoeChip newChip=Dominoes.get(chip);
System.out.println("validateChip: player: "+player + " chip: " + chip + " value : "+newChip.getChip0()+"|"+newChip.getChip1());
System.out.println("validateChip: prevChip "+ +prevChip.getChip0()+"|"+prevChip.getChip1() +" getShifted : " + prevChip.getShifted() );
if(prevChip.getShifted()==1)
{
if(prevChip.getChip0()== newChip.getChip0())
{
System.out.println("validateChip: isValid - shifted = 1" );
gameBoard[player].push(previousChip);
gameBoard[player].push(chip);
return isValid;
}
else if(prevChip.getChip0()== newChip.getChip1())
{
System.out.println("validateChip: validAndShifed - shifted = 1" );
//Dominoes.remove(chip);
newChip.setShifted(1);
Dominoes.set(chip, newChip);
gameBoard[player].push(previousChip);
gameBoard[player].push(chip);
return validAndShifed;
}
}
else
{
if(prevChip.getChip1()== newChip.getChip0())
{
System.out.println("validateChip: isValid - shifted = 0" );
gameBoard[player].push(previousChip);
gameBoard[player].push(chip);
return isValid;
}
else if(prevChip.getChip1()== newChip.getChip1())
{
System.out.println("validateChip: validAndShifed - shifted = 0" );
gameBoard[player].push(previousChip);
gameBoard[player].push(chip);
//Dominoes.remove(chip);
newChip.setShifted(1);
Dominoes.set(chip, newChip);
return validAndShifed;
}
}