|
@ -8,6 +8,15 @@ import javax.swing.event.MouseInputListener; |
|
|
|
|
|
|
|
|
public class MyMouseListener implements MouseInputListener { |
|
|
public class MyMouseListener implements MouseInputListener { |
|
|
|
|
|
|
|
|
|
|
|
private SaveStack save; |
|
|
|
|
|
private BaseStack tempStack; |
|
|
|
|
|
private Card tempCard; |
|
|
|
|
|
|
|
|
|
|
|
public MyMouseListener(SaveStack _save) { |
|
|
|
|
|
// TODO Auto-generated constructor stub |
|
|
|
|
|
this.save = _save; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void mouseClicked(MouseEvent e) { |
|
|
public void mouseClicked(MouseEvent e) { |
|
|
// TODO Auto-generated method stub |
|
|
// TODO Auto-generated method stub |
|
@ -32,9 +41,27 @@ public class MyMouseListener implements MouseInputListener { |
|
|
} |
|
|
} |
|
|
//Karte, die in einem StartStack liegt |
|
|
//Karte, die in einem StartStack liegt |
|
|
else if(com instanceof Card && com.getParent() instanceof StartStack) { |
|
|
else if(com instanceof Card && com.getParent() instanceof StartStack) { |
|
|
System.out.println("Karte in StartStack"+com.toString()); |
|
|
|
|
|
|
|
|
tempCard = (Card) com; |
|
|
|
|
|
tempStack = (StartStack) com.getParent(); |
|
|
|
|
|
|
|
|
|
|
|
//Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um |
|
|
|
|
|
if(!tempCard.isFaceUp()) { |
|
|
|
|
|
if(tempStack.peekLastCard().equals(tempCard)) { |
|
|
|
|
|
tempCard.setFaceUp(true); |
|
|
|
|
|
tempCard.repaint(); |
|
|
|
|
|
System.out.println("Turn"+tempCard.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//System.out.println("Karte in StartStack"+com.toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
((BaseStack)com.getParent()).removeLastCard(); |
|
|
|
|
|
|
|
|
//save.addCard(((BaseStack)com.getParent()).removeLastCard());; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|