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.

86 lines
3.1KB

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