You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
package solitaer;
|
|
|
|
import java.awt.Color;
|
|
import java.awt.Graphics;
|
|
|
|
public class StartStack extends BaseStack {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
public StartStack(int _x, int _y) {
|
|
super(true);
|
|
super.setLocation(_x, _y);
|
|
super.setSize(IMAGE_WIDTH, STACK_HIGHT);
|
|
super.setOpaque(false);
|
|
super.setLayout(null);
|
|
}
|
|
|
|
public boolean cardCheck(Card _topStack, Card _playerCard) {
|
|
if (_topStack == null && _playerCard == null) {
|
|
return false;
|
|
}
|
|
if (_topStack == null) {
|
|
// Nur der König kann auf einen leeren Stapel gelegt werden
|
|
return _playerCard.getNr() == 13;
|
|
} else if (!_topStack.isFaceUp()) {
|
|
return false;
|
|
} else {
|
|
return (// Nummer nur aufsteigend
|
|
(_topStack.getNr() == _playerCard.getNr() + 1) &&
|
|
// rot auf Schwarz
|
|
((_topStack.isred() && _playerCard.isblack()) ||
|
|
// schwarz auf rot
|
|
(_topStack.isblack() && _playerCard.isred())));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void paintComponent(Graphics g) {
|
|
// TODO Auto-generated method stub
|
|
super.paintComponent(g);
|
|
if (stackIsEmpty()) {
|
|
g.setColor(Color.gray);
|
|
g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT);
|
|
|
|
g.setColor(Color.black);
|
|
g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1);
|
|
}
|
|
}
|
|
|
|
}
|