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