Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

59 lines
1.8KB

  1. /*------------ -------------- -------- --- ----- --- -- - -
  2. * Libre Blackjack - stdio player
  3. *
  4. * Copyright (C) 2020 jeremy theler
  5. *
  6. * This file is part of Libre Blackjack.
  7. *
  8. * Libre Blackjack is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Libre Blackjack is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Libre Blackjack. If not, see <http://www.gnu.org/licenses/>.
  20. *------------------- ------------ ---- -------- -- - - -
  21. */
  22. #ifndef STDINOUT_H
  23. #define STDINOUT_H
  24. #include "blackjack.h"
  25. #include <algorithm>
  26. #include <functional>
  27. #include <cctype>
  28. #include <locale>
  29. class StdInOut : public Player {
  30. public:
  31. StdInOut(Configuration &);
  32. ~StdInOut() { };
  33. int play(void) override;
  34. void info(Libreblackjack::Info = Libreblackjack::Info::None, int = 0, int = 0) override;
  35. private:
  36. std::string input_buffer;
  37. std::size_t handToSplit;
  38. unsigned int cardToSplit;
  39. inline void ltrim(std::string &s) {
  40. s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { return !std::isspace(ch); }));
  41. };
  42. inline void rtrim(std::string &s) {
  43. s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { return !std::isspace(ch); }).base(), s.end());
  44. };
  45. inline void trim(std::string &s) { ltrim(s); rtrim(s); };
  46. };
  47. #endif