deck.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef DECK_H
  2. #define DECK_H
  3. #include "door.h"
  4. #include <random>
  5. #include <string>
  6. #include <utility> // pair
  7. #include <vector>
  8. /*
  9. I tried card_height = 5, but the cards looked a little too stretched out/tall.
  10. 3 looks good.
  11. layout, rev2:
  12. 12345678901234567890123456789012345678901234567890123456789012345678901234567890
  13. +---------------------------------+
  14. Space Ace - Tri-Peaks Solitaire
  15. +---------------------------------+
  16. Cards start at 0, not 1!
  17. ░░1░░ ░░2░░ ░░3░░
  18. ░░░░░ ░░░░░ ░░░░░
  19. ▒▒4▒▒░░░▒▒5▒▒ ##6##░░░##7## ##8##░░░##9##
  20. ▒▒▒▒▒ ▒▒▒▒▒ ##### ##### ##### #####
  21. ▓▓10▓▒▒▒▓▓11▓▒▒▒▓▓12▓ ##13#===##14#===##15# ##16#===##17#===##18#
  22. ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ##### ##### ##### ##### ##### #####
  23. ██19█▓▓▓██20█▓▓▓██21█▓▓▓##22#===##23#===##24#===##25#===##26#===##27#===##28#
  24. █████ █████ █████ ##### ##### ##### ##### ##### ##### #####
  25. █████ █████ █████ ##### ##### ##### ##### ##### ##### #####
  26. Name: ##30# --29- Playing: December 31
  27. Score: ##### ----- Current Streak: nn
  28. Time used: xxx / XXX left ##### ----- Longest Streak: nn
  29. Playing Hand X of X Cards left XX
  30. 1234567890123456789012345 123456789012345 12345678901234567890
  31. [4/<] Left [6/>] Right [Space] Play Card [Enter] Draw [Q]uit [R]edraw [H]elp
  32. ^ -- above is 20 lines from +-- to [4/<] < Left
  33. score_panel left_panel streak_panel
  34. command_panel
  35. #####
  36. Player Information ##### Time in: xx Time out: xx
  37. Name: ##### Playing Day: November 3rd
  38. Hand Score : Current Streak: N
  39. Todays Score : XX Cards Remaining Longest Streak: NN
  40. Monthly Score: Playing Hand X of X Most Won: xxx Lost: xxx
  41. [4] Lf [6] Rt [Space] Play Card [Enter] Draw [D]one [H]elp [R]edraw
  42. layout, rev1:
  43. ░░░░░ ░░░░░ ░░░░░
  44. ░░░░░ ░░░░░ ░░░░░
  45. ▒▒▒▒▒░▒▒▒▒▒ #####░##### #####░#####
  46. ▒▒▒▒▒ ▒▒▒▒▒ ##### ##### ##### #####
  47. ▓▓▓▓▓▒▓▓▓▓▓▒▓▓▓▓▓ #####=#####=##### #####=#####=#####
  48. ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ##### ##### ##### ##### ##### #####
  49. █████▓█████▓█████▓#####=#####=#####=#####=#####=#####=#####
  50. █████ █████ █████ ##### ##### ##### ##### ##### ##### #####
  51. █████ █████ █████ ##### ##### ##### ##### ##### ##### #####
  52. #####
  53. Player Information ##### Time in: xx Time out: xx
  54. Name: ##### Playing Day: November 3rd
  55. Hand Score : Current Streak: N
  56. Todays Score : XX Cards Remaining Longest Streak: NN
  57. Monthly Score: Playing Hand X of X Most Won: xxx Lost: xxx
  58. [4] Lf [6] Rt [Space] Play Card [Enter] Draw [D]one [H]elp [R]edraw
  59. Spacing 1 or 3. 1 is what was used before, 3 looks better, takes up more
  60. screenspace. And I have plenty, even on 80x23.
  61. TODO: Have functions that gives me:
  62. int deck(int c); // which deck #
  63. int suit(int c); // suit
  64. int rank(int c); // rank
  65. */
  66. typedef std::vector<int> cards; // or a "deck"
  67. class Deck {
  68. private:
  69. // We assume for this game that there's only one deck back color.
  70. door::ANSIColor cardback;
  71. // shared_ptr<door::Panel> for the win?
  72. vector<door::Panel *> cards;
  73. vector<door::Panel *> backs;
  74. vector<door::Panel *> mark;
  75. door::Panel *card_of(int c);
  76. std::string back_char(int level);
  77. door::Panel *back_of(int level);
  78. door::Panel *mark_of(int c);
  79. void init(void);
  80. char rank_symbol(int c);
  81. std::string suit_symbol(int c);
  82. int card_height;
  83. public:
  84. enum SUIT { HEART, DIAMOND, CLUBS, SPADE };
  85. Deck(int size = 3);
  86. // Deck(const Deck &) = default;
  87. Deck(Deck &&);
  88. Deck &operator=(Deck &&);
  89. Deck(door::ANSIColor backcolor, int size = 3);
  90. ~Deck();
  91. int is_rank(int c);
  92. int is_suit(int c);
  93. int is_deck(int c);
  94. bool can_play(int card1, int card2);
  95. door::Panel *card(int c);
  96. door::Panel *back(int level);
  97. door::Panel *marker(int c);
  98. void part(int x, int y, door::Door &d, int level, bool left);
  99. std::vector<int> unblocks(int card);
  100. const static std::array<std::pair<int, int>, 18> blocks;
  101. void remove_card(door::Door &door, int c, int off_x, int off_y, bool left,
  102. bool right);
  103. };
  104. void cardgo(int pos, int &x, int &y, int &level);
  105. cards card_shuffle(std::seed_seq &seed, int decks = 1);
  106. cards card_states(int decks = 1);
  107. int find_next(bool left, const cards &states, int current);
  108. int find_next_closest(const cards &states, int current);
  109. extern vector<std::string> deck_colors;
  110. door::renderFunction makeColorRender(door::ANSIColor c1, door::ANSIColor c2,
  111. door::ANSIColor c3);
  112. door::ANSIColor from_string(std::string colorCode);
  113. std::string from_color_option(int opt);
  114. void string_toupper(std::string &str);
  115. #endif