Browse Source

Refactor GeberStack

feature_solitaer_Geber-_WasteStack
Alexander Hartung 3 years ago
parent
commit
b2be476c38
  1. 15
      src/main/java/solitaer/GeberStack.java
  2. 14
      src/main/java/solitaer/MyMouseListener.java

15
src/main/java/solitaer/GeberStack.java

@ -25,12 +25,21 @@ public class GeberStack extends BaseStack {
public void swapWasteGeber() {
while(wasteStack.stackIsEmpty() == false) {
Card card = wasteStack.removeLastCard();
card.setFaceUp(false);
this.addCard(card);
moveCardTurnFace(wasteStack, this, false);
}
}
public void moveToWaste() {
moveCardTurnFace(this, wasteStack, true);
}
private void moveCardTurnFace(BaseStack _removeStack, BaseStack _addStack, boolean _face) {
Card card = _removeStack.removeLastCard();
card.setFaceUp(_face);
_addStack.addCard(card);
}
@Override
protected boolean cardCheck(Card _topStack, Card _playerCard) {

14
src/main/java/solitaer/MyMouseListener.java

@ -106,30 +106,22 @@ public class MyMouseListener implements MouseInputListener {
}
// GeberStack
else if (com.getParent() instanceof GeberStack || com instanceof 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);
((GeberStack) this.tempStack).moveToWaste();
}
}
}
private void clearSaveStack(BaseStack _ziel) {
// Alles wieder auf den Ursprünglichen Stack packen

Loading…
Cancel
Save