Browse Source

Add MouseInput WasteStack

feature_solitaer_Geber-_WasteStack
Alexander Hartung 3 years ago
parent
commit
8b93f04144
  1. 26
      src/main/java/solitaer/MyMouseListener.java
  2. 4
      src/main/java/solitaer/SolitaerGamePanel.java

26
src/main/java/solitaer/MyMouseListener.java

@ -99,15 +99,14 @@ public class MyMouseListener implements MouseInputListener {
} }
} else { } else {
//Clear Save
// Clear Save
clearSaveStack(selectedStack); clearSaveStack(selectedStack);
} }
} }
} }
// GeberStack // GeberStack
else if (com.getParent() instanceof GeberStack
|| com instanceof GeberStack) {
else if (com.getParent() instanceof GeberStack || com instanceof GeberStack) {
System.out.println("GeberStack"); System.out.println("GeberStack");
if (com instanceof GeberStack) { if (com instanceof GeberStack) {
tempStack = (GeberStack) com; tempStack = (GeberStack) com;
@ -122,7 +121,28 @@ public class MyMouseListener implements MouseInputListener {
((GeberStack) this.tempStack).moveToWaste(); ((GeberStack) this.tempStack).moveToWaste();
} }
} }
// WasteStack
else if (com.getParent() instanceof WasteStack || com instanceof WasteStack) {
System.out.println("WasteStack");
if (com instanceof WasteStack) {
tempStack = (WasteStack) com;
} else {
tempStack = (WasteStack) com.getParent();
}
if (saveStack.stackIsEmpty()) {
// Move Top Card from AblageStack in Save
if (tempStack.stackIsEmpty() == false) {
saveStack.addCard(tempStack.removeLastCard());
selectedStack = tempStack;
} }
} else {
clearSaveStack(selectedStack);
}
}
}
private void clearSaveStack(BaseStack _ziel) { private void clearSaveStack(BaseStack _ziel) {
// Alles wieder auf den Ursprünglichen Stack packen // Alles wieder auf den Ursprünglichen Stack packen
while (!saveStack.stackIsEmpty()) { while (!saveStack.stackIsEmpty()) {

4
src/main/java/solitaer/SolitaerGamePanel.java

@ -55,8 +55,8 @@ public class SolitaerGamePanel extends JPanel {
StartStack c = new StartStack(375,125); StartStack c = new StartStack(375,125);
deck.getDeck().get(13).setFaceUp(true);
c.addCard((deck.getDeck().get(12)));
deck.getDeck().get(10).setFaceUp(true);
c.addCard((deck.getDeck().get(10)));
this.add(c); this.add(c);

Loading…
Cancel
Save