You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.7KB

  1. /*------------ -------------- -------- --- ----- --- -- - -
  2. * Libre Blackjack - main function
  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. #include <iostream>
  23. #include "blackjack.h"
  24. #include "stdinout.h"
  25. int main(int argc, char **argv) {
  26. // TODO: read args/conf to see what dealer we need to play
  27. // TODO: pass args/conf to the constructor
  28. Blackjack dealer;
  29. StdInOut player;
  30. std::cout << "Let's play" << std::endl;
  31. dealer.setNextAction(DealerAction::StartNewHand);
  32. Command command = Command::None;
  33. while (!dealer.finished()) {
  34. dealer.setInputNeeded(false);
  35. // TODO: clean buffers
  36. dealer.deal();
  37. if (dealer.getInputNeeded()) {
  38. do {
  39. // TODO: check for too many errors meaning dealer and player do not understand each other
  40. player.play(&command, nullptr);
  41. } while (dealer.process(command) <= 0);
  42. }
  43. }
  44. // TODO: write report
  45. }