|
@ -32,10 +32,10 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
|
|
|
|
|
public SolitaerGamePanel() { |
|
|
public SolitaerGamePanel() { |
|
|
setLayout(null); |
|
|
setLayout(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); |
|
|
int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); |
|
|
int Offset_y_Save = setLayouty(1); |
|
|
int Offset_y_Save = setLayouty(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JLabel label = new JLabel(); |
|
|
JLabel label = new JLabel(); |
|
|
label.setText("selected Cards"); |
|
|
label.setText("selected Cards"); |
|
|
label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); |
|
|
label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); |
|
@ -43,25 +43,25 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
|
|
|
|
|
save = new SaveStack(Offset_x_Save, Offset_y_Save); |
|
|
save = new SaveStack(Offset_x_Save, Offset_y_Save); |
|
|
this.add(save); |
|
|
this.add(save); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mouseL = new MyMouseListener(save); |
|
|
mouseL = new MyMouseListener(save); |
|
|
this.addMouseListener(mouseL); |
|
|
this.addMouseListener(mouseL); |
|
|
|
|
|
|
|
|
deck = new CardDeck(); |
|
|
|
|
|
deck.shuffelDeck(); |
|
|
|
|
|
|
|
|
// deck = new CardDeck(); |
|
|
|
|
|
// deck.shuffelDeck(); |
|
|
|
|
|
|
|
|
for (int i = 0; i < STARTSTACK_SIZE; i++) { |
|
|
for (int i = 0; i < STARTSTACK_SIZE; i++) { |
|
|
int y = setLayouty(1); |
|
|
int y = setLayouty(1); |
|
|
start[i] = new StartStack(setLayoutX(i), y); |
|
|
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]); |
|
|
|
|
|
|
|
|
// 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++) { |
|
|
for (int i = 0; i < ABLAGESTACK_SIZE; i++) { |
|
@ -84,22 +84,24 @@ public class SolitaerGamePanel extends JPanel { |
|
|
default: |
|
|
default: |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
this.add(ablage[i]); |
|
|
|
|
|
|
|
|
// this.add(ablage[i]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); |
|
|
waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); |
|
|
geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); |
|
|
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); |
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -108,10 +110,54 @@ public class SolitaerGamePanel extends JPanel { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private int setLayouty(int _row) { |
|
|
private int setLayouty(int _row) { |
|
|
if(_row == 1) |
|
|
|
|
|
|
|
|
if (_row == 1) |
|
|
return IMAGE_HIGHT + (OFFSET_STACKS_Y * 3); |
|
|
return IMAGE_HIGHT + (OFFSET_STACKS_Y * 3); |
|
|
else |
|
|
else |
|
|
return OFFSET_STACKS_Y; |
|
|
return OFFSET_STACKS_Y; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void restartGame() { |
|
|
|
|
|
deck = new CardDeck(); |
|
|
|
|
|
deck.shuffelDeck(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < STARTSTACK_SIZE; i++) { |
|
|
|
|
|
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++) { |
|
|
|
|
|
this.add(ablage[i]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|