Browse Source

Add MousInput GeberStack

feature_solitaer_Geber-_WasteStack
Alexander Hartung 3 years ago
parent
commit
ae20cbcbae
  1. 4
      src/main/java/solitaer/GeberStack.java
  2. 23
      src/main/java/solitaer/MyMouseListener.java
  3. 13
      src/main/java/solitaer/SolitaerGamePanel.java

4
src/main/java/solitaer/GeberStack.java

@ -25,7 +25,9 @@ public class GeberStack extends BaseStack {
public void swapWasteGeber() { public void swapWasteGeber() {
while(wasteStack.stackIsEmpty() == false) { while(wasteStack.stackIsEmpty() == false) {
this.addCard(wasteStack.removeLastCard());
Card card = wasteStack.removeLastCard();
card.setFaceUp(false);
this.addCard(card);
} }
} }

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

@ -105,9 +105,32 @@ public class MyMouseListener implements MouseInputListener {
} }
} }
// GeberStack
else if (com.getParent() instanceof GeberStack || com instanceof GeberStack) {
System.out.println("GeberStack");
if (com instanceof GeberStack) {
tempStack = (GeberStack) com;
} else {
tempStack = (GeberStack) com.getParent();
}
if (tempStack.stackIsEmpty()) {
// Move all from Waste to Geber
((GeberStack) this.tempStack).swapWasteGeber();
} else {
// Move next card to Waste
tempCard = tempStack.removeLastCard();
tempCard.setFaceUp(true);
((GeberStack) this.tempStack).getWastStack()
.addCard(tempCard);
} }
}
}
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()) {

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

@ -80,6 +80,19 @@ public class SolitaerGamePanel extends JPanel {
WasteStack w = new WasteStack(85, 10); WasteStack w = new WasteStack(85, 10);
GeberStack g = new GeberStack(10, 10, w); GeberStack g = new GeberStack(10, 10, w);
deck.getDeck().get(34).setFaceUp(true);
w.addCard(deck.getDeck().get(34));
deck.getDeck().get(35).setFaceUp(true);
w.addCard(deck.getDeck().get(35));
deck.getDeck().get(36).setFaceUp(true);
w.addCard(deck.getDeck().get(36));
deck.getDeck().get(37).setFaceUp(true);
w.addCard(deck.getDeck().get(37));
g.addCard(deck.getDeck().get(38));
this.add(w); this.add(w);
this.add(g); this.add(g);

Loading…
Cancel
Save