|
|
@ -1,7 +1,6 @@ |
|
|
|
package solitaer; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Font; |
|
|
|
import java.awt.Graphics; |
|
|
|
|
|
|
|
import javax.swing.JLabel; |
|
|
@ -19,6 +18,8 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
|
|
|
|
public final int STARTSTACK_SIZE = 7; |
|
|
|
public final int ABLAGESTACK_SIZE = 4; |
|
|
|
|
|
|
|
private Color backgroundColor = new Color(0, 135, 62); |
|
|
|
|
|
|
|
private CardDeck deck; |
|
|
|
private MyMouseListener mouseL; |
|
|
@ -42,26 +43,13 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
this.add(label); |
|
|
|
|
|
|
|
save = new SaveStack(Offset_x_Save, Offset_y_Save); |
|
|
|
|
|
|
|
|
|
|
|
mouseL = new MyMouseListener(save); |
|
|
|
this.addMouseListener(mouseL); |
|
|
|
|
|
|
|
// deck = new CardDeck(); |
|
|
|
// deck.shuffelDeck(); |
|
|
|
|
|
|
|
for (int i = 0; i < STARTSTACK_SIZE; i++) { |
|
|
|
int y = setLayouty(1); |
|
|
|
start[i] = new StartStack(setLayoutX(i), y); |
|
|
|
// int tmp = i; |
|
|
|
// while (tmp != 0) { |
|
|
|
// start[i].addCard(deck.getDeck().remove(0)); |
|
|
|
// tmp -= 1; |
|
|
|
// } |
|
|
|
// Card card = deck.getDeck().remove(0); |
|
|
|
// card.setFaceUp(true); |
|
|
|
// start[i].addCard(card); |
|
|
|
// this.add(start[i]); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < ABLAGESTACK_SIZE; i++) { |
|
|
@ -84,22 +72,10 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
// this.add(ablage[i]); |
|
|
|
} |
|
|
|
|
|
|
|
waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); |
|
|
|
geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); |
|
|
|
|
|
|
|
// while (deck.getDeck().size() != 1) { |
|
|
|
// geber.addCard(deck.getDeck().remove(0)); |
|
|
|
// } |
|
|
|
// |
|
|
|
// Card card = deck.getDeck().remove(0); |
|
|
|
// card.setFaceUp(true); |
|
|
|
// waste.addCard(card); |
|
|
|
// |
|
|
|
// this.add(waste); |
|
|
|
// this.add(geber); |
|
|
|
|
|
|
|
restartGame(); |
|
|
|
|
|
|
@ -131,11 +107,8 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
card.setFaceUp(true); |
|
|
|
start[i].addCard(card); |
|
|
|
this.add(start[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ABLAGESTACK_SIZE; i++) { |
|
|
|
ablage[i].clearStack(); |
|
|
|
this.add(ablage[i]); |
|
|
@ -146,7 +119,6 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
while (deck.getDeck().size() != 1) { |
|
|
|
geber.addCard(deck.getDeck().remove(0)); |
|
|
|
} |
|
|
|
|
|
|
|
Card card = deck.getDeck().remove(0); |
|
|
|
card.setFaceUp(true); |
|
|
|
waste.addCard(card); |
|
|
@ -154,24 +126,15 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
this.add(waste); |
|
|
|
this.add(geber); |
|
|
|
|
|
|
|
|
|
|
|
save.clearStack(); |
|
|
|
this.add(save); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.add(save); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
// TODO Auto-generated method stub |
|
|
|
super.paintComponent(g); |
|
|
|
g.setColor(new Color(0, 135, 62)); |
|
|
|
g.setColor(backgroundColor); |
|
|
|
g.fillRect(0, 0, this.getWidth(), this.getHeight()); |
|
|
|
} |
|
|
|
} |