deck.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "door.h"
  2. #include <random>
  3. #include <string>
  4. #include <vector>
  5. /*
  6. I tried card_height = 5, but the cards looked a little too stretched out/tall.
  7. 3 looks good.
  8. Spacing 1 or 3. 1 is what was used before, 3 looks better, takes up more
  9. screenspace. And I have plenty, even on 80x23.
  10. TODO: Have functions that gives me:
  11. int deck(int c); // which deck #
  12. int suit(int c); // suit
  13. int rank(int c); // rank
  14. */
  15. class Deck {
  16. private:
  17. door::ANSIColor cardback;
  18. vector<door::Panel *> cards;
  19. vector<door::Panel *> backs;
  20. door::Panel *card_of(int c);
  21. std::string back_char(int level);
  22. door::Panel *back_of(int level);
  23. int is_rank(int c);
  24. int is_suit(int c);
  25. void init(void);
  26. char rank_symbol(int c);
  27. std::string suit_symbol(int c);
  28. int card_height;
  29. public:
  30. enum SUIT { HEART, DIAMOND, CLUBS, SPADE };
  31. Deck(int size = 3);
  32. Deck(door::ANSIColor backcolor, int size = 3);
  33. ~Deck();
  34. door::Panel *card(int c);
  35. door::Panel *back(int level);
  36. void part(int x, int y, door::Door &d, int level, bool left);
  37. };
  38. /**
  39. * @brief Given a position, space=3, height=3, return x,y and level.
  40. *
  41. * @param pos
  42. * @param space
  43. * @param h
  44. * @param x
  45. * @param y
  46. * @param level
  47. */
  48. void cardgo(int pos, int space, int h, int &x, int &y, int &level);
  49. /**
  50. * @brief shuffle deck of cards
  51. *
  52. * example of seeding the deck for a given date 2/27/2021 game 1
  53. * std::seed_seq s1{2021, 2, 27, 1};
  54. * vector<int> deck1 = card_shuffle(s1, 1);
  55. * @param seed
  56. * @param decks
  57. * @return vector<int>
  58. */
  59. vector<int> card_shuffle(std::seed_seq &seed, int decks = 1);