diff --git a/game/level_management.py b/game/level_management.py index ca73220dc..cb61a8f6f 100644 --- a/game/level_management.py +++ b/game/level_management.py @@ -165,6 +165,7 @@ def save_level(level, data): level.pythonViewEnabled = data.get("pythonViewEnabled", False) level.theme = get_theme_by_pk(pk=data["theme"]) level.character = get_character_by_pk(pk=data["character"]) + level.disable_algorithm_score = data.get("disable_algorithm_score", False) level.save() set_decor(level, data["decor"]) diff --git a/game/migrations/0092_disable_algo_score_in_custom_levels.py b/game/migrations/0092_disable_algo_score_in_custom_levels.py new file mode 100644 index 000000000..678f5da25 --- /dev/null +++ b/game/migrations/0092_disable_algo_score_in_custom_levels.py @@ -0,0 +1,28 @@ +from django.apps.registry import Apps +from django.db import migrations + +def disable_algo_score_for_existing_custom_levels(apps: Apps, *args): + Level = apps.get_model("game", "Level") + + Level.objects.filter( + default=False + ).update(disable_algorithm_score=True) + +def enable_algo_score_for_existing_custom_levels(apps: Apps, *args): + Level = apps.get_model("game", "Level") + + Level.objects.filter( + default=False + ).update(disable_algorithm_score=False) + +class Migration(migrations.Migration): + dependencies = [ + ("game", "0091_disable_algo_score_if_no_model_solution") + ] + + operations = [ + migrations.RunPython( + disable_algo_score_for_existing_custom_levels, + reverse_code=enable_algo_score_for_existing_custom_levels + ) + ] \ No newline at end of file diff --git a/game/static/game/js/level_editor.js b/game/static/game/js/level_editor.js index c5fed2189..96b0f7739 100644 --- a/game/static/game/js/level_editor.js +++ b/game/static/game/js/level_editor.js @@ -2284,6 +2284,7 @@ ocargo.LevelEditor = function(levelId) { // Other data state.theme = currentTheme.id; state.character = $('#character_select').val(); + state.disable_algorithm_score = true; return state; } diff --git a/game/templates/game/game.html b/game/templates/game/game.html index c4e8df780..ace7b34d0 100644 --- a/game/templates/game/game.html +++ b/game/templates/game/game.html @@ -7,15 +7,15 @@ {% block scripts %} {{block.super}} -