|
@ -8,14 +8,14 @@ import javax.swing.event.MouseInputListener; |
|
|
|
|
|
|
|
|
public class MyMouseListener implements MouseInputListener { |
|
|
public class MyMouseListener implements MouseInputListener { |
|
|
|
|
|
|
|
|
private SaveStack save; |
|
|
|
|
|
|
|
|
private SaveStack saveStack; |
|
|
private BaseStack tempStack; |
|
|
private BaseStack tempStack; |
|
|
private BaseStack selectedStack; |
|
|
private BaseStack selectedStack; |
|
|
private Card tempCard; |
|
|
private Card tempCard; |
|
|
|
|
|
|
|
|
public MyMouseListener(SaveStack _save) { |
|
|
public MyMouseListener(SaveStack _save) { |
|
|
// TODO Auto-generated constructor stub |
|
|
// TODO Auto-generated constructor stub |
|
|
this.save = _save; |
|
|
|
|
|
|
|
|
this.saveStack = _save; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -40,7 +40,7 @@ public class MyMouseListener implements MouseInputListener { |
|
|
tempCard = (Card) com; |
|
|
tempCard = (Card) com; |
|
|
tempStack = (StartStack) com.getParent(); |
|
|
tempStack = (StartStack) com.getParent(); |
|
|
|
|
|
|
|
|
if (save.stackIsEmpty()) { |
|
|
|
|
|
|
|
|
if (saveStack.stackIsEmpty()) { |
|
|
// Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um |
|
|
// Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um |
|
|
if (!tempCard.isFaceUp()) { |
|
|
if (!tempCard.isFaceUp()) { |
|
|
if (tempStack.peekLastCard().equals(tempCard)) { |
|
|
if (tempStack.peekLastCard().equals(tempCard)) { |
|
@ -53,7 +53,7 @@ public class MyMouseListener implements MouseInputListener { |
|
|
// move all Cards below the selected Card to Save |
|
|
// move all Cards below the selected Card to Save |
|
|
int index = tempStack.indexOfCard(tempCard); |
|
|
int index = tempStack.indexOfCard(tempCard); |
|
|
while (tempStack.stackSize() - 1 >= index) { |
|
|
while (tempStack.stackSize() - 1 >= index) { |
|
|
save.addCard(tempStack.removeLastCard()); |
|
|
|
|
|
|
|
|
saveStack.addCard(tempStack.removeLastCard()); |
|
|
} |
|
|
} |
|
|
selectedStack = tempStack; |
|
|
selectedStack = tempStack; |
|
|
|
|
|
|
|
@ -64,14 +64,14 @@ public class MyMouseListener implements MouseInputListener { |
|
|
if(selectedStack == null) { |
|
|
if(selectedStack == null) { |
|
|
System.out.println("ERROR selectedStack in StartStack"); |
|
|
System.out.println("ERROR selectedStack in StartStack"); |
|
|
} |
|
|
} |
|
|
if(tempStack.cardCheck(tempStack.peekLastCard(), save.peekLastCard())) { |
|
|
|
|
|
while(!save.stackIsEmpty()) { |
|
|
|
|
|
tempStack.addCard(save.removeLastCard()); |
|
|
|
|
|
|
|
|
if(tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { |
|
|
|
|
|
while(!saveStack.stackIsEmpty()) { |
|
|
|
|
|
tempStack.addCard(saveStack.removeLastCard()); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
//Alles wieder auf den Ursprünglichen Stack packen |
|
|
//Alles wieder auf den Ursprünglichen Stack packen |
|
|
while(!save.stackIsEmpty()) { |
|
|
|
|
|
selectedStack.addCard(save.removeLastCard()); |
|
|
|
|
|
|
|
|
while(!saveStack.stackIsEmpty()) { |
|
|
|
|
|
selectedStack.addCard(saveStack.removeLastCard()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|