play.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef PLAY_H
  2. #define PLAY_H
  3. #include "db.h"
  4. #include "deck.h"
  5. #include "door.h"
  6. #include <chrono>
  7. #include <random>
  8. class PlayCards {
  9. private:
  10. door::Door &door;
  11. DBData &db;
  12. std::mt19937 &rng;
  13. int month_last_day;
  14. /**
  15. * These map to the positions on the screen that displays the calendar. This
  16. * allows me to update the days string. Sun - Sat, 6 lines. (7*6)
  17. */
  18. std::array<int, 7 * 6> calendar_panel_days;
  19. /**
  20. * This maps a day to: 0 (available), 1 (has hands left to play), 2 (played),
  21. * 3 (NNY)
  22. */
  23. std::array<int, 31> calendar_day_status;
  24. std::unique_ptr<door::Panel> spaceAceTriPeaks;
  25. std::unique_ptr<door::Panel> score_panel;
  26. std::unique_ptr<door::Panel> streak_panel;
  27. std::unique_ptr<door::Panel> left_panel;
  28. std::unique_ptr<door::Panel> cmd_panel;
  29. std::unique_ptr<door::Panel> next_quit_panel;
  30. std::unique_ptr<door::Screen> calendar;
  31. std::unique_ptr<door::Panel> make_score_panel();
  32. std::unique_ptr<door::Panel> make_tripeaks(void);
  33. std::unique_ptr<door::Panel> make_command_panel(void);
  34. std::unique_ptr<door::Panel> make_streak_panel(void);
  35. std::unique_ptr<door::Panel> make_left_panel(void);
  36. std::unique_ptr<door::Panel> make_next_panel(void);
  37. std::unique_ptr<door::Panel> make_weekdays(void);
  38. std::unique_ptr<door::Panel> make_month(std::string month);
  39. std::unique_ptr<door::Panel> make_calendar_panel(void);
  40. std::unique_ptr<door::Screen> make_calendar(void);
  41. std::string current_month(std::chrono::_V2::system_clock::time_point now);
  42. int press_a_key(void);
  43. int hand;
  44. int total_hands;
  45. int play_card;
  46. int current_streak;
  47. int best_streak;
  48. int select_card; // the card the player selects, has state=1
  49. unsigned long score;
  50. int days_played;
  51. Deck dp; // deckPanels
  52. int off_x, off_y;
  53. const int height = 3;
  54. std::chrono::_V2::system_clock::time_point play_day;
  55. door::ANSIColor deck_color;
  56. cards deck;
  57. cards state;
  58. void redraw(bool dealing);
  59. void bonus(void);
  60. int play_cards(void);
  61. public:
  62. PlayCards(door::Door &d, DBData &dbd, std::mt19937 &r);
  63. ~PlayCards();
  64. int play(void);
  65. void init_values(void);
  66. door::renderFunction statusValue(door::ANSIColor status,
  67. door::ANSIColor value);
  68. door::renderFunction commandLineRender(door::ANSIColor bracket,
  69. door::ANSIColor inner,
  70. door::ANSIColor outer);
  71. };
  72. #endif