Browse Source

Refactor MouseInput

feature_solitaer_AblageStack
Alexander Hartung 3 years ago
parent
commit
24f874a09d
  1. 23
      src/main/java/solitaer/MyMouseListener.java

23
src/main/java/solitaer/MyMouseListener.java

@ -65,14 +65,9 @@ public class MyMouseListener implements MouseInputListener {
System.out.println("ERROR selectedStack in StartStack"); System.out.println("ERROR selectedStack in StartStack");
} }
if (tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { if (tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) {
while (!saveStack.stackIsEmpty()) {
tempStack.addCard(saveStack.removeLastCard());
}
clearSaveStack(tempStack);
} else { } else {
// Alles wieder auf den Ursprünglichen Stack packen
while (!saveStack.stackIsEmpty()) {
selectedStack.addCard(saveStack.removeLastCard());
}
clearSaveStack(selectedStack);
} }
selectedStack = null; selectedStack = null;
@ -87,7 +82,6 @@ public class MyMouseListener implements MouseInputListener {
tempStack = (AblageStack) com; tempStack = (AblageStack) com;
} else { } else {
tempStack = (AblageStack) com.getParent(); tempStack = (AblageStack) com.getParent();
} }
if (saveStack.stackIsEmpty()) { if (saveStack.stackIsEmpty()) {
@ -105,10 +99,8 @@ public class MyMouseListener implements MouseInputListener {
} }
} else { } else {
// Alles wieder auf den Ursprünglichen Stack packen
while (!saveStack.stackIsEmpty()) {
selectedStack.addCard(saveStack.removeLastCard());
}
//Clear Save
clearSaveStack(selectedStack);
} }
} }
@ -116,6 +108,13 @@ public class MyMouseListener implements MouseInputListener {
} }
private void clearSaveStack(BaseStack _ziel) {
// Alles wieder auf den Ursprünglichen Stack packen
while (!saveStack.stackIsEmpty()) {
_ziel.addCard(saveStack.removeLastCard());
}
}
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

Loading…
Cancel
Save