From 604dbdb3344f5cf905a37cb527325c00a5799ee3 Mon Sep 17 00:00:00 2001 From: Florian Aucomte <33633200+faucomte97@users.noreply.github.com> Date: Wed, 13 Jul 2022 17:55:10 +0100 Subject: [PATCH] feat: Update styles of the game pt. 1 (#1356) * feat: Update colours and images in Rapid Router * Revert CSP * Remove unused class * Improve base indentation * Added difficulty property * Added difficulty to levels too --- .github/workflows/publish-python-package.yml | 2 +- Pipfile.lock | 172 +++++++++++-------- game/admin.py | 2 + game/csp_config.py | 14 +- game/models.py | 26 +++ game/static/game/css/backgrounds.css | 29 ++++ game/static/game/css/game.css | 19 +- game/static/game/css/game_screen.css | 15 +- game/static/game/css/level_editor.css | 8 + game/static/game/css/level_selection.css | 16 +- game/static/game/image/icons/clear.svg | 2 +- game/static/game/image/icons/quit.svg | 2 +- game/static/game/image/icons/random.svg | 2 +- game/static/game/js/drawing.js | 12 +- game/static/game/js/game.js | 4 +- game/templates/game/base.html | 65 ++++--- game/templates/game/basenonav.html | 38 ++-- game/templates/game/game.html | 2 +- game/templates/game/level_selection.html | 15 +- game/views/level_selection.py | 4 +- 20 files changed, 276 insertions(+), 173 deletions(-) create mode 100644 game/static/game/css/backgrounds.css diff --git a/.github/workflows/publish-python-package.yml b/.github/workflows/publish-python-package.yml index 9886244e9..01e3df23d 100644 --- a/.github/workflows/publish-python-package.yml +++ b/.github/workflows/publish-python-package.yml @@ -48,7 +48,7 @@ jobs: django-admin compilemessages popd - name: Release rapid-router - uses: relekang/python-semantic-release@v7.25.2 # Fix version to avoid this bug https://github.com/relekang/python-semantic-release/issues/442 + uses: ocadotechnology/python-semantic-release@patch-packaging-error with: github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} pypi_token: ${{ secrets.PYPI_TOKEN }} diff --git a/Pipfile.lock b/Pipfile.lock index 4d453db6a..3f0065e78 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -26,18 +26,18 @@ }, "cfl-common": { "hashes": [ - "sha256:c48798fb8cbae174265d07710a53fbb98c4765b689fd0421bdb7e2fc78d3364d", - "sha256:de71bd224d1d476eab75f59f28fc03604fd2bde00de40fe7f0543dccd64733ad" + "sha256:1236fe4c59aad4f57402be774107434505ad1c17530e3bf3a7e5107f6ce5174f", + "sha256:d5887410330db575dd949f4cc5c09b0da7df45ec8912b6a810cd1c4b86f3c06f" ], - "version": "==6.8.9" + "version": "==6.13.3" }, "django": { "hashes": [ - "sha256:6d93497a0a9bf6ba0e0b1a29cccdc40efbfc76297255b1309b3a884a688ec4b6", - "sha256:b896ca61edc079eb6bbaa15cf6071eb69d6aac08cce5211583cfb41515644fdf" + "sha256:677182ba8b5b285a4e072f3ac17ceee6aff1b5ce77fd173cc5b6a2d3dc022fcf", + "sha256:a8681e098fa60f7c33a4b628d6fcd3fe983a0939ff1301ecacac21d0b38bad56" ], "markers": "python_version >= '3.6'", - "version": "==3.2.13" + "version": "==3.2.14" }, "django-autoconfig": { "git": "https://github.com/ocadotechnology/django-autoconfig.git", @@ -183,20 +183,20 @@ }, "typing-extensions": { "hashes": [ - "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708", - "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376" + "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02", + "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6" ], "markers": "python_version >= '3.7'", - "version": "==4.2.0" + "version": "==4.3.0" } }, "develop": { "aimmo": { "hashes": [ - "sha256:0c901683e4558e37925429dd2eca2d2c8f77426c809fa01613279b022b1ebde8", - "sha256:8c5dbdcd224940298db512db884f24a23e5a769f97d0a327dedf9e24cf345c05" + "sha256:52a6947d184c5284a26b1fc1ec91ef65f90a1fa5f74dec1c7bc535aca716b258", + "sha256:c912f0543368a368d163a58b4073fd35a306891a5d5756a610f008335e9d5cfb" ], - "version": "==2.3.5" + "version": "==2.4.1" }, "asgiref": { "hashes": [ @@ -232,10 +232,10 @@ }, "cfl-common": { "hashes": [ - "sha256:c48798fb8cbae174265d07710a53fbb98c4765b689fd0421bdb7e2fc78d3364d", - "sha256:de71bd224d1d476eab75f59f28fc03604fd2bde00de40fe7f0543dccd64733ad" + "sha256:1236fe4c59aad4f57402be774107434505ad1c17530e3bf3a7e5107f6ce5174f", + "sha256:d5887410330db575dd949f4cc5c09b0da7df45ec8912b6a810cd1c4b86f3c06f" ], - "version": "==6.8.9" + "version": "==6.13.3" }, "chardet": { "hashes": [ @@ -246,19 +246,19 @@ }, "codeforlife-portal": { "hashes": [ - "sha256:0eef2178e70e0035139f8a1591ca4941862120bc760efa7676208e3c5a179c22", - "sha256:ab14c64f773570a194c0b431a03ec533e4b3615d45e82272b6ca54a4d04e4761" + "sha256:2e54de28416825df0678d2905483d882ed02e5ae5ef6892b4d814b989e19af3f", + "sha256:96875a8401765d15405c0e11825e41527bc4dc2d700bf3b696e8f18cd5dadea1" ], "index": "pypi", - "version": "==6.8.9" + "version": "==6.13.3" }, "django": { "hashes": [ - "sha256:6d93497a0a9bf6ba0e0b1a29cccdc40efbfc76297255b1309b3a884a688ec4b6", - "sha256:b896ca61edc079eb6bbaa15cf6071eb69d6aac08cce5211583cfb41515644fdf" + "sha256:677182ba8b5b285a4e072f3ac17ceee6aff1b5ce77fd173cc5b6a2d3dc022fcf", + "sha256:a8681e098fa60f7c33a4b628d6fcd3fe983a0939ff1301ecacac21d0b38bad56" ], "markers": "python_version >= '3.6'", - "version": "==3.2.13" + "version": "==3.2.14" }, "django-classy-tags": { "hashes": [ @@ -406,11 +406,11 @@ }, "google-auth": { "hashes": [ - "sha256:819b70140d05501739e1387291d39f0de3b4dff3b00ae4aff8e7a05369957f89", - "sha256:9b1da39ab8731c3061f36fefde9f8bb902dbee9eb28e3a67e8cfa7dc1be76227" + "sha256:3b2f9d2f436cc7c3b363d0ac66470f42fede249c3bafcc504e9f0bcbe983cff0", + "sha256:75b3977e7e22784607e074800048f44d6a56df589fb2abe58a11d4d20c97c314" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==2.8.0" + "version": "==2.9.0" }, "greenlet": { "hashes": [ @@ -491,11 +491,11 @@ }, "importlib-metadata": { "hashes": [ - "sha256:5d26852efe48c0a32b0509ffbc583fda1a2266545a78d104a6f4aff3db17d700", - "sha256:c58c8eb8a762858f49e18436ff552e83914778e50e9d2f1660535ffb364552ec" + "sha256:637245b8bab2b6502fcbc752cc4b7a6f6243bb02b31c5c26156ad103d3d45670", + "sha256:7401a975809ea1fdc658c3aa4f78cc2195a0e019c5cbc4c06122884e9ae80c23" ], "markers": "python_version < '3.8'", - "version": "==4.11.4" + "version": "==4.12.0" }, "iniconfig": { "hashes": [ @@ -560,47 +560,67 @@ }, "pillow": { "hashes": [ - "sha256:088df396b047477dd1bbc7de6e22f58400dae2f21310d9e2ec2933b2ef7dfa4f", - "sha256:09e67ef6e430f90caa093528bd758b0616f8165e57ed8d8ce014ae32df6a831d", - "sha256:0b4d5ad2cd3a1f0d1df882d926b37dbb2ab6c823ae21d041b46910c8f8cd844b", - "sha256:0b525a356680022b0af53385944026d3486fc8c013638cf9900eb87c866afb4c", - "sha256:1d4331aeb12f6b3791911a6da82de72257a99ad99726ed6b63f481c0184b6fb9", - "sha256:20d514c989fa28e73a5adbddd7a171afa5824710d0ab06d4e1234195d2a2e546", - "sha256:2b291cab8a888658d72b575a03e340509b6b050b62db1f5539dd5cd18fd50578", - "sha256:3f6c1716c473ebd1649663bf3b42702d0d53e27af8b64642be0dd3598c761fb1", - "sha256:42dfefbef90eb67c10c45a73a9bc1599d4dac920f7dfcbf4ec6b80cb620757fe", - "sha256:488f3383cf5159907d48d32957ac6f9ea85ccdcc296c14eca1a4e396ecc32098", - "sha256:4d45dbe4b21a9679c3e8b3f7f4f42a45a7d3ddff8a4a16109dff0e1da30a35b2", - "sha256:53c27bd452e0f1bc4bfed07ceb235663a1df7c74df08e37fd6b03eb89454946a", - "sha256:55e74faf8359ddda43fee01bffbc5bd99d96ea508d8a08c527099e84eb708f45", - "sha256:59789a7d06c742e9d13b883d5e3569188c16acb02eeed2510fd3bfdbc1bd1530", - "sha256:5b650dbbc0969a4e226d98a0b440c2f07a850896aed9266b6fedc0f7e7834108", - "sha256:66daa16952d5bf0c9d5389c5e9df562922a59bd16d77e2a276e575d32e38afd1", - "sha256:6e760cf01259a1c0a50f3c845f9cad1af30577fd8b670339b1659c6d0e7a41dd", - "sha256:7502539939b53d7565f3d11d87c78e7ec900d3c72945d4ee0e2f250d598309a0", - "sha256:769a7f131a2f43752455cc72f9f7a093c3ff3856bf976c5fb53a59d0ccc704f6", - "sha256:7c150dbbb4a94ea4825d1e5f2c5501af7141ea95825fadd7829f9b11c97aaf6c", - "sha256:8844217cdf66eabe39567118f229e275f0727e9195635a15e0e4b9227458daaf", - "sha256:8a66fe50386162df2da701b3722781cbe90ce043e7d53c1fd6bd801bca6b48d4", - "sha256:9370d6744d379f2de5d7fa95cdbd3a4d92f0b0ef29609b4b1687f16bc197063d", - "sha256:937a54e5694684f74dcbf6e24cc453bfc5b33940216ddd8f4cd8f0f79167f765", - "sha256:9c857532c719fb30fafabd2371ce9b7031812ff3889d75273827633bca0c4602", - "sha256:a4165205a13b16a29e1ac57efeee6be2dfd5b5408122d59ef2145bc3239fa340", - "sha256:b3fe2ff1e1715d4475d7e2c3e8dabd7c025f4410f79513b4ff2de3d51ce0fa9c", - "sha256:b6617221ff08fbd3b7a811950b5c3f9367f6e941b86259843eab77c8e3d2b56b", - "sha256:b761727ed7d593e49671d1827044b942dd2f4caae6e51bab144d4accf8244a84", - "sha256:baf3be0b9446a4083cc0c5bb9f9c964034be5374b5bc09757be89f5d2fa247b8", - "sha256:c17770a62a71718a74b7548098a74cd6880be16bcfff5f937f900ead90ca8e92", - "sha256:c67db410508b9de9c4694c57ed754b65a460e4812126e87f5052ecf23a011a54", - "sha256:d78ca526a559fb84faaaf84da2dd4addef5edb109db8b81677c0bb1aad342601", - "sha256:e9ed59d1b6ee837f4515b9584f3d26cf0388b742a11ecdae0d9237a94505d03a", - "sha256:f054b020c4d7e9786ae0404278ea318768eb123403b18453e28e47cdb7a0a4bf", - "sha256:f372d0f08eff1475ef426344efe42493f71f377ec52237bf153c5713de987251", - "sha256:f3f6a6034140e9e17e9abc175fc7a266a6e63652028e157750bd98e804a8ed9a", - "sha256:ffde4c6fabb52891d81606411cbfaf77756e3b561b566efd270b3ed3791fde4e" + "sha256:0030fdbd926fb85844b8b92e2f9449ba89607231d3dd597a21ae72dc7fe26927", + "sha256:030e3460861488e249731c3e7ab59b07c7853838ff3b8e16aac9561bb345da14", + "sha256:0ed2c4ef2451de908c90436d6e8092e13a43992f1860275b4d8082667fbb2ffc", + "sha256:136659638f61a251e8ed3b331fc6ccd124590eeff539de57c5f80ef3a9594e58", + "sha256:13b725463f32df1bfeacbf3dd197fb358ae8ebcd8c5548faa75126ea425ccb60", + "sha256:1536ad017a9f789430fb6b8be8bf99d2f214c76502becc196c6f2d9a75b01b76", + "sha256:15928f824870535c85dbf949c09d6ae7d3d6ac2d6efec80f3227f73eefba741c", + "sha256:17d4cafe22f050b46d983b71c707162d63d796a1235cdf8b9d7a112e97b15bac", + "sha256:1802f34298f5ba11d55e5bb09c31997dc0c6aed919658dfdf0198a2fe75d5490", + "sha256:1cc1d2451e8a3b4bfdb9caf745b58e6c7a77d2e469159b0d527a4554d73694d1", + "sha256:1fd6f5e3c0e4697fa7eb45b6e93996299f3feee73a3175fa451f49a74d092b9f", + "sha256:254164c57bab4b459f14c64e93df11eff5ded575192c294a0c49270f22c5d93d", + "sha256:2ad0d4df0f5ef2247e27fc790d5c9b5a0af8ade9ba340db4a73bb1a4a3e5fb4f", + "sha256:2c58b24e3a63efd22554c676d81b0e57f80e0a7d3a5874a7e14ce90ec40d3069", + "sha256:2d33a11f601213dcd5718109c09a52c2a1c893e7461f0be2d6febc2879ec2402", + "sha256:337a74fd2f291c607d220c793a8135273c4c2ab001b03e601c36766005f36885", + "sha256:37ff6b522a26d0538b753f0b4e8e164fdada12db6c6f00f62145d732d8a3152e", + "sha256:3d1f14f5f691f55e1b47f824ca4fdcb4b19b4323fe43cc7bb105988cad7496be", + "sha256:408673ed75594933714482501fe97e055a42996087eeca7e5d06e33218d05aa8", + "sha256:4134d3f1ba5f15027ff5c04296f13328fecd46921424084516bdb1b2548e66ff", + "sha256:4ad2f835e0ad81d1689f1b7e3fbac7b01bb8777d5a985c8962bedee0cc6d43da", + "sha256:50dff9cc21826d2977ef2d2a205504034e3a4563ca6f5db739b0d1026658e004", + "sha256:510cef4a3f401c246cfd8227b300828715dd055463cdca6176c2e4036df8bd4f", + "sha256:5aed7dde98403cd91d86a1115c78d8145c83078e864c1de1064f52e6feb61b20", + "sha256:69bd1a15d7ba3694631e00df8de65a8cb031911ca11f44929c97fe05eb9b6c1d", + "sha256:6bf088c1ce160f50ea40764f825ec9b72ed9da25346216b91361eef8ad1b8f8c", + "sha256:6e8c66f70fb539301e064f6478d7453e820d8a2c631da948a23384865cd95544", + "sha256:727dd1389bc5cb9827cbd1f9d40d2c2a1a0c9b32dd2261db522d22a604a6eec9", + "sha256:74a04183e6e64930b667d321524e3c5361094bb4af9083db5c301db64cd341f3", + "sha256:75e636fd3e0fb872693f23ccb8a5ff2cd578801251f3a4f6854c6a5d437d3c04", + "sha256:7761afe0126d046974a01e030ae7529ed0ca6a196de3ec6937c11df0df1bc91c", + "sha256:7888310f6214f19ab2b6df90f3f06afa3df7ef7355fc025e78a3044737fab1f5", + "sha256:7b0554af24df2bf96618dac71ddada02420f946be943b181108cac55a7a2dcd4", + "sha256:7c7b502bc34f6e32ba022b4a209638f9e097d7a9098104ae420eb8186217ebbb", + "sha256:808add66ea764ed97d44dda1ac4f2cfec4c1867d9efb16a33d158be79f32b8a4", + "sha256:831e648102c82f152e14c1a0938689dbb22480c548c8d4b8b248b3e50967b88c", + "sha256:93689632949aff41199090eff5474f3990b6823404e45d66a5d44304e9cdc467", + "sha256:96b5e6874431df16aee0c1ba237574cb6dff1dcb173798faa6a9d8b399a05d0e", + "sha256:9a54614049a18a2d6fe156e68e188da02a046a4a93cf24f373bffd977e943421", + "sha256:a138441e95562b3c078746a22f8fca8ff1c22c014f856278bdbdd89ca36cff1b", + "sha256:a647c0d4478b995c5e54615a2e5360ccedd2f85e70ab57fbe817ca613d5e63b8", + "sha256:a9c9bc489f8ab30906d7a85afac4b4944a572a7432e00698a7239f44a44e6efb", + "sha256:ad2277b185ebce47a63f4dc6302e30f05762b688f8dc3de55dbae4651872cdf3", + "sha256:b6d5e92df2b77665e07ddb2e4dbd6d644b78e4c0d2e9272a852627cdba0d75cf", + "sha256:bc431b065722a5ad1dfb4df354fb9333b7a582a5ee39a90e6ffff688d72f27a1", + "sha256:bdd0de2d64688ecae88dd8935012c4a72681e5df632af903a1dca8c5e7aa871a", + "sha256:c79698d4cd9318d9481d89a77e2d3fcaeff5486be641e60a4b49f3d2ecca4e28", + "sha256:cb6259196a589123d755380b65127ddc60f4c64b21fc3bb46ce3a6ea663659b0", + "sha256:d5b87da55a08acb586bad5c3aa3b86505f559b84f39035b233d5bf844b0834b1", + "sha256:dcd7b9c7139dc8258d164b55696ecd16c04607f1cc33ba7af86613881ffe4ac8", + "sha256:dfe4c1fedfde4e2fbc009d5ad420647f7730d719786388b7de0999bf32c0d9fd", + "sha256:ea98f633d45f7e815db648fd7ff0f19e328302ac36427343e4432c84432e7ff4", + "sha256:ec52c351b35ca269cb1f8069d610fc45c5bd38c3e91f9ab4cbbf0aebc136d9c8", + "sha256:eef7592281f7c174d3d6cbfbb7ee5984a671fcd77e3fc78e973d492e9bf0eb3f", + "sha256:f07f1f00e22b231dd3d9b9208692042e29792d6bd4f6639415d2f23158a80013", + "sha256:f3fac744f9b540148fa7715a435d2283b71f68bfb6d4aae24482a890aed18b59", + "sha256:fa768eff5f9f958270b081bb33581b4b569faabf8774726b283edb06617101dc", + "sha256:fac2d65901fb0fdf20363fbd345c01958a742f2dc62a8dd4495af66e3ff502a4" ], "markers": "python_version >= '3.7'", - "version": "==9.1.1" + "version": "==9.2.0" }, "pluggy": { "hashes": [ @@ -849,19 +869,19 @@ }, "typing-extensions": { "hashes": [ - "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708", - "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376" + "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02", + "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6" ], "markers": "python_version >= '3.7'", - "version": "==4.2.0" + "version": "==4.3.0" }, "urllib3": { "hashes": [ - "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14", - "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e" + "sha256:8298d6d56d39be0e3bc13c1c97d133f9b45d797169a0e11cdd0e0489d786f7ec", + "sha256:879ba4d1e89654d9769ce13121e0f94310ea32e8d2f8cf587b77c08bbcdb30d6" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0'", - "version": "==1.26.9" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4.0'", + "version": "==1.26.10" }, "websocket-client": { "hashes": [ @@ -873,11 +893,11 @@ }, "zipp": { "hashes": [ - "sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad", - "sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099" + "sha256:05b45f1ee8f807d0cc928485ca40a07cb491cf092ff587c0df9cb1fd154848d2", + "sha256:47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009" ], "markers": "python_version >= '3.7'", - "version": "==3.8.0" + "version": "==3.8.1" } } } diff --git a/game/admin.py b/game/admin.py index f78b40230..9c1585706 100644 --- a/game/admin.py +++ b/game/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from game.models import Level, Block, Episode, Workspace @@ -6,6 +7,7 @@ class LevelAdmin(admin.ModelAdmin): search_fields = ["name"] raw_id_fields = ["next_level"] readonly_fields = ["owner"] + list_display = ["name", "id", "episode", "owner"] class WorkspaceAdmin(admin.ModelAdmin): diff --git a/game/csp_config.py b/game/csp_config.py index a6b1d443d..67102c265 100644 --- a/game/csp_config.py +++ b/game/csp_config.py @@ -10,14 +10,14 @@ f"{domain()}/static/game/js/blockly/media/", f"{domain()}/static/icons/", "https://cdn.crowdin.com/", - "https://crowdin-static.downloads.crowdin.com/" + "https://crowdin-static.downloads.crowdin.com/", ), - "CSP_STYLE_SRC": ("https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css", "https://cdn.crowdin.com/"), - "CSP_SCRIPT_SRC": ("'unsafe-eval'", "https://cdn.crowdin.com/"), - "CSP_FRAME_SRC": ( - f"{domain()}/static/game/image/", - "https://crowdin.com/" + "CSP_STYLE_SRC": ( + "https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css", + "https://cdn.crowdin.com/", ), + "CSP_SCRIPT_SRC": ("'unsafe-eval'", "https://cdn.crowdin.com/"), + "CSP_FRAME_SRC": (f"{domain()}/static/game/image/", "https://crowdin.com/"), "CSP_OBJECT_SRC": (f"{domain()}/static/game/image/",), - "CSP_CONNECT_SRC": ("https://crowdin.com/",) + "CSP_CONNECT_SRC": ("https://crowdin.com/",), } diff --git a/game/models.py b/game/models.py index 8ddb450df..63efc9007 100644 --- a/game/models.py +++ b/game/models.py @@ -54,6 +54,28 @@ def levels(self): return sorted(self.level_set.all(), key=lambda level: int(level.name)) + @property + def difficulty(self): + """ + Maps the Episode's id to a difficulty level, used later on to map to CSS classes and different background + colours + """ + difficulty_map = { + 1: "easy", + 2: "easy", + 3: "easy", + 4: "easy", + 5: "medium", + 6: "medium", + 7: "medium-hard", + 8: "medium-hard", + 9: "brainteasers", + 10: "hard", + 11: "advanced", + } + + return difficulty_map.get(self.id, "easy") + def __str__(self): return f"Episode: {self.name}" @@ -143,6 +165,10 @@ def character(self, val): self.character_name = get_character_by_pk(val.pk).name + @property + def difficulty(self): + return self.episode.difficulty if self.episode else "easy" + class LevelBlock(models.Model): type = models.ForeignKey(Block, on_delete=models.CASCADE) diff --git a/game/static/game/css/backgrounds.css b/game/static/game/css/backgrounds.css new file mode 100644 index 000000000..4d6b004e4 --- /dev/null +++ b/game/static/game/css/backgrounds.css @@ -0,0 +1,29 @@ +/* Background colours for episodes and game sidebar */ + +.bg--easy { + background: #86ae18; +} + +.bg--medium { + background: #00a3e0; +} + +.bg--medium-hard { + background: #008cc1; +} + +.bg--brainteasers { + background: #c90548; +} + +.bg--hard { + background: #8967d3; +} + +.bg--advanced { + background: #754fc8; +} + +.bg--shared-levels { + background: #f6be00; +} diff --git a/game/static/game/css/game.css b/game/static/game/css/game.css index 2d2eaac65..6a6ab31e9 100644 --- a/game/static/game/css/game.css +++ b/game/static/game/css/game.css @@ -25,10 +25,27 @@ #tabs { width: 95px; height: 100%; - background-color: #a0c53a; float: left; } +#tabs span { + color: white; +} + +#tabs img { + filter: invert(1); +} + +#tabs #blockly_tab span, +#tabs #python_tab span { + color: black; +} + +#tabs #blockly_tab img, +#tabs #python_tab img { + filter: none; +} + #right { position: relative; height: 100%; diff --git a/game/static/game/css/game_screen.css b/game/static/game/css/game_screen.css index c3075c63d..aa2e0f4a7 100644 --- a/game/static/game/css/game_screen.css +++ b/game/static/game/css/game_screen.css @@ -318,13 +318,9 @@ table th { line-height: 20px; } -.tab label:hover { - background: rgba(255, 255, 255, 0.5); -} - +.tab label:hover, .tab input[type='radio']:checked + label { - background: rgba(255, 255, 255, 1); - opacity: 1; + background: rgba(255, 255, 255, 0.25); } .tab_pane { @@ -371,11 +367,16 @@ table th { margin-right: 0.5em; } -#modal-mascot { +#modal-mascot, +#modal-mascot--brain { float: right; width: 20%; } +#modal-mascot--brain { + transform: scaleX(-1); +} + #myModal pre { margin: 1em 2em 0.3em; } diff --git a/game/static/game/css/level_editor.css b/game/static/game/css/level_editor.css index f008f2ef5..410efd050 100644 --- a/game/static/game/css/level_editor.css +++ b/game/static/game/css/level_editor.css @@ -174,6 +174,14 @@ input { float: left; } +#tabs .tab span { + color: white; +} + +#tabs .tab img { + filter: invert(1); +} + #tab_panes_wrapper { margin-left: 120px; height: 100%; diff --git a/game/static/game/css/level_selection.css b/game/static/game/css/level_selection.css index b1b58530f..958c00739 100644 --- a/game/static/game/css/level_selection.css +++ b/game/static/game/css/level_selection.css @@ -4,7 +4,6 @@ #episodes .panel-header { color: #fff; - background: #6e7171; margin-bottom: 0; text-align: left; padding-left: 10px; @@ -12,20 +11,7 @@ font-size: 17px; } -#episodes .bg-tertiary { - background: #00a3e0; /* color-tertiary-500 */ -} - -#episodes .bg-tertiary-dark { - background: #008cc1; /* color-tertiary-700 */ -} - -#episodes .bg-primary { - background: #e0004d; /* color-primary-500 */ -} - -#episodes .bg-secondary { - background: #f6be00; /* color-secondary-500 */ +#episodes .bg--shared-levels { color: #000; font-weight: 500; } diff --git a/game/static/game/image/icons/clear.svg b/game/static/game/image/icons/clear.svg index 7f57fa897..12b82f6fc 100644 --- a/game/static/game/image/icons/clear.svg +++ b/game/static/game/image/icons/clear.svg @@ -1,6 +1,6 @@ - + diff --git a/game/static/game/image/icons/quit.svg b/game/static/game/image/icons/quit.svg index 39a44916b..deac8d86e 100644 --- a/game/static/game/image/icons/quit.svg +++ b/game/static/game/image/icons/quit.svg @@ -1,5 +1,5 @@ - + diff --git a/game/static/game/image/icons/random.svg b/game/static/game/image/icons/random.svg index 225491630..4ce2c7830 100644 --- a/game/static/game/image/icons/random.svg +++ b/game/static/game/image/icons/random.svg @@ -1,6 +1,6 @@ - + diff --git a/game/static/game/js/drawing.js b/game/static/game/js/drawing.js index f2438a74a..65f09d93d 100644 --- a/game/static/game/js/drawing.js +++ b/game/static/game/js/drawing.js @@ -1036,10 +1036,16 @@ ocargo.Drawing.startPopup = function ( $('#myModal-lead').html(subtitle) $('#myModal-mainText').html(message) + $('#modal-mascot').hide() + $('#modal-mascot--brain').hide() + if (mascot) { - $('#modal-mascot').show() - } else { - $('#modal-mascot').hide() + if (EPISODE === 9) { + $('#modal-mascot--brain').show() + } + else { + $('#modal-mascot').show() + } } if (buttons) { diff --git a/game/static/game/js/game.js b/game/static/game/js/game.js index 74d0cc9ee..f97f02642 100644 --- a/game/static/game/js/game.js +++ b/game/static/game/js/game.js @@ -116,7 +116,7 @@ ocargo.Game.prototype.setup = function () { title, LESSON, message, - true, + BLOCKLY_ENABLED && !PYTHON_VIEW_ENABLED, // show mascot on Blockly-only levels ocargo.button.dismissButtonHtml('play_button', gettext('Play')) ) } @@ -786,7 +786,7 @@ ocargo.Game.prototype._setupPythonTab = function () { $('#van_commands_help').click( function (e) { - ocargo.Drawing.startPopup(gettext('Python Commands'), leadMsg, '', true) + ocargo.Drawing.startPopup(gettext('Python Commands'), leadMsg, '') }.bind(this) ) diff --git a/game/templates/game/base.html b/game/templates/game/base.html index 7cb4409b4..256154b71 100644 --- a/game/templates/game/base.html +++ b/game/templates/game/base.html @@ -10,59 +10,68 @@ {% endblock head %} +{% block css %} + {{block.super}} + +{% endblock %} + {% block subNav %} -{{ block.super }} -{% block header %} -