Nur die besten Spiele ;3
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

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package solitaer;
  2. import java.awt.Color;
  3. import java.awt.Graphics;
  4. public class StartStack extends BaseStack {
  5. private static final long serialVersionUID = 1L;
  6. public StartStack(int _x, int _y) {
  7. super(true);
  8. super.setLocation(_x, _y);
  9. super.setSize(IMAGE_WIDTH, STACK_HIGHT);
  10. super.setOpaque(false);
  11. super.setLayout(null);
  12. }
  13. public boolean cardCheck(Card _topStack, Card _playerCard) {
  14. if (_topStack == null && _playerCard == null) {
  15. return false;
  16. }
  17. if (_topStack == null) {
  18. // Nur der König kann auf einen leeren Stapel gelegt werden
  19. return _playerCard.getNr() == 13;
  20. } else if (!_topStack.isFaceUp()) {
  21. return false;
  22. } else {
  23. return (// Nummer nur aufsteigend
  24. (_topStack.getNr() == _playerCard.getNr() + 1) &&
  25. // rot auf Schwarz
  26. ((_topStack.isred() && _playerCard.isblack()) ||
  27. // schwarz auf rot
  28. (_topStack.isblack() && _playerCard.isred())));
  29. }
  30. }
  31. @Override
  32. protected void paintComponent(Graphics g) {
  33. // TODO Auto-generated method stub
  34. super.paintComponent(g);
  35. if (stackIsEmpty()) {
  36. g.setColor(Color.gray);
  37. g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT);
  38. g.setColor(Color.black);
  39. g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1);
  40. }
  41. }
  42. }