Research portable Memory game | Исследовать портируемую игру Память
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.

53 lines
920B

  1. #include <map>
  2. #include <string>
  3. #include <vector>
  4. #include "cli.h"
  5. #include "cli_Context.h"
  6. #include "memory.h"
  7. #include "memory_Context.h"
  8. #include "shell.h"
  9. // Greet the user upon start
  10. shell_Context shell_launch(
  11. shell_Context c
  12. ) {
  13. c.cCLI = cli_greetUser(c.cCLI);
  14. c.cCLI.input = "help";
  15. c.cCLI = cli_showHelp(c.cCLI);
  16. c.output = c.cCLI.outputGreeting + "\n" + c.cCLI.outputHelp;
  17. return c;
  18. }
  19. // Switch among CLI functions based on input
  20. //
  21. // Conditions:
  22. // 1. User requested to quit the game
  23. // 2. User plays the game
  24. shell_Context shell_processInput(
  25. shell_Context c
  26. ) {
  27. if (
  28. c.input == "e" ||
  29. c.input == "exit" ||
  30. c.input == "q" ||
  31. c.input == "quit"
  32. ) {
  33. c.exit = true;
  34. return c;
  35. }
  36. c.cCLI.input = c.input;
  37. c.output = "";
  38. c.cCLI = cli_showHelp(c.cCLI);
  39. if (
  40. c.cCLI.recentField == "outputHelp"
  41. ) {
  42. c.output += c.cCLI.outputHelp;
  43. }
  44. return c;
  45. }