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.

63 lines
1.5 KiB

  1. package solitaer;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. public class AblageStack extends BaseStack {
  6. private static final long serialVersionUID = 1L;
  7. private Symbol sym;
  8. public AblageStack(int _x, int _y, Symbol _sym) {
  9. super(false);
  10. super.setLocation(_x, _y);
  11. super.setSize(IMAGE_WIDTH, STACK_HIGHT);
  12. super.setOpaque(false);
  13. super.setLayout(null);
  14. this.sym = _sym;
  15. }
  16. @Override
  17. protected boolean cardCheck(Card _topStack, Card _playerCard) {
  18. if(_topStack == null && _playerCard == null) {
  19. return false;
  20. }
  21. if(_playerCard.getSymbol() != this.sym) {
  22. return false;
  23. } else if(_topStack == null) {
  24. //nur ein Ass darf auf einen Leeren Stabel gelegt werden
  25. return _playerCard.getNr() == 1;
  26. } else {
  27. return _topStack.getNr() == _playerCard.getNr() - 1;
  28. }
  29. }
  30. @Override
  31. protected void paintComponent(Graphics g) {
  32. // TODO Auto-generated method stub
  33. super.paintComponent(g);
  34. if (stackIsEmpty()) {
  35. g.setColor(Color.gray);
  36. g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT);
  37. g.setColor(Color.black);
  38. g.drawRect(0, 0, this.getWidth()-1, IMAGE_HIGHT-1);
  39. if (this.sym == Symbol.Herz || this.sym == Symbol.Karo)
  40. g.setColor(Color.red);
  41. else
  42. g.setColor(Color.black);
  43. int fontSize = 20;
  44. Font f = new Font(Font.MONOSPACED, Font.BOLD, fontSize);
  45. g.setFont(f);
  46. String text = this.sym.toString();
  47. g.drawString(text, 5, this.IMAGE_HIGHT/2);
  48. }
  49. }
  50. }