rpgame.mvc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import models/SimpleClassDiagrams as SCD
  2. include "primitives.alh"
  3. include "object_operations.alh"
  4. SCD RPGame{
  5. Class Tile {
  6. $
  7. Element associations
  8. Element back_associations
  9. Element association
  10. String destination
  11. associations = allOutgoingAssociationInstances(model, name, "tile_left")
  12. while (0 < list_len(associations)):
  13. association = set_pop(associations)
  14. destination = readAssociationDestination(model, association)
  15. back_associations = allOutgoingAssociationInstances(model, destination, "tile_right")
  16. if (list_len(back_associations) < 1):
  17. return "Left link does not have a right link back"!
  18. else:
  19. association = set_pop(back_associations)
  20. destination = readAssociationDestination(model, association)
  21. if (destination != name):
  22. return "Right link does not have a left link back to the same tile"!
  23. associations = allOutgoingAssociationInstances(model, name, "tile_right")
  24. while (0 < list_len(associations)):
  25. association = set_pop(associations)
  26. destination = readAssociationDestination(model, association)
  27. back_associations = allOutgoingAssociationInstances(model, destination, "tile_left")
  28. if (list_len(back_associations) < 1):
  29. return "Right link does not have a left link back"!
  30. else:
  31. association = set_pop(back_associations)
  32. destination = readAssociationDestination(model, association)
  33. if (destination != name):
  34. return "Right link does not have a left link back to the same tile"!
  35. associations = allOutgoingAssociationInstances(model, name, "tile_top")
  36. while (0 < list_len(associations)):
  37. association = set_pop(associations)
  38. destination = readAssociationDestination(model, association)
  39. back_associations = allOutgoingAssociationInstances(model, destination, "tile_bottom")
  40. if (list_len(back_associations) < 1):
  41. return "Top link does not have a bottom link back"!
  42. else:
  43. association = set_pop(back_associations)
  44. destination = readAssociationDestination(model, association)
  45. if (destination != name):
  46. return "Top link does not have a bottom link back to the same tile"!
  47. associations = allOutgoingAssociationInstances(model, name, "tile_bottom")
  48. while (0 < list_len(associations)):
  49. association = set_pop(associations)
  50. destination = readAssociationDestination(model, association)
  51. back_associations = allOutgoingAssociationInstances(model, destination, "tile_top")
  52. if (list_len(back_associations) < 1):
  53. return "Bottom link does not have a top link back"!
  54. else:
  55. association = set_pop(back_associations)
  56. destination = readAssociationDestination(model, association)
  57. if (destination != name):
  58. return "Bottom link does not have a top link back to the same tile"!
  59. return "OK"!
  60. $
  61. }
  62. Association tile_left (Tile, Tile){
  63. source_upper_cardinality = 1
  64. target_upper_cardinality = 1
  65. }
  66. Association tile_right (Tile, Tile){
  67. source_upper_cardinality = 1
  68. target_upper_cardinality = 1
  69. }
  70. Association tile_top (Tile, Tile){
  71. source_upper_cardinality = 1
  72. target_upper_cardinality = 1
  73. }
  74. Association tile_bottom (Tile, Tile){
  75. source_upper_cardinality = 1
  76. target_upper_cardinality = 1
  77. }
  78. Class Scene {}
  79. Association Scene_has_tiles (Scene, Tile){
  80. source_lower_cardinality = 1
  81. source_upper_cardinality = 1
  82. target_lower_cardinality = 1
  83. }
  84. Class Item {}
  85. Association Item_on_tile (Item, Tile){
  86. source_upper_cardinality = 1
  87. target_lower_cardinality = 1
  88. target_upper_cardinality = 1
  89. }
  90. Class Goal : Item {}
  91. Class Character {}
  92. Association Character_on_tile (Character, Tile){
  93. source_upper_cardinality = 1
  94. target_lower_cardinality = 1
  95. target_upper_cardinality = 1
  96. }
  97. Class Hero : Character {}
  98. }
  99. export RPGame to models/RPGame
  100. RPGame my_game {
  101. Scene scene {}
  102. Hero link {}
  103. Goal goal {}
  104. Tile tile_00 {}
  105. Tile tile_01 {}
  106. Tile tile_10 {}
  107. Tile tile_11 {}
  108. Scene_has_tiles (scene, tile_00) {}
  109. Scene_has_tiles (scene, tile_01) {}
  110. Scene_has_tiles (scene, tile_10) {}
  111. Scene_has_tiles (scene, tile_11) {}
  112. Character_on_tile (link, tile_00) {}
  113. Item_on_tile (goal, tile_11) {}
  114. tile_left (tile_01, tile_00) {}
  115. tile_right (tile_00, tile_01) {}
  116. tile_left (tile_11, tile_10) {}
  117. tile_right (tile_10, tile_11) {}
  118. tile_top (tile_10, tile_00) {}
  119. tile_bottom (tile_00, tile_10) {}
  120. tile_top (tile_11, tile_01) {}
  121. tile_bottom (tile_01, tile_11) {}
  122. }
  123. export my_game to models/my_game