play.h 2.5 KB

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