rapid-router 5.4.1__py2.py3-none-any.whl → 7.6.8__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. example_project/rapid_router_test_settings.py +164 -0
  2. example_project/settings.py +152 -0
  3. example_project/urls.py +15 -0
  4. example_project/{example_project/wsgi.py → wsgi.py} +2 -1
  5. game/__init__.py +1 -1
  6. game/admin.py +43 -4
  7. game/app_settings.py +3 -7
  8. game/character.py +26 -18
  9. game/decor.py +172 -97
  10. game/end_to_end_tests/base_game_test.py +44 -33
  11. game/end_to_end_tests/editor_page.py +17 -2
  12. game/end_to_end_tests/game_page.py +127 -45
  13. game/end_to_end_tests/selenium_test_case.py +1 -20
  14. game/end_to_end_tests/test_cow_crashes.py +3 -5
  15. game/end_to_end_tests/test_language_dropdown.py +14 -0
  16. game/end_to_end_tests/test_level_editor.py +290 -0
  17. game/end_to_end_tests/test_level_failures.py +1 -1
  18. game/end_to_end_tests/test_level_selection.py +79 -0
  19. game/end_to_end_tests/test_play_through.py +240 -102
  20. game/end_to_end_tests/test_python_levels.py +44 -13
  21. game/end_to_end_tests/test_saving_workspace.py +22 -0
  22. game/forms.py +9 -2
  23. game/level_management.py +38 -29
  24. game/messages.py +1218 -203
  25. game/migrations/0001_squashed_0025_levels_ordering_pt1.py +19 -1
  26. game/migrations/0026_levels_pt2.py +13 -2
  27. game/migrations/0032_cannot_turn_left_level.py +13 -2
  28. game/migrations/0033_recursion_level.py +13 -2
  29. game/migrations/0034_joes_level.py +13 -2
  30. game/migrations/0035_disable_route_score_level_70.py +0 -2
  31. game/migrations/0036_level_score_73.py +0 -2
  32. game/migrations/0037_level_score_79.py +0 -2
  33. game/migrations/0038_level_score_40.py +0 -1
  34. game/migrations/0042_level_score_73.py +0 -2
  35. game/migrations/0048_add_cow_field_and_blocks.py +0 -2
  36. game/migrations/0049_level_score_34.py +0 -2
  37. game/migrations/0050_level_score_40.py +0 -2
  38. game/migrations/0051_level_score_49.py +0 -1
  39. game/migrations/0076_level_locked_for_class.py +19 -0
  40. game/migrations/0077_alter_level_next_level.py +52 -0
  41. game/migrations/0078_add_block_types.py +23 -0
  42. game/migrations/0079_populate_block_type_add_cow_blocks.py +60 -0
  43. game/migrations/0080_level_disable_algorithm_score.py +18 -0
  44. game/migrations/0081_first_12_levels_no_algo_score.py +29 -0
  45. game/migrations/0082_level_43_solution.py +16 -0
  46. game/migrations/0083_add_cows_to_existing_levels.py +195 -0
  47. game/migrations/0084_alter_block_block_type.py +18 -0
  48. game/migrations/0085_add_new_blocks.py +53 -0
  49. game/migrations/0086_loop_levels.py +482 -0
  50. game/migrations/0087_workspace_python_view_enabled.py +18 -0
  51. game/migrations/0088_rename_episodes.py +35 -0
  52. game/migrations/0089_episodes_in_development.py +30 -0
  53. game/migrations/0090_add_missing_model_solutions.py +144 -0
  54. game/migrations/0091_disable_algo_score_if_no_model_solution.py +46 -0
  55. game/migrations/0092_disable_algo_score_in_custom_levels.py +28 -0
  56. game/migrations/0093_alter_level_character_name.py +18 -0
  57. game/migrations/0094_add_hint_lesson_subtitle_to_levels.py +28 -0
  58. game/migrations/0095_level_commands.py +18 -0
  59. game/migrations/0096_alter_level_commands.py +18 -0
  60. game/migrations/0097_add_python_den_levels.py +1515 -0
  61. game/migrations/0098_add_episode_link_fields.py +44 -0
  62. game/migrations/0099_python_episodes_links.py +103 -0
  63. game/migrations/0100_reorder_python_levels.py +179 -0
  64. game/migrations/0101_rename_episodes.py +45 -0
  65. game/migrations/0102_reoder_episodes_13_14.py +136 -0
  66. game/migrations/0103_level_1015_solution.py +26 -0
  67. game/migrations/0104_remove_level_direct_drive.py +17 -0
  68. game/migrations/0105_delete_invalid_attempts.py +18 -0
  69. game/migrations/0106_fields_to_snake_case.py +48 -0
  70. game/migrations/0107_rename_worksheet_link_episode_student_worksheet_link.py +18 -0
  71. game/migrations/0108_episode_indy_worksheet_link.py +18 -0
  72. game/migrations/0109_create_episodes_23_and_24.py +99 -0
  73. game/migrations/0110_remove_episode_indy_worksheet_link_and_more.py +100 -0
  74. game/migrations/0111_create_worksheets.py +149 -0
  75. game/migrations/0112_worksheet_locked_classes.py +21 -0
  76. game/migrations/0113_level_needs_approval.py +18 -0
  77. game/migrations/0114_default_and_non_student_levels_no_approval.py +31 -0
  78. game/migrations/0115_level_level__default_does_not_need_approval.py +22 -0
  79. game/migrations/0116_update_worksheet_video_links.py +68 -0
  80. game/migrations/0117_update_solutions_to_if_else.py +61 -0
  81. game/models.py +157 -16
  82. game/permissions.py +34 -19
  83. game/python_den_urls.py +26 -0
  84. game/random_road.py +43 -127
  85. game/serializers.py +12 -17
  86. game/static/django_reverse_js/js/reverse.js +171 -0
  87. game/static/game/css/LilitaOne-Regular.ttf +0 -0
  88. game/static/game/css/backgrounds.css +14 -10
  89. game/static/game/css/dataTables.custom.css +4 -2
  90. game/static/game/css/dataTables.jqueryui.css +561 -320
  91. game/static/game/css/editor.css +47 -0
  92. game/static/game/css/game.css +43 -49
  93. game/static/game/css/game_screen.css +116 -53
  94. game/static/game/css/jquery.dataTables.css +455 -251
  95. game/static/game/css/level_editor.css +10 -1
  96. game/static/game/css/level_selection.css +32 -3
  97. game/static/game/css/level_share.css +6 -5
  98. game/static/game/css/skulpt/codemirror.css +1 -0
  99. game/static/game/image/Python_Den_hero_student.png +0 -0
  100. game/static/game/image/Python_levels_page.svg +1954 -0
  101. game/static/game/image/characters/front_view/Electric_van.svg +448 -0
  102. game/static/game/image/characters/top_view/Electric_van.svg +448 -0
  103. game/static/game/image/characters/top_view/Sleigh.svg +436 -0
  104. game/static/game/image/decor/city/solar_panel.svg +1200 -0
  105. game/static/game/image/decor/farm/solar_panel.svg +86 -0
  106. game/static/game/image/decor/grass/solar_panel.svg +86 -0
  107. game/static/game/image/decor/snow/barn.svg +1788 -0
  108. game/static/game/image/decor/snow/cfc.svg +1050 -147
  109. game/static/game/image/decor/snow/crops.svg +7370 -0
  110. game/static/game/image/decor/snow/hospital.svg +1220 -0
  111. game/static/game/image/decor/snow/house1.svg +971 -0
  112. game/static/game/image/decor/snow/house2.svg +1574 -0
  113. game/static/game/image/decor/snow/school.svg +1071 -0
  114. game/static/game/image/decor/snow/shop.svg +3211 -0
  115. game/static/game/image/decor/snow/solar_panel.svg +173 -0
  116. game/static/game/image/electric_van.svg +448 -0
  117. game/static/game/image/icons/add_house.svg +26 -0
  118. game/static/game/image/icons/delete_house.svg +26 -0
  119. game/static/game/image/icons/description.svg +1 -0
  120. game/static/game/image/icons/hint.svg +1 -0
  121. game/static/game/image/icons/if_else.svg +3 -0
  122. game/static/game/image/icons/python.svg +1 -1
  123. game/static/game/image/if_else_example.png +0 -0
  124. game/static/game/image/pigeon.svg +684 -0
  125. game/static/game/image/python_den_header.svg +19 -0
  126. game/static/game/js/animation.js +84 -28
  127. game/static/game/js/blockly/msg/js/bg.js +52 -1
  128. game/static/game/js/blockly/msg/js/ca.js +52 -1
  129. game/static/game/js/blockly/msg/js/en-gb.js +52 -1
  130. game/static/game/js/blockly/msg/js/en.js +52 -1
  131. game/static/game/js/blockly/msg/js/es.js +52 -1
  132. game/static/game/js/blockly/msg/js/fr.js +52 -1
  133. game/static/game/js/blockly/msg/js/hi.js +52 -1
  134. game/static/game/js/blockly/msg/js/it.js +52 -1
  135. game/static/game/js/blockly/msg/js/pl.js +52 -1
  136. game/static/game/js/blockly/msg/js/pt-br.js +52 -1
  137. game/static/game/js/blockly/msg/js/ru.js +52 -1
  138. game/static/game/js/blockly/msg/js/ur.js +52 -1
  139. game/static/game/js/blocklyCompiler.js +550 -392
  140. game/static/game/js/blocklyControl.js +335 -302
  141. game/static/game/js/blocklyCustomBlocks.js +691 -458
  142. game/static/game/js/blocklyCustomisations.js +3 -1
  143. game/static/game/js/button.js +12 -0
  144. game/static/game/js/cow.js +15 -130
  145. game/static/game/js/drawing.js +313 -201
  146. game/static/game/js/editor.js +23 -0
  147. game/static/game/js/game.js +148 -139
  148. game/static/game/js/jquery.dataTables.min.js +3 -159
  149. game/static/game/js/level_editor.js +823 -448
  150. game/static/game/js/level_moderation.js +33 -2
  151. game/static/game/js/level_selection.js +62 -25
  152. game/static/game/js/loadLanguages.js +21 -0
  153. game/static/game/js/map.js +106 -36
  154. game/static/game/js/model.js +55 -107
  155. game/static/game/js/pathFinder.js +73 -72
  156. game/static/game/js/program.js +184 -193
  157. game/static/game/js/pythonControl.js +14 -1
  158. game/static/game/js/scoreboard.js +0 -37
  159. game/static/game/js/scoreboardSharedLevels.js +48 -0
  160. game/static/game/js/sharing.js +22 -10
  161. game/static/game/js/skulpt/codemirror.js +5 -4
  162. game/static/game/js/skulpt/skulpt-stdlib.js +1 -1
  163. game/static/game/js/sound.js +52 -5
  164. game/static/game/js/van.js +0 -7
  165. game/static/game/raphael_image/characters/top_view/Electric_van.svg +448 -0
  166. game/static/game/raphael_image/characters/top_view/Sleigh.svg +436 -0
  167. game/static/game/raphael_image/decor/city/solar_panel.svg +1200 -0
  168. game/static/game/raphael_image/decor/farm/solar_panel.svg +86 -0
  169. game/static/game/raphael_image/decor/grass/solar_panel.svg +86 -0
  170. game/static/game/raphael_image/decor/snow/barn.svg +1788 -0
  171. game/static/game/raphael_image/decor/snow/cfc.svg +1050 -147
  172. game/static/game/raphael_image/decor/snow/crops.svg +7370 -0
  173. game/static/game/raphael_image/decor/snow/hospital.svg +1220 -0
  174. game/static/game/raphael_image/decor/snow/house1.svg +971 -0
  175. game/static/game/raphael_image/decor/snow/house2.svg +1574 -0
  176. game/static/game/raphael_image/decor/snow/school.svg +1071 -0
  177. game/static/game/raphael_image/decor/snow/shop.svg +3211 -0
  178. game/static/game/raphael_image/decor/snow/solar_panel.svg +173 -0
  179. game/static/game/raphael_image/pigeon.svg +685 -0
  180. game/static/game/raphael_image/sleigh_wreckage.svg +430 -0
  181. game/static/game/sass/game.scss +22 -6
  182. game/static/game/sound/clown_horn.mp3 +0 -0
  183. game/static/game/sound/clown_horn.ogg +0 -0
  184. game/static/game/sound/electric_van_starting.mp3 +0 -0
  185. game/static/game/sound/electric_van_starting.ogg +0 -0
  186. game/static/game/sound/pigeon.mp3 +0 -0
  187. game/static/game/sound/pigeon.ogg +0 -0
  188. game/static/game/sound/sleigh_bells.mp3 +0 -0
  189. game/static/game/sound/sleigh_bells.ogg +0 -0
  190. game/static/game/sound/sleigh_crash.mp3 +0 -0
  191. game/static/game/sound/sleigh_crash.ogg +0 -0
  192. game/templates/game/base.html +35 -15
  193. game/templates/game/basenonav.html +23 -17
  194. game/templates/game/game.html +236 -111
  195. game/templates/game/level_editor.html +353 -275
  196. game/templates/game/level_moderation.html +19 -6
  197. game/templates/game/level_selection.html +75 -62
  198. game/templates/game/python_den_level_selection.html +291 -0
  199. game/templates/game/python_den_worksheet.html +101 -0
  200. game/templates/game/scoreboard.html +88 -65
  201. game/tests/test_level_editor.py +210 -35
  202. game/tests/test_level_moderation.py +6 -20
  203. game/tests/test_level_selection.py +332 -11
  204. game/tests/test_python_den_worksheet.py +85 -0
  205. game/tests/test_scoreboard.py +258 -66
  206. game/tests/utils/level.py +43 -3
  207. game/tests/utils/teacher.py +2 -2
  208. game/theme.py +21 -21
  209. game/urls.py +125 -78
  210. game/views/language_code_conversions.py +90 -0
  211. game/views/level.py +201 -63
  212. game/views/level_editor.py +109 -48
  213. game/views/level_moderation.py +29 -6
  214. game/views/level_selection.py +179 -56
  215. game/views/level_solutions.py +600 -106
  216. game/views/scoreboard.py +181 -66
  217. game/views/worksheet.py +25 -0
  218. rapid_router-7.6.8.dist-info/METADATA +174 -0
  219. {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/RECORD +222 -242
  220. {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/WHEEL +1 -1
  221. rapid_router-7.6.8.dist-info/licenses/LICENSE.md +3 -0
  222. example_project/example_project/__init__.py +0 -1
  223. example_project/example_project/settings.py +0 -54
  224. example_project/example_project/urls.py +0 -16
  225. example_project/manage.py +0 -10
  226. game/autoconfig.py +0 -59
  227. game/csp_config.py +0 -23
  228. game/locale/ar_SA/LC_MESSAGES/django.mo +0 -0
  229. game/locale/ar_SA/LC_MESSAGES/django.po +0 -405
  230. game/locale/ar_SA/LC_MESSAGES/djangojs.mo +0 -0
  231. game/locale/ar_SA/LC_MESSAGES/djangojs.po +0 -743
  232. game/locale/bg_BG/LC_MESSAGES/django.mo +0 -0
  233. game/locale/bg_BG/LC_MESSAGES/django.po +0 -405
  234. game/locale/bg_BG/LC_MESSAGES/djangojs.mo +0 -0
  235. game/locale/bg_BG/LC_MESSAGES/djangojs.po +0 -739
  236. game/locale/ca_ES/LC_MESSAGES/django.mo +0 -0
  237. game/locale/ca_ES/LC_MESSAGES/django.po +0 -405
  238. game/locale/ca_ES/LC_MESSAGES/djangojs.mo +0 -0
  239. game/locale/ca_ES/LC_MESSAGES/djangojs.po +0 -740
  240. game/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  241. game/locale/cs_CZ/LC_MESSAGES/django.po +0 -405
  242. game/locale/cs_CZ/LC_MESSAGES/djangojs.mo +0 -0
  243. game/locale/cs_CZ/LC_MESSAGES/djangojs.po +0 -741
  244. game/locale/cy_GB/LC_MESSAGES/django.mo +0 -0
  245. game/locale/cy_GB/LC_MESSAGES/django.po +0 -405
  246. game/locale/cy_GB/LC_MESSAGES/djangojs.mo +0 -0
  247. game/locale/cy_GB/LC_MESSAGES/djangojs.po +0 -743
  248. game/locale/de_DE/LC_MESSAGES/django.mo +0 -0
  249. game/locale/de_DE/LC_MESSAGES/django.po +0 -405
  250. game/locale/de_DE/LC_MESSAGES/djangojs.mo +0 -0
  251. game/locale/de_DE/LC_MESSAGES/djangojs.po +0 -739
  252. game/locale/el_GR/LC_MESSAGES/django.mo +0 -0
  253. game/locale/el_GR/LC_MESSAGES/django.po +0 -405
  254. game/locale/el_GR/LC_MESSAGES/djangojs.mo +0 -0
  255. game/locale/el_GR/LC_MESSAGES/djangojs.po +0 -739
  256. game/locale/en_GB/LC_MESSAGES/django.mo +0 -0
  257. game/locale/en_GB/LC_MESSAGES/django.po +0 -405
  258. game/locale/en_GB/LC_MESSAGES/djangojs.mo +0 -0
  259. game/locale/en_GB/LC_MESSAGES/djangojs.po +0 -739
  260. game/locale/es_ES/LC_MESSAGES/django.mo +0 -0
  261. game/locale/es_ES/LC_MESSAGES/django.po +0 -405
  262. game/locale/es_ES/LC_MESSAGES/djangojs.mo +0 -0
  263. game/locale/es_ES/LC_MESSAGES/djangojs.po +0 -739
  264. game/locale/fi_FI/LC_MESSAGES/django.mo +0 -0
  265. game/locale/fi_FI/LC_MESSAGES/django.po +0 -405
  266. game/locale/fi_FI/LC_MESSAGES/djangojs.mo +0 -0
  267. game/locale/fi_FI/LC_MESSAGES/djangojs.po +0 -739
  268. game/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
  269. game/locale/fr_FR/LC_MESSAGES/django.po +0 -405
  270. game/locale/fr_FR/LC_MESSAGES/djangojs.mo +0 -0
  271. game/locale/fr_FR/LC_MESSAGES/djangojs.po +0 -739
  272. game/locale/gu_IN/LC_MESSAGES/django.mo +0 -0
  273. game/locale/gu_IN/LC_MESSAGES/django.po +0 -405
  274. game/locale/gu_IN/LC_MESSAGES/djangojs.mo +0 -0
  275. game/locale/gu_IN/LC_MESSAGES/djangojs.po +0 -739
  276. game/locale/hi_IN/LC_MESSAGES/django.mo +0 -0
  277. game/locale/hi_IN/LC_MESSAGES/django.po +0 -405
  278. game/locale/hi_IN/LC_MESSAGES/djangojs.mo +0 -0
  279. game/locale/hi_IN/LC_MESSAGES/djangojs.po +0 -739
  280. game/locale/id_ID/LC_MESSAGES/django.mo +0 -0
  281. game/locale/id_ID/LC_MESSAGES/django.po +0 -405
  282. game/locale/id_ID/LC_MESSAGES/djangojs.mo +0 -0
  283. game/locale/id_ID/LC_MESSAGES/djangojs.po +0 -738
  284. game/locale/it_IT/LC_MESSAGES/django.mo +0 -0
  285. game/locale/it_IT/LC_MESSAGES/django.po +0 -405
  286. game/locale/it_IT/LC_MESSAGES/djangojs.mo +0 -0
  287. game/locale/it_IT/LC_MESSAGES/djangojs.po +0 -739
  288. game/locale/ja_JP/LC_MESSAGES/django.mo +0 -0
  289. game/locale/ja_JP/LC_MESSAGES/django.po +0 -405
  290. game/locale/ja_JP/LC_MESSAGES/djangojs.mo +0 -0
  291. game/locale/ja_JP/LC_MESSAGES/djangojs.po +0 -738
  292. game/locale/lol_US/LC_MESSAGES/django.mo +0 -0
  293. game/locale/lol_US/LC_MESSAGES/django.po +0 -405
  294. game/locale/lol_US/LC_MESSAGES/djangojs.mo +0 -0
  295. game/locale/lol_US/LC_MESSAGES/djangojs.po +0 -739
  296. game/locale/nb_NO/LC_MESSAGES/django.mo +0 -0
  297. game/locale/nb_NO/LC_MESSAGES/django.po +0 -405
  298. game/locale/nb_NO/LC_MESSAGES/djangojs.mo +0 -0
  299. game/locale/nb_NO/LC_MESSAGES/djangojs.po +0 -739
  300. game/locale/nl_NL/LC_MESSAGES/django.mo +0 -0
  301. game/locale/nl_NL/LC_MESSAGES/django.po +0 -405
  302. game/locale/nl_NL/LC_MESSAGES/djangojs.mo +0 -0
  303. game/locale/nl_NL/LC_MESSAGES/djangojs.po +0 -739
  304. game/locale/pl_PL/LC_MESSAGES/django.mo +0 -0
  305. game/locale/pl_PL/LC_MESSAGES/django.po +0 -405
  306. game/locale/pl_PL/LC_MESSAGES/djangojs.mo +0 -0
  307. game/locale/pl_PL/LC_MESSAGES/djangojs.po +0 -741
  308. game/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  309. game/locale/pt_BR/LC_MESSAGES/django.po +0 -405
  310. game/locale/pt_BR/LC_MESSAGES/djangojs.mo +0 -0
  311. game/locale/pt_BR/LC_MESSAGES/djangojs.po +0 -739
  312. game/locale/pt_PT/LC_MESSAGES/django.mo +0 -0
  313. game/locale/pt_PT/LC_MESSAGES/django.po +0 -405
  314. game/locale/pt_PT/LC_MESSAGES/djangojs.mo +0 -0
  315. game/locale/pt_PT/LC_MESSAGES/djangojs.po +0 -739
  316. game/locale/ro_RO/LC_MESSAGES/django.mo +0 -0
  317. game/locale/ro_RO/LC_MESSAGES/django.po +0 -405
  318. game/locale/ro_RO/LC_MESSAGES/djangojs.mo +0 -0
  319. game/locale/ro_RO/LC_MESSAGES/djangojs.po +0 -740
  320. game/locale/ru_RU/LC_MESSAGES/django.mo +0 -0
  321. game/locale/ru_RU/LC_MESSAGES/django.po +0 -405
  322. game/locale/ru_RU/LC_MESSAGES/djangojs.mo +0 -0
  323. game/locale/ru_RU/LC_MESSAGES/djangojs.po +0 -741
  324. game/locale/sv_SE/LC_MESSAGES/django.mo +0 -0
  325. game/locale/sv_SE/LC_MESSAGES/django.po +0 -405
  326. game/locale/sv_SE/LC_MESSAGES/djangojs.mo +0 -0
  327. game/locale/sv_SE/LC_MESSAGES/djangojs.po +0 -739
  328. game/locale/tl_PH/LC_MESSAGES/django.mo +0 -0
  329. game/locale/tl_PH/LC_MESSAGES/django.po +0 -405
  330. game/locale/tl_PH/LC_MESSAGES/djangojs.mo +0 -0
  331. game/locale/tl_PH/LC_MESSAGES/djangojs.po +0 -739
  332. game/locale/tlh_AA/LC_MESSAGES/django.mo +0 -0
  333. game/locale/tlh_AA/LC_MESSAGES/django.po +0 -405
  334. game/locale/tlh_AA/LC_MESSAGES/djangojs.mo +0 -0
  335. game/locale/tlh_AA/LC_MESSAGES/djangojs.po +0 -739
  336. game/locale/tr_TR/LC_MESSAGES/django.mo +0 -0
  337. game/locale/tr_TR/LC_MESSAGES/django.po +0 -405
  338. game/locale/tr_TR/LC_MESSAGES/djangojs.mo +0 -0
  339. game/locale/tr_TR/LC_MESSAGES/djangojs.po +0 -740
  340. game/locale/ur_IN/LC_MESSAGES/django.mo +0 -0
  341. game/locale/ur_IN/LC_MESSAGES/django.po +0 -405
  342. game/locale/ur_IN/LC_MESSAGES/djangojs.mo +0 -0
  343. game/locale/ur_IN/LC_MESSAGES/djangojs.po +0 -739
  344. game/locale/ur_PK/LC_MESSAGES/django.mo +0 -0
  345. game/locale/ur_PK/LC_MESSAGES/django.po +0 -405
  346. game/locale/ur_PK/LC_MESSAGES/djangojs.mo +0 -0
  347. game/locale/ur_PK/LC_MESSAGES/djangojs.po +0 -739
  348. game/static/game/image/actions/go.svg +0 -18
  349. game/static/game/image/icons/destination.svg +0 -9
  350. game/static/game/js/pqselect.min.js +0 -9
  351. game/static/game/js/widget-scroller.js +0 -906
  352. rapid_router-5.4.1.dist-info/LICENSE.md +0 -577
  353. rapid_router-5.4.1.dist-info/METADATA +0 -24
  354. {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/top_level.txt +0 -0
@@ -1,46 +1,52 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  var ocargo = ocargo || {};
4
4
 
5
- ocargo.BlocklyCompiler = function() {};
5
+ ocargo.BlocklyCompiler = function () {};
6
6
 
7
7
  ocargo.BlocklyCompiler.prototype.procedureBindings = null;
8
8
  ocargo.BlocklyCompiler.prototype.procedures = null;
9
9
  ocargo.BlocklyCompiler.prototype.events = null;
10
10
  ocargo.BlocklyCompiler.prototype.program = null;
11
11
 
12
- ocargo.BlocklyCompiler.prototype.compile = function() {
12
+ ocargo.BlocklyCompiler.prototype.compile = function () {
13
13
  this.compileProcedures();
14
14
  this.compileEvents();
15
15
  this.compileProgram();
16
16
  this.bindProcedureCalls();
17
17
 
18
- return this.program;
18
+ return this.program;
19
19
  };
20
20
 
21
- ocargo.BlocklyCompiler.prototype.compileProcedures = function() {
22
- this.procedures = {};
23
- this.procedureBindings = [];
21
+ ocargo.BlocklyCompiler.prototype.compileProcedures = function () {
22
+ this.procedures = {};
23
+ this.procedureBindings = [];
24
24
 
25
- var procBlocks = ocargo.blocklyControl.procedureBlocks();
26
- for (var i = 0; i < procBlocks.length; i++) {
27
- var block = procBlocks[i];
28
- var name = block.inputList[0].fieldRow[1].text_;
29
- if (name === "") {
30
- throw gettext_noop('Perhaps try looking at your \'define\' blocks?');
31
- }
25
+ var procBlocks = ocargo.blocklyControl.procedureBlocks();
26
+ for (var i = 0; i < procBlocks.length; i++) {
27
+ var block = procBlocks[i];
28
+ var name = block.inputList[0].fieldRow[1].text_;
29
+ if (name === "") {
30
+ throw gettext_noop("Perhaps try looking at your 'define' blocks?");
31
+ }
32
32
 
33
- var bodyBlock = block.inputList[1].connection.targetBlock();
34
- if (bodyBlock === null) {
35
- throw gettext_noop('Perhaps try looking at your \'define\' blocks?');
36
- }
33
+ var bodyBlock = block.inputList[1].connection.targetBlock();
34
+ if (bodyBlock === null) {
35
+ throw gettext_noop("Perhaps try looking at your 'define' blocks?");
36
+ }
37
37
 
38
- if (!(name in this.procedures)) {
39
- this.procedures[name] = new Procedure(name, this.createSequence(bodyBlock),block);
40
- } else {
41
- throw gettext_noop('Perhaps try checking the names of your \'define\' blocks?');
42
- }
38
+ if (!(name in this.procedures)) {
39
+ this.procedures[name] = new Procedure(
40
+ name,
41
+ this.createSequence(bodyBlock),
42
+ block
43
+ );
44
+ } else {
45
+ throw gettext_noop(
46
+ "Perhaps try checking the names of your 'define' blocks?"
47
+ );
43
48
  }
49
+ }
44
50
  };
45
51
 
46
52
  ocargo.BlocklyCompiler.prototype.compileEvents = function() {
@@ -73,456 +79,608 @@ ocargo.BlocklyCompiler.prototype.compileProgram = function() {
73
79
  this.program.thread = thread;
74
80
  };
75
81
 
76
- ocargo.BlocklyCompiler.prototype.bindProcedureCalls = function() {
77
- this.program.procedures = this.procedures;
78
- for (var i = 0; i < this.procedureBindings.length; i++) {
79
- var name = this.procedureBindings[i].name;
80
- var call = this.procedureBindings[i].call;
81
-
82
- if (name in this.procedures) {
83
- call.bind(this.procedures[name]);
84
- } else {
85
- throw gettext_noop('Perhaps try checking the names in your \'call\' blocks?');
86
- }
82
+ ocargo.BlocklyCompiler.prototype.bindProcedureCalls = function () {
83
+ this.program.procedures = this.procedures;
84
+ for (var i = 0; i < this.procedureBindings.length; i++) {
85
+ var name = this.procedureBindings[i].name;
86
+ var call = this.procedureBindings[i].call;
87
+
88
+ if (name in this.procedures) {
89
+ call.bind(this.procedures[name]);
90
+ } else {
91
+ throw gettext_noop(
92
+ "Perhaps try checking the names in your 'call' blocks?"
93
+ );
87
94
  }
95
+ }
88
96
  };
89
97
 
90
98
  /** Instructions **/
91
99
 
92
100
  // New completely custom repeat until and repeat while blocks
93
101
 
94
- ocargo.BlocklyCompiler.prototype.createRepeatUntil = function(block) {
95
- var conditionBlock = block.inputList[0].connection.targetBlock();
96
- if (conditionBlock === null) {
97
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
98
- }
99
- var condition = this.getCondition(conditionBlock);
100
- // negate condition for repeat until
101
- condition = this.negateCondition(condition);
102
+ ocargo.BlocklyCompiler.prototype.createRepeatUntil = function (block) {
103
+ var conditionBlock = block.inputList[0].connection.targetBlock();
104
+ if (conditionBlock === null) {
105
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
106
+ }
107
+ var condition = this.getCondition(conditionBlock);
108
+ // negate condition for repeat until
109
+ condition = this.negateCondition(condition);
110
+
111
+ var bodyBlock = block.inputList[1].connection.targetBlock();
112
+ if (bodyBlock === null) {
113
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
114
+ }
115
+ return new While(condition, this.createSequence(bodyBlock), block);
116
+ };
102
117
 
103
- var bodyBlock = block.inputList[1].connection.targetBlock();
104
- if (bodyBlock === null) {
105
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
106
- }
107
- return new While(condition, this.createSequence(bodyBlock), block);
118
+ ocargo.BlocklyCompiler.prototype.createRepeatWhile = function (block) {
119
+ var conditionBlock = block.inputList[0].connection.targetBlock();
120
+ if (conditionBlock === null) {
121
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
122
+ }
123
+ var condition = this.getCondition(conditionBlock);
124
+
125
+ var bodyBlock = block.inputList[1].connection.targetBlock();
126
+ if (bodyBlock === null) {
127
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
128
+ }
129
+ return new While(condition, this.createSequence(bodyBlock), block);
108
130
  };
109
131
 
110
- ocargo.BlocklyCompiler.prototype.createRepeatWhile = function(block) {
111
- var conditionBlock = block.inputList[0].connection.targetBlock();
112
- if (conditionBlock === null) {
113
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
114
- }
115
- var condition = this.getCondition(conditionBlock);
132
+ ocargo.BlocklyCompiler.prototype.createProcedureCall = function (block) {
133
+ var name = block.inputList[0].fieldRow[2].text_;
134
+ if (name === "") {
135
+ throw gettext_noop("Perhaps try checking the names in your 'call' blocks?");
136
+ }
116
137
 
117
- var bodyBlock = block.inputList[1].connection.targetBlock();
118
- if (bodyBlock === null) {
119
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
120
- }
121
- return new While(condition, this.createSequence(bodyBlock), block);
138
+ var procCall = new ProcedureCall(block);
139
+ this.procedureBindings.push({ call: procCall, name: name });
140
+ return procCall;
122
141
  };
123
142
 
124
- ocargo.BlocklyCompiler.prototype.createProcedureCall = function(block) {
125
- var name = block.inputList[0].fieldRow[2].text_;
126
- if (name === "") {
127
- throw gettext_noop('Perhaps try checking the names in your \'call\' blocks?');
128
- }
143
+ ocargo.BlocklyCompiler.prototype.createVariable = function (block) {
144
+ var variableName = block.inputList[0].fieldRow[1].text_;
145
+ if (variableName === "") {
146
+ throw gettext_noop(
147
+ "Perhaps try checking the names in your 'set variable' blocks?"
148
+ );
149
+ }
150
+
151
+ var self = this;
152
+ var variableValueFunction = function () {
153
+ return self.getValue(block.inputList[0].connection.targetBlock());
154
+ };
129
155
 
130
- var procCall = new ProcedureCall(block);
131
- this.procedureBindings.push({call:procCall,name:name});
132
- return procCall;
156
+ return new SetVariableCommand(block, variableName, variableValueFunction);
133
157
  };
134
158
 
135
- ocargo.BlocklyCompiler.prototype.createRepeat = function(block) {
136
- var bodyBlock = block.inputList[1].connection.targetBlock();
137
- if (bodyBlock === null) {
138
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
159
+ ocargo.BlocklyCompiler.prototype.createVariableNumeric = function (block) {
160
+ var variableName = block.inputList[0].fieldRow[1].text_;
161
+ if (variableName === "") {
162
+ throw gettext_noop(
163
+ "Perhaps try checking the names in your 'set variable' blocks?"
164
+ );
165
+ }
166
+
167
+ var variableValueFunction = function () {
168
+ var variableValue = parseInt(block.getFieldValue("VALUE"));
169
+ if (variableValue === "") {
170
+ throw gettext_noop(
171
+ "Perhaps try checking the values in your 'set variable' blocks?"
172
+ );
139
173
  }
140
- return new While(
141
- this.counterCondition(block, parseInt(block.inputList[0].fieldRow[1].text_)),
142
- this.createSequence(bodyBlock),
143
- block);
174
+ return variableValue;
175
+ };
176
+
177
+ return new SetVariableCommand(block, variableName, variableValueFunction);
178
+ };
179
+
180
+ ocargo.BlocklyCompiler.prototype.incrementVariable = function (block) {
181
+ var variableName = block.inputList[0].fieldRow[1].text_;
182
+ if (variableName === "") {
183
+ throw gettext_noop(
184
+ "Perhaps try checking the names in your 'increment variable' blocks?"
185
+ );
186
+ }
187
+
188
+ var variableIncrValue = parseInt(block.getFieldValue("VALUE"));
189
+ if (variableIncrValue === "") {
190
+ throw gettext_noop(
191
+ "Perhaps try checking the values in your 'increment variable' blocks?"
192
+ );
193
+ }
194
+
195
+ return new IncrementVariableCommand(block, variableName, variableIncrValue);
196
+ };
197
+
198
+ ocargo.BlocklyCompiler.prototype.createRepeat = function (block) {
199
+ var bodyBlock = block.inputList[1].connection.targetBlock();
200
+ if (bodyBlock === null) {
201
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
202
+ }
203
+ return new While(
204
+ this.counterCondition(
205
+ block,
206
+ parseInt(block.inputList[0].fieldRow[1].text_)
207
+ ),
208
+ this.createSequence(bodyBlock),
209
+ block
210
+ );
211
+ };
212
+
213
+ ocargo.BlocklyCompiler.prototype.createWhileUntil = function (block) {
214
+ var conditionBlock = block.inputList[0].connection.targetBlock();
215
+ if (conditionBlock === null) {
216
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
217
+ }
218
+ var condition = this.getCondition(conditionBlock);
219
+ if (block.inputList[0].fieldRow[1].value_ == "UNTIL") {
220
+ condition = this.negateCondition(condition);
221
+ }
222
+
223
+ var bodyBlock = block.inputList[1].connection.targetBlock();
224
+ if (bodyBlock === null) {
225
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
226
+ }
227
+ return new While(condition, this.createSequence(bodyBlock), block);
228
+ };
229
+
230
+ ocargo.BlocklyCompiler.prototype.getCondition = function (conditionBlock) {
231
+ if (conditionBlock.type === "road_exists") {
232
+ var selection = conditionBlock.inputList[0].fieldRow[1].value_;
233
+ return this.roadCondition(conditionBlock, selection);
234
+ } else if (conditionBlock.type === "dead_end") {
235
+ return this.deadEndCondition(conditionBlock);
236
+ } else if (conditionBlock.type === "at_destination") {
237
+ return this.atDestinationCondition(conditionBlock);
238
+ } else if (conditionBlock.type === "logic_negate") {
239
+ return this.negateCondition(
240
+ this.getCondition(conditionBlock.inputList[0].connection.targetBlock())
241
+ );
242
+ } else if (conditionBlock.type === "traffic_light") {
243
+ return this.trafficLightCondition(conditionBlock);
244
+ } else if (conditionBlock.type === "cow_crossing") {
245
+ return this.cowCrossingCondition(conditionBlock);
246
+ } else if (conditionBlock.type === "logic_compare") {
247
+ return this.logicCompareCondition(conditionBlock);
248
+ }
144
249
  };
145
250
 
146
- ocargo.BlocklyCompiler.prototype.createWhileUntil = function(block) {
147
- var conditionBlock = block.inputList[0].connection.targetBlock();
148
- if (conditionBlock === null) {
149
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
251
+ ocargo.BlocklyCompiler.prototype.getValue = function (block) {
252
+ if (block.type === "variables_get") {
253
+ var variableName = block.inputList[0].fieldRow[0].text_;
254
+ return parseInt(this.program.variables[variableName]);
255
+ } else if (block.type === "math_number") {
256
+ return parseInt(block.getFieldValue("NUM"));
257
+ } else if (block.type === "math_arithmetic") {
258
+ var leftBlock = block.inputList[0].connection.targetBlock();
259
+ var rightBlock = block.inputList[1].connection.targetBlock();
260
+ if (leftBlock === null || rightBlock === null) {
261
+ throw gettext_noop(
262
+ "Perhaps try looking at your 'math arithmetic' blocks?"
263
+ );
150
264
  }
151
- var condition = this.getCondition(conditionBlock);
152
- if (block.inputList[0].fieldRow[1].value_ == 'UNTIL') {
153
- condition = this.negateCondition(condition);
154
- }
155
265
 
156
- var bodyBlock = block.inputList[1].connection.targetBlock();
157
- if (bodyBlock === null) {
158
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
266
+ var operator = block.getFieldValue("OP");
267
+ var leftValue = this.getValue(leftBlock);
268
+ var rightValue = this.getValue(rightBlock);
269
+
270
+ if (operator == "ADD") {
271
+ return leftValue + rightValue;
272
+ } else if (operator == "MINUS") {
273
+ return leftValue - rightValue;
274
+ } else if (operator == "MULTIPLY") {
275
+ return leftValue * rightValue;
276
+ } else if (operator == "DIVIDE") {
277
+ return leftValue / rightValue;
278
+ } else if (operator == "POWER") {
279
+ return leftValue ** rightValue;
159
280
  }
160
- return new While(condition, this.createSequence(bodyBlock), block);
161
- };
162
-
163
- ocargo.BlocklyCompiler.prototype.getCondition = function(conditionBlock) {
164
- if (conditionBlock.type === 'road_exists') {
165
- var selection = conditionBlock.inputList[0].fieldRow[1].value_;
166
- return this.roadCondition(conditionBlock, selection);
167
- } else if (conditionBlock.type === 'dead_end') {
168
- return this.deadEndCondition(conditionBlock);
169
- } else if (conditionBlock.type === 'at_destination') {
170
- return this.atDestinationCondition(conditionBlock);
171
- } else if (conditionBlock.type === 'logic_negate') {
172
- return this.negateCondition(
173
- this.getCondition(conditionBlock.inputList[0].connection.targetBlock()));
174
- } else if (conditionBlock.type === 'traffic_light') {
175
- return this.trafficLightCondition(conditionBlock);
176
- } else if (conditionBlock.type === 'declare_event') {
177
- return this.cowCrossingCondition(conditionBlock);
281
+ }
282
+ };
283
+
284
+ ocargo.BlocklyCompiler.prototype.createIf = function (block) {
285
+ var conditionalCommandSets = [];
286
+
287
+ var elseCount = block.elseCount_ || 0;
288
+ var i = 0;
289
+ while (i < block.inputList.length - elseCount) {
290
+ var input = block.inputList[i];
291
+ var condition;
292
+
293
+ if (input.name.indexOf("IF") === 0) {
294
+ var conditionBlock = input.connection.targetBlock();
295
+ if (conditionBlock === null) {
296
+ throw gettext_noop("Perhaps try looking at your 'if' blocks?");
297
+ }
298
+ condition = this.getCondition(conditionBlock);
299
+ } else if (input.name.indexOf("DO") === 0) {
300
+ var conditionalCommandSet = {};
301
+ conditionalCommandSet.condition = condition;
302
+ conditionalCommandSet.commands = this.createSequence(
303
+ input.connection.targetBlock()
304
+ );
305
+ conditionalCommandSets.push(conditionalCommandSet);
178
306
  }
307
+
308
+ i++;
309
+ }
310
+
311
+ if (elseCount === 1) {
312
+ var elseBody = this.createSequence(
313
+ block.inputList[block.inputList.length - 1].connection.targetBlock()
314
+ );
315
+ }
316
+
317
+ return new If(conditionalCommandSets, elseBody, block);
179
318
  };
180
319
 
181
- ocargo.BlocklyCompiler.prototype.createIf = function(block) {
182
- var conditionalCommandSets = [];
183
-
184
- var elseCount = block.elseCount_ || 0;
185
- var i = 0;
186
- while (i < block.inputList.length - elseCount) {
187
- var input = block.inputList[i];
188
- var condition;
189
-
190
- if (input.name.indexOf('IF') === 0) {
191
- var conditionBlock = input.connection.targetBlock();
192
- if (conditionBlock === null) {
193
- throw gettext_noop('Perhaps try looking at your \'if\' blocks?');
194
- }
195
- condition = this.getCondition(conditionBlock);
196
- } else if (input.name.indexOf('DO') === 0) {
197
- var conditionalCommandSet = {};
198
- conditionalCommandSet.condition = condition;
199
- conditionalCommandSet.commands = this.createSequence(input.connection.targetBlock());
200
- conditionalCommandSets.push(conditionalCommandSet);
201
- }
202
-
203
- i++;
204
- }
205
-
206
- if (elseCount === 1) {
207
- var elseBody = this.createSequence(
208
- block.inputList[block.inputList.length - 1].connection.targetBlock());
209
- }
210
-
211
- return new If(conditionalCommandSets, elseBody, block);
212
- };
213
-
214
- ocargo.BlocklyCompiler.prototype.createSequence = function(block) {
215
- var commands = [];
216
-
217
- while (block) {
218
- if (block.type === 'move_forwards') {
219
- commands.push(new ForwardCommand(block));
220
- } else if (block.type === 'turn_left') {
221
- commands.push(new TurnLeftCommand(block));
222
- } else if (block.type === 'turn_right') {
223
- commands.push(new TurnRightCommand(block));
224
- } else if (block.type === 'turn_around') {
225
- commands.push(new TurnAroundCommand(block));
226
- } else if (block.type === 'wait') {
227
- commands.push(new WaitCommand(block));
228
- } else if (block.type === 'deliver') {
229
- commands.push(new DeliverCommand(block));
230
- } else if (block.type === 'sound_horn') {
231
- commands.push(new SoundHornCommand(block));
232
- } else if (block.type === 'puff_up') {
233
- commands.push(new PuffUpCommand(block));
234
- } else if (block.type === 'controls_repeat_until') {
235
- commands.push(this.createRepeatUntil(block));
236
- } else if (block.type === 'controls_repeat_while') {
237
- commands.push(this.createRepeatWhile(block));
238
- } else if (block.type === 'controls_repeat') {
239
- commands.push(this.createRepeat(block));
240
- } else if (block.type === 'controls_whileUntil') {
241
- commands.push(this.createWhileUntil(block));
242
- } else if (block.type === 'controls_if') {
243
- commands.push(this.createIf(block));
244
- } else if (block.type === 'call_proc') {
245
- commands.push(this.createProcedureCall(block));
246
- }
320
+ ocargo.BlocklyCompiler.prototype.createSequence = function (block) {
321
+ var commands = [];
322
+
323
+ while (block) {
324
+ if (block.type === "move_forwards") {
325
+ commands.push(new ForwardCommand(block));
326
+ } else if (block.type === "turn_left") {
327
+ commands.push(new TurnLeftCommand(block));
328
+ } else if (block.type === "turn_right") {
329
+ commands.push(new TurnRightCommand(block));
330
+ } else if (block.type === "turn_around") {
331
+ commands.push(new TurnAroundCommand(block));
332
+ } else if (block.type === "wait") {
333
+ commands.push(new WaitCommand(block));
334
+ } else if (block.type === "deliver") {
335
+ commands.push(new DeliverCommand(block));
336
+ } else if (block.type === "sound_horn") {
337
+ commands.push(new SoundHornCommand(block));
338
+ } else if (block.type === "controls_repeat_until") {
339
+ commands.push(this.createRepeatUntil(block));
340
+ } else if (block.type === "controls_repeat_while") {
341
+ commands.push(this.createRepeatWhile(block));
342
+ } else if (block.type === "controls_repeat") {
343
+ commands.push(this.createRepeat(block));
344
+ } else if (block.type === "controls_whileUntil") {
345
+ commands.push(this.createWhileUntil(block));
346
+ } else if (block.type === "controls_if") {
347
+ commands.push(this.createIf(block));
348
+ } else if (block.type === "call_proc") {
349
+ commands.push(this.createProcedureCall(block));
350
+ } else if (block.type === "variables_set") {
351
+ commands.push(this.createVariable(block));
352
+ } else if (block.type === "variables_numeric_set") {
353
+ commands.push(this.createVariableNumeric(block));
354
+ } else if (block.type === "variables_increment") {
355
+ commands.push(this.incrementVariable(block));
356
+ }
247
357
 
248
- block = block.nextConnection ? block.nextConnection.targetBlock() : null;
249
- }
358
+ block = block.nextConnection ? block.nextConnection.targetBlock() : null;
359
+ }
250
360
 
251
- return commands;
361
+ return commands;
252
362
  };
253
363
 
254
- ocargo.BlocklyCompiler.prototype.simplifyBlock = function(block){
255
- return new Block(block.id, block.type);
364
+ ocargo.BlocklyCompiler.prototype.simplifyBlock = function (block) {
365
+ return new Block(block.id, block.type);
256
366
  };
257
367
 
258
368
  /** Conditions **/
259
369
 
260
- ocargo.BlocklyCompiler.prototype.trafficLightCondition = function(block) {
261
- var lightColour = block.getFieldValue('CHOICE');
262
- return function(model) {
263
- queueHighlight(model, block);
264
- if (lightColour === ocargo.TrafficLight.RED) {
265
- return model.isTrafficLightRed();
266
- }
267
- else if (lightColour === ocargo.TrafficLight.GREEN) {
268
- return model.isTrafficLightGreen();
269
- }
270
- };
271
- };
272
-
273
- ocargo.BlocklyCompiler.prototype.roadCondition = function(block, selection) {
274
- return function(model) {
275
- queueHighlight(model, block);
276
- if (selection === 'FORWARD') {
277
- return model.isRoadForward();
278
- } else if (selection === 'LEFT') {
279
- return model.isRoadLeft();
280
- } else if (selection === 'RIGHT') {
281
- return model.isRoadRight();
282
- }
283
- };
370
+ ocargo.BlocklyCompiler.prototype.trafficLightCondition = function (block) {
371
+ var lightColour = block.getFieldValue("CHOICE");
372
+ return function (model) {
373
+ queueHighlight(model, block);
374
+ if (lightColour === ocargo.TrafficLight.RED) {
375
+ return model.isTrafficLightRed();
376
+ } else if (lightColour === ocargo.TrafficLight.GREEN) {
377
+ return model.isTrafficLightGreen();
378
+ }
379
+ };
284
380
  };
285
381
 
286
- ocargo.BlocklyCompiler.prototype.deadEndCondition = function(block) {
287
- return function(model) {
288
- queueHighlight(model, block);
289
- return model.isDeadEnd();
290
- };
382
+ ocargo.BlocklyCompiler.prototype.roadCondition = function (block, selection) {
383
+ return function (model) {
384
+ queueHighlight(model, block);
385
+ if (selection === "FORWARD") {
386
+ return model.isRoadForward();
387
+ } else if (selection === "LEFT") {
388
+ return model.isRoadLeft();
389
+ } else if (selection === "RIGHT") {
390
+ return model.isRoadRight();
391
+ }
392
+ };
291
393
  };
292
394
 
293
- ocargo.BlocklyCompiler.prototype.cowCrossingCondition = function(block) {
294
- return function(model) {
295
- queueHighlight(model, block);
296
- return model.isCowCrossing(block.getFieldValue('TYPE'));
297
- };
395
+ ocargo.BlocklyCompiler.prototype.deadEndCondition = function (block) {
396
+ return function (model) {
397
+ queueHighlight(model, block);
398
+ return model.isDeadEnd();
399
+ };
298
400
  };
299
401
 
402
+ ocargo.BlocklyCompiler.prototype.cowCrossingCondition = function (block) {
403
+ return function (model) {
404
+ queueHighlight(model, block);
405
+ return model.isCowCrossing(block.getFieldValue("TYPE"));
406
+ };
407
+ };
300
408
 
301
- ocargo.BlocklyCompiler.prototype.negateCondition = function(otherCondition) {
302
- return function(model) {
303
- return !otherCondition(model);
304
- };
409
+ ocargo.BlocklyCompiler.prototype.negateCondition = function (otherCondition) {
410
+ return function (model) {
411
+ return !otherCondition(model);
412
+ };
305
413
  };
306
414
 
307
- ocargo.BlocklyCompiler.prototype.atDestinationCondition = function(block) {
308
- return function(model) {
309
- queueHighlight(model, block);
310
- return model.isAtADestination();
311
- };
415
+ ocargo.BlocklyCompiler.prototype.atDestinationCondition = function (block) {
416
+ return function (model) {
417
+ queueHighlight(model, block);
418
+ return model.isAtADestination();
419
+ };
312
420
  };
313
421
 
314
- ocargo.BlocklyCompiler.prototype.counterCondition = function(block, count) {
315
- var startCount = count;
316
- return function(model) {
317
- queueHighlight(model, block);
318
- if (count > 0) {
319
- count--;
320
- return true;
321
- }
322
- // Resets the counter for nested loops
323
- count = startCount;
324
- return false;
325
- };
422
+ ocargo.BlocklyCompiler.prototype.counterCondition = function (block, count) {
423
+ var startCount = count;
424
+ return function (model) {
425
+ queueHighlight(model, block);
426
+ if (count > 0) {
427
+ count--;
428
+ return true;
429
+ }
430
+ // Resets the counter for nested loops
431
+ count = startCount;
432
+ return false;
433
+ };
434
+ };
435
+
436
+ ocargo.BlocklyCompiler.prototype.logicCompareCondition = function (block) {
437
+ // check left and right blocks
438
+ var leftBlock = block.inputList[0].connection.targetBlock();
439
+ var rightBlock = block.inputList[1].connection.targetBlock();
440
+ if (leftBlock === null || rightBlock === null) {
441
+ throw gettext_noop("Perhaps try looking at your 'compare' blocks?");
442
+ }
443
+
444
+ var operator = block.getFieldValue("OP");
445
+ var self = this;
446
+
447
+ return function (model) {
448
+ queueHighlight(model, block);
449
+
450
+ // get values of left and right blocks - must be evaluated on each step because of variables
451
+ var leftValue = self.getValue(leftBlock);
452
+ var rightValue = self.getValue(rightBlock);
453
+
454
+ if (operator == "EQ") {
455
+ return leftValue === rightValue;
456
+ } else if (operator == "NEQ") {
457
+ return leftValue !== rightValue;
458
+ } else if (operator == "LT") {
459
+ return leftValue < rightValue;
460
+ } else if (operator == "LTE") {
461
+ return leftValue <= rightValue;
462
+ } else if (operator == "GT") {
463
+ return leftValue > rightValue;
464
+ } else if (operator == "GTE") {
465
+ return leftValue >= rightValue;
466
+ }
467
+ };
326
468
  };
327
469
 
328
470
  /** Mobile Code **/
329
471
  /* Block types in the list passed in from mobile are converted to simplified Block objects
330
472
  id is assigned to each block in the order it appears in the array
331
473
  */
332
- ocargo.BlocklyCompiler.prototype.mobileCompile = function(types) {
333
- var blocks = [];
334
- for (var i = 0 ; i < types.length ; i++ ){
335
- blocks.push(new Block(i+1, types[i]));
336
- }
474
+ ocargo.BlocklyCompiler.prototype.mobileCompile = function (types) {
475
+ var blocks = [];
476
+ for (var i = 0; i < types.length; i++) {
477
+ blocks.push(new Block(i + 1, types[i]));
478
+ }
479
+
480
+ this.program = new ocargo.Program([]);
481
+ var thread = new ocargo.Thread(this.program);
482
+ thread.stack = this.mobileCreateSequence(blocks);
483
+ this.program.thread = thread;
484
+ return this.program;
485
+ };
337
486
 
338
- this.program = new ocargo.Program([]);
339
- var thread = new ocargo.Thread(this.program);
340
- thread.stack = this.mobileCreateSequence(blocks);
341
- this.program.thread = thread;
342
- return this.program;
343
- };
344
-
345
- ocargo.BlocklyCompiler.prototype.mobileCreateSequence = function(blocks) {
346
- var commands = [];
347
-
348
- var block = blocks.shift();
349
- while (block) {
350
- if (block.type === 'move_forwards') {
351
- commands.push(new ForwardCommand(block));
352
- } else if (block.type === 'turn_left') {
353
- commands.push(new TurnLeftCommand(block));
354
- } else if (block.type === 'turn_right') {
355
- commands.push(new TurnRightCommand(block));
356
- } else if (block.type === 'turn_around') {
357
- commands.push(new TurnAroundCommand(block));
358
- } else if (block.type === 'wait') {
359
- commands.push(new WaitCommand(block));
360
- } else if (block.type === 'deliver') {
361
- commands.push(new DeliverCommand(block));
362
- }
363
- //} else if (block.type === 'controls_repeat_until') {
364
- // commands.push(this.mobileCreateRepeatUntil(block));
365
- //} else if (block.type === 'controls_repeat_while') {
366
- // commands.push(this.mobileCreateRepeatWhile(block));
367
- //} else if (block.type === 'controls_repeat') {
368
- // commands.push(this.mobileCreateRepeat(block));
369
- //} else if (block.type === 'controls_whileUntil') {
370
- // commands.push(this.mobileCreateWhileUntil(block));
371
- //} else if (block.type === 'controls_if') {
372
- // commands.push(this.mobileCreateIf(block));
373
- //} else if (block.type === 'call_proc') {
374
- // commands.push(this.mobileCreateProcedureCall(block));
375
- //}
376
-
377
- block = blocks.shift();
487
+ ocargo.BlocklyCompiler.prototype.mobileCreateSequence = function (blocks) {
488
+ var commands = [];
489
+
490
+ var block = blocks.shift();
491
+ while (block) {
492
+ if (block.type === "move_forwards") {
493
+ commands.push(new ForwardCommand(block));
494
+ } else if (block.type === "turn_left") {
495
+ commands.push(new TurnLeftCommand(block));
496
+ } else if (block.type === "turn_right") {
497
+ commands.push(new TurnRightCommand(block));
498
+ } else if (block.type === "turn_around") {
499
+ commands.push(new TurnAroundCommand(block));
500
+ } else if (block.type === "wait") {
501
+ commands.push(new WaitCommand(block));
502
+ } else if (block.type === "deliver") {
503
+ commands.push(new DeliverCommand(block));
378
504
  }
505
+ //} else if (block.type === 'controls_repeat_until') {
506
+ // commands.push(this.mobileCreateRepeatUntil(block));
507
+ //} else if (block.type === 'controls_repeat_while') {
508
+ // commands.push(this.mobileCreateRepeatWhile(block));
509
+ //} else if (block.type === 'controls_repeat') {
510
+ // commands.push(this.mobileCreateRepeat(block));
511
+ //} else if (block.type === 'controls_whileUntil') {
512
+ // commands.push(this.mobileCreateWhileUntil(block));
513
+ //} else if (block.type === 'controls_if') {
514
+ // commands.push(this.mobileCreateIf(block));
515
+ //} else if (block.type === 'call_proc') {
516
+ // commands.push(this.mobileCreateProcedureCall(block));
517
+ //}
379
518
 
380
- return commands;
519
+ block = blocks.shift();
520
+ }
521
+
522
+ return commands;
381
523
  };
382
524
 
383
525
  /** Instructions **/
384
526
 
385
527
  // New completely custom repeat until and repeat while blocks
386
528
 
387
- ocargo.BlocklyCompiler.prototype.mobileCreateRepeatUntil = function(block, conditionBlock) {
388
- var condition;
389
- if (conditionBlock === null || (condition = this.mobileGetCondition(conditionBlock)) === null) {
390
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
391
- }
529
+ ocargo.BlocklyCompiler.prototype.mobileCreateRepeatUntil = function (
530
+ block,
531
+ conditionBlock
532
+ ) {
533
+ var condition;
534
+ if (
535
+ conditionBlock === null ||
536
+ (condition = this.mobileGetCondition(conditionBlock)) === null
537
+ ) {
538
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
539
+ }
540
+
541
+ // negate condition for repeat until
542
+ condition = this.negateCondition(condition);
543
+
544
+ var bodyBlock = block.inputList[1].connection.targetBlock();
545
+ if (bodyBlock === null) {
546
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
547
+ }
548
+ return new While(condition, this.createSequence(bodyBlock), block);
549
+ };
392
550
 
393
- // negate condition for repeat until
394
- condition = this.negateCondition(condition);
551
+ ocargo.BlocklyCompiler.prototype.mobileCreateRepeatWhile = function (block) {
552
+ var conditionBlock = block.inputList[0].connection.targetBlock();
553
+ if (conditionBlock === null) {
554
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
555
+ }
556
+ var condition = this.getCondition(conditionBlock);
557
+
558
+ var bodyBlock = block.inputList[1].connection.targetBlock();
559
+ if (bodyBlock === null) {
560
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
561
+ }
562
+ return new While(condition, this.createSequence(bodyBlock), block);
563
+ };
395
564
 
396
- var bodyBlock = block.inputList[1].connection.targetBlock();
397
- if (bodyBlock === null) {
398
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
399
- }
400
- return new While(condition, this.createSequence(bodyBlock), block);
565
+ ocargo.BlocklyCompiler.prototype.mobileCreateRepeat = function (block) {
566
+ var bodyBlock = block.inputList[1].connection.targetBlock();
567
+ if (bodyBlock === null) {
568
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
569
+ }
570
+ return new While(
571
+ this.counterCondition(
572
+ block,
573
+ parseInt(block.inputList[0].fieldRow[1].text_)
574
+ ),
575
+ this.createSequence(bodyBlock),
576
+ block
577
+ );
401
578
  };
402
579
 
403
- ocargo.BlocklyCompiler.prototype.mobileCreateRepeatWhile = function(block) {
404
- var conditionBlock = block.inputList[0].connection.targetBlock();
405
- if (conditionBlock === null) {
406
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
407
- }
408
- var condition = this.getCondition(conditionBlock);
580
+ ocargo.BlocklyCompiler.prototype.mobileCreateWhileUntil = function (block) {
581
+ var conditionBlock = block.inputList[0].connection.targetBlock();
582
+ if (conditionBlock === null) {
583
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
584
+ }
585
+ var condition = this.getCondition(conditionBlock);
586
+ if (block.inputList[0].fieldRow[1].value_ == "UNTIL") {
587
+ condition = this.negateCondition(condition);
588
+ }
409
589
 
410
- var bodyBlock = block.inputList[1].connection.targetBlock();
411
- if (bodyBlock === null) {
412
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
413
- }
414
- return new While(condition, this.createSequence(bodyBlock), block);
590
+ var bodyBlock = block.inputList[1].connection.targetBlock();
591
+ if (bodyBlock === null) {
592
+ throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
593
+ }
594
+ return new While(condition, this.createSequence(bodyBlock), block);
415
595
  };
416
596
 
417
- ocargo.BlocklyCompiler.prototype.mobileCreateRepeat = function(block) {
418
- var bodyBlock = block.inputList[1].connection.targetBlock();
419
- if (bodyBlock === null) {
420
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
421
- }
422
- return new While(
423
- this.counterCondition(block, parseInt(block.inputList[0].fieldRow[1].text_)),
424
- this.createSequence(bodyBlock),
425
- block);
426
- };
597
+ ocargo.BlocklyCompiler.prototype.mobileCreateIf = function (block) {
598
+ var conditionalCommandSets = [];
427
599
 
428
- ocargo.BlocklyCompiler.prototype.mobileCreateWhileUntil = function(block) {
429
- var conditionBlock = block.inputList[0].connection.targetBlock();
430
- if (conditionBlock === null) {
431
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
432
- }
433
- var condition = this.getCondition(conditionBlock);
434
- if (block.inputList[0].fieldRow[1].value_ == 'UNTIL') {
435
- condition = this.negateCondition(condition);
436
- }
600
+ var elseCount = block.elseCount_ || 0;
601
+ var i = 0;
602
+ while (i < block.inputList.length - elseCount) {
603
+ var input = block.inputList[i];
604
+ var condition;
437
605
 
438
- var bodyBlock = block.inputList[1].connection.targetBlock();
439
- if (bodyBlock === null) {
440
- throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
606
+ if (input.name.indexOf("IF") === 0) {
607
+ var conditionBlock = input.connection.targetBlock();
608
+ if (conditionBlock === null) {
609
+ throw gettext_noop("Perhaps try looking at your 'if' blocks?");
610
+ }
611
+ condition = this.getCondition(conditionBlock);
612
+ } else if (input.name.indexOf("DO") === 0) {
613
+ var conditionalCommandSet = {};
614
+ conditionalCommandSet.condition = condition;
615
+ conditionalCommandSet.commands = this.createSequence(
616
+ input.connection.targetBlock()
617
+ );
618
+ conditionalCommandSets.push(conditionalCommandSet);
441
619
  }
442
- return new While(condition, this.createSequence(bodyBlock), block);
443
- };
444
-
445
- ocargo.BlocklyCompiler.prototype.mobileCreateIf = function(block) {
446
- var conditionalCommandSets = [];
447
-
448
- var elseCount = block.elseCount_ || 0;
449
- var i = 0;
450
- while (i < block.inputList.length - elseCount) {
451
- var input = block.inputList[i];
452
- var condition;
453
-
454
- if (input.name.indexOf('IF') === 0) {
455
- var conditionBlock = input.connection.targetBlock();
456
- if (conditionBlock === null) {
457
- throw gettext_noop('Perhaps try looking at your \'if\' blocks?');
458
- }
459
- condition = this.getCondition(conditionBlock);
460
- } else if (input.name.indexOf('DO') === 0) {
461
- var conditionalCommandSet = {};
462
- conditionalCommandSet.condition = condition;
463
- conditionalCommandSet.commands = this.createSequence(input.connection.targetBlock());
464
- conditionalCommandSets.push(conditionalCommandSet);
465
- }
466
620
 
467
- i++;
468
- }
621
+ i++;
622
+ }
469
623
 
470
- if (elseCount === 1) {
471
- var elseBody = this.createSequence(
472
- block.inputList[block.inputList.length - 1].connection.targetBlock());
473
- }
624
+ if (elseCount === 1) {
625
+ var elseBody = this.createSequence(
626
+ block.inputList[block.inputList.length - 1].connection.targetBlock()
627
+ );
628
+ }
474
629
 
475
- return new If(conditionalCommandSets, elseBody, block);
630
+ return new If(conditionalCommandSets, elseBody, block);
476
631
  };
477
632
 
478
- ocargo.BlocklyCompiler.prototype.mobileCreateProcedureCall = function(block) {
479
- var name = block.inputList[0].fieldRow[2].text_;
480
- if (name === "") {
481
- throw gettext_noop('Perhaps try checking the names in your \'call\' blocks?');
482
- }
633
+ ocargo.BlocklyCompiler.prototype.mobileCreateProcedureCall = function (block) {
634
+ var name = block.inputList[0].fieldRow[2].text_;
635
+ if (name === "") {
636
+ throw gettext_noop("Perhaps try checking the names in your 'call' blocks?");
637
+ }
483
638
 
484
- var procCall = new ProcedureCall(block);
485
- this.procedureBindings.push({call:procCall,name:name});
486
- return procCall;
487
- };
488
-
489
- ocargo.BlocklyCompiler.prototype.mobileGetCondition = function(conditionBlock) {
490
- if (conditionBlock.type === 'road_exists') {
491
- var selection = conditionBlock.inputList[0].fieldRow[1].value_;
492
- return this.roadCondition(conditionBlock, selection);
493
- } else if (conditionBlock.type === 'dead_end') {
494
- return this.deadEndCondition(conditionBlock);
495
- } else if (conditionBlock.type === 'at_destination') {
496
- return this.atDestinationCondition(conditionBlock);
497
- } else if (conditionBlock.type === 'logic_negate') {
498
- return this.negateCondition(
499
- this.getCondition(conditionBlock.inputList[0].connection.targetBlock()));
500
- } else if (conditionBlock.type === 'traffic_light') {
501
- return this.trafficLightCondition(conditionBlock);
502
- } else{
503
- return null;
504
- }
639
+ var procCall = new ProcedureCall(block);
640
+ this.procedureBindings.push({ call: procCall, name: name });
641
+ return procCall;
642
+ };
643
+
644
+ ocargo.BlocklyCompiler.prototype.mobileGetCondition = function (
645
+ conditionBlock
646
+ ) {
647
+ if (conditionBlock.type === "road_exists") {
648
+ var selection = conditionBlock.inputList[0].fieldRow[1].value_;
649
+ return this.roadCondition(conditionBlock, selection);
650
+ } else if (conditionBlock.type === "dead_end") {
651
+ return this.deadEndCondition(conditionBlock);
652
+ } else if (conditionBlock.type === "at_destination") {
653
+ return this.atDestinationCondition(conditionBlock);
654
+ } else if (conditionBlock.type === "logic_negate") {
655
+ return this.negateCondition(
656
+ this.getCondition(conditionBlock.inputList[0].connection.targetBlock())
657
+ );
658
+ } else if (conditionBlock.type === "traffic_light") {
659
+ return this.trafficLightCondition(conditionBlock);
660
+ } else {
661
+ return null;
662
+ }
505
663
  };
506
664
 
507
- ocargo.BlocklyCompiler.prototype.workspaceToPython = function() {
508
- Blockly.Python.variableDB_.reset();
665
+ ocargo.BlocklyCompiler.prototype.workspaceToPython = function () {
666
+ Blockly.Python.variableDB_.reset();
509
667
 
510
- var procBlocks = ocargo.blocklyControl.procedureBlocks();
668
+ var procBlocks = ocargo.blocklyControl.procedureBlocks();
511
669
 
512
- var code = "";
670
+ var code = "";
513
671
 
514
- for (var i = 0; i < procBlocks.length; i++) {
515
- code += '\n' + Blockly.Python.blockToCode(procBlocks[i]);
516
- }
672
+ for (var i = 0; i < procBlocks.length; i++) {
673
+ code += "\n" + Blockly.Python.blockToCode(procBlocks[i]);
674
+ }
517
675
 
518
- // TODO support events in python
519
- //var eventBlocks = ocargo.blocklyControl.onEventDoBlocks();
520
- //for (var i = 0; i < eventBlocks.length; i++) {
521
- // code += '\n' + Blockly.Python.blockToCode(eventBlocks[i]);
522
- //}
676
+ // TODO support events in python
677
+ //var eventBlocks = ocargo.blocklyControl.onEventDoBlocks();
678
+ //for (var i = 0; i < eventBlocks.length; i++) {
679
+ // code += '\n' + Blockly.Python.blockToCode(eventBlocks[i]);
680
+ //}
523
681
 
524
- var startBlock = ocargo.blocklyControl.startBlock();
525
- code += '\n' + Blockly.Python.blockToCode(startBlock);
682
+ var startBlock = ocargo.blocklyControl.startBlock();
683
+ code += "\n" + Blockly.Python.blockToCode(startBlock);
526
684
 
527
- return code;
685
+ return code;
528
686
  };