Browse Source

add MouseInput for AblageStack

feature_solitaer_AblageStack
Alexander Hartung 3 years ago
parent
commit
2cb74cadc9
  1. 35
      src/main/java/solitaer/MyMouseListener.java
  2. 13
      src/main/java/solitaer/SolitaerGamePanel.java

35
src/main/java/solitaer/MyMouseListener.java

@ -78,6 +78,41 @@ public class MyMouseListener implements MouseInputListener {
selectedStack = null; selectedStack = null;
} }
} }
// AblageStack
else if (com.getParent() instanceof AblageStack || com instanceof AblageStack) {
System.out.println("AblageStack");
if (com instanceof AblageStack) {
tempStack = (AblageStack) com;
} else {
tempStack = (AblageStack) com.getParent();
}
if (saveStack.stackIsEmpty()) {
// Move Top Card from AblageStack in Save
if (tempStack.stackIsEmpty() == false) {
saveStack.addCard(tempStack.removeLastCard());
selectedStack = tempStack;
}
} else {
// Move Card from Save in AblageStack
if (saveStack.stackSize() == 1) {
if (tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) {
tempStack.addCard(saveStack.removeLastCard());
}
} else {
// Alles wieder auf den Ursprünglichen Stack packen
while (!saveStack.stackIsEmpty()) {
selectedStack.addCard(saveStack.removeLastCard());
}
}
}
}
} }

13
src/main/java/solitaer/SolitaerGamePanel.java

@ -27,8 +27,6 @@ public class SolitaerGamePanel extends JPanel {
StartStack a = new StartStack(25,125); StartStack a = new StartStack(25,125);
a.addCard(deck.getDeck().get(0));
deck.getDeck().get(5).setFaceUp(true); deck.getDeck().get(5).setFaceUp(true);
a.addCard((deck.getDeck().get(5))); a.addCard((deck.getDeck().get(5)));
@ -44,6 +42,9 @@ public class SolitaerGamePanel extends JPanel {
deck.getDeck().get(1).setFaceUp(true); deck.getDeck().get(1).setFaceUp(true);
a.addCard((deck.getDeck().get(1))); a.addCard((deck.getDeck().get(1)));
deck.getDeck().get(0).setFaceUp(true);
a.addCard(deck.getDeck().get(0));
this.add(a); this.add(a);
StartStack b = new StartStack(200,125); StartStack b = new StartStack(200,125);
@ -54,10 +55,14 @@ public class SolitaerGamePanel extends JPanel {
StartStack c = new StartStack(375,125); StartStack c = new StartStack(375,125);
deck.getDeck().get(33).setFaceUp(true);
c.addCard((deck.getDeck().get(33)));
deck.getDeck().get(13).setFaceUp(true);
c.addCard((deck.getDeck().get(12)));
this.add(c); this.add(c);
StartStack d = new StartStack(475,125);
this.add(d);
//save = new SaveStack(500,250); //save = new SaveStack(500,250);
this.add(save); this.add(save);

Loading…
Cancel
Save