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.

84 lines
3.1KB

  1. #include <utility>
  2. #include "any.h"
  3. #include "memory_Context.h"
  4. libany::any memory_Context::field(const std::string &fieldName) {
  5. if (fieldName == "didLaunch") {
  6. return didLaunch;
  7. } else if (fieldName == "exit") {
  8. return exit;
  9. } else if (fieldName == "hiddenItems") {
  10. return hiddenItems;
  11. } else if (fieldName == "input") {
  12. return input;
  13. } else if (fieldName == "mismatchedItems") {
  14. return mismatchedItems;
  15. } else if (fieldName == "outputGoOn") {
  16. return outputGoOn;
  17. } else if (fieldName == "outputGreeting") {
  18. return outputGreeting;
  19. } else if (fieldName == "outputHelp") {
  20. return outputHelp;
  21. } else if (fieldName == "outputMatchedItems") {
  22. return outputMatchedItems;
  23. } else if (fieldName == "outputMismatchedItems") {
  24. return outputMismatchedItems;
  25. } else if (fieldName == "outputPromptSelection") {
  26. return outputPromptSelection;
  27. } else if (fieldName == "outputVictory") {
  28. return outputVictory;
  29. } else if (fieldName == "playfieldItems") {
  30. return playfieldItems;
  31. } else if (fieldName == "playfieldSize") {
  32. return playfieldSize;
  33. } else if (fieldName == "selectedId") {
  34. return selectedId;
  35. } else if (fieldName == "selectedItems") {
  36. return selectedItems;
  37. }
  38. // victory
  39. return victory;
  40. }
  41. void memory_Context::setField(const std::string &fieldName, libany::any value) {
  42. if (fieldName == "didLaunch") {
  43. didLaunch = libany::any_cast<bool>(value);
  44. } else if (fieldName == "exit") {
  45. exit = libany::any_cast<bool>(value);
  46. } else if (fieldName == "hiddenItems") {
  47. hiddenItems = libany::any_cast<std::vector<int> >(value);
  48. } else if (fieldName == "input") {
  49. input = libany::any_cast<std::string>(value);
  50. } else if (fieldName == "mismatchedItems") {
  51. mismatchedItems = libany::any_cast<std::vector<int> >(value);
  52. } else if (fieldName == "outputGoOn") {
  53. outputGoOn = libany::any_cast<std::string>(value);
  54. } else if (fieldName == "outputGreeting") {
  55. outputGreeting = libany::any_cast<std::string>(value);
  56. } else if (fieldName == "outputHelp") {
  57. outputHelp = libany::any_cast<std::string>(value);
  58. } else if (fieldName == "outputMatchedItems") {
  59. outputMatchedItems = libany::any_cast<std::string>(value);
  60. } else if (fieldName == "outputMismatchedItems") {
  61. outputMismatchedItems = libany::any_cast<std::string>(value);
  62. } else if (fieldName == "outputPromptSelection") {
  63. outputPromptSelection = libany::any_cast<std::string>(value);
  64. } else if (fieldName == "outputVictory") {
  65. outputVictory = libany::any_cast<std::string>(value);
  66. } else if (fieldName == "playfieldItems") {
  67. playfieldItems = libany::any_cast<std::map<int, int> >(value);
  68. } else if (fieldName == "playfieldSize") {
  69. playfieldSize = libany::any_cast<int>(value);
  70. } else if (fieldName == "selectedId") {
  71. selectedId = libany::any_cast<int>(value);
  72. } else if (fieldName == "selectedItems") {
  73. selectedItems = libany::any_cast<std::vector<int> >(value);
  74. } else if (fieldName == "victory") {
  75. victory = libany::any_cast<bool>(value);
  76. }
  77. }
  78. memory_Context memory_createContext() {
  79. return memory_Context();
  80. }