deck.h 1.7 KB

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