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.
59 lines
1.4 KiB
59 lines
1.4 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();
|
|
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 {
|
|
return (// Nummer nur aufsteigend
|
|
_topStack.getNr() == _playerCard.getNr() + 1)
|
|
&&
|
|
// rot auf Schwarz
|
|
(
|
|
((_topStack.getSymbol() == Symbol.Herz || _topStack.getSymbol() == Symbol.Karo)
|
|
&& (_playerCard.getSymbol() == Symbol.Pik || _playerCard.getSymbol() == Symbol.Kreuz))
|
|
||
|
|
// schwarz auf rot
|
|
((_topStack.getSymbol() == Symbol.Pik || _topStack.getSymbol() == Symbol.Kreuz)
|
|
&& (_playerCard.getSymbol() == Symbol.Herz || _playerCard.getSymbol() == Symbol.Karo))
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|