diff --git a/game/messages.py b/game/messages.py
index ae8862990..ee2c83d06 100644
--- a/game/messages.py
+++ b/game/messages.py
@@ -36,9 +36,7 @@ def if_else_icon_url():
def if_else_example_url():
- return (
- ''
- )
+ return ''
def not_shared_level():
@@ -1940,6 +1938,7 @@ def hint_level91():
"Beginner's Guide to Python."
)
+
def title_level92():
return "Start with the basics, forward, left and right"
@@ -1952,13 +1951,16 @@ def description_level92():
)
return build_description(title_level92(), message)
+
def commands_level92():
- return ('Movement'+
- '
my_van.move_forwards()' +
- '
my_van.turn_left()' +
- '
my_van.turn_right()'
+ return (
+ "Movement"
+ + "
my_van.move_forwards()"
+ + "
my_van.turn_left()"
+ + "
my_van.turn_right()"
)
+
def hint_level92():
return (
"Try using the following commands:
my_van.move_forwards()
my_van.turn_left()" @@ -1977,13 +1979,16 @@ def description_level93(): ) return build_description(title_level93(), message) + def commands_level93(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level93(): return ( """Try using the following commands: @@ -2005,13 +2010,16 @@ def description_level94(): ) return build_description(title_level94(), message) + def commands_level94(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level94(): return ( """Try using the following commands: @@ -2033,13 +2041,16 @@ def description_level95(): ) return build_description(title_level95(), message) + def commands_level95(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level95(): return ( """To repeat some statements a set number of times you can use something like the following: @@ -2063,11 +2074,10 @@ def description_level96(): ) return build_description(title_level96(), message) + def commands_level96(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' - ) + return "Movement" + "
my_van.move_forwards()" + "
my_van.turn_left()" + def hint_level96(): return ( @@ -2091,13 +2101,16 @@ def description_level97(): ) return build_description(title_level97(), message) + def commands_level97(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level97(): return ( """To repeat within a repeats a set number of times you can use something like the following: @@ -2123,19 +2136,22 @@ def description_level98(): ) return build_description(title_level98(), message) + def commands_level98(): - return ('' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - 'Position' + - '' + - '
my_van.at_destination()' + - '
my_van.is_road_forward()' + + '' ) + def hint_level98(): return ( """To repeat while a condition is met you can use something like the following: @@ -2161,22 +2177,25 @@ def description_level99(): ) return build_description(title_level99(), message) + def commands_level99(): - return ('' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()' + + "Position" + + "" + + '
my_van.at_destination()" + + "
my_van.is_road_forward()' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + - 'Position' + - '' + - '
my_van.at_destination()' + - '
my_van.is_road_right()' + - '
my_van.is_road_left()' + - '
my_van.is_road_forward()' + + '' ) + def hint_level99(): return ( """To repeat while a condition is met you can use something like the following: @@ -2201,22 +2220,25 @@ def description_level100(): ) return build_description(title_level100(), message) + def commands_level100(): - return ('' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.at_destination()" + + "
my_van.is_road_right()" + + "
my_van.is_road_left()" + + "
my_van.is_road_forward()' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + - 'Position'+ - '' + - '
my_van.at_destination()' + - '
my_van.is_road_forward()' + - '
my_van.is_road_right()' + - '
my_van.is_road_left()' + + '' ) + def hint_level100(): return ( "Try using' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.at_destination()" + + "
my_van.is_road_forward()" + + "
my_van.is_road_right()" + + "
my_van.is_road_left()if my_van.at_dead_end():
to check if the van is at a dead end." @@ -2236,13 +2258,16 @@ def description_level101(): ) return build_description(title_level101(), message) + def commands_level101(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level101(): return ( """To define a function in Python you could do something like: @@ -2266,13 +2291,16 @@ def description_level102(): ) return build_description(title_level102(), message) + def commands_level102(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level102(): return ( """To define a function in Python you could do something like: @@ -2295,13 +2323,16 @@ def description_level103(): ) return build_description(title_level103(), message) + def commands_level103(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level103(): return ( """To define a function that calls another function you could do something like: @@ -2328,13 +2359,16 @@ def description_level104(): ) return build_description(title_level104(), message) + def commands_level104(): - return ('Movement'+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()' + return ( + "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" ) + def hint_level104(): return ( """To define a function that calls another function you could do something like: @@ -2361,23 +2395,26 @@ def description_level105(): ) return build_description(title_level105(), message) + def commands_level105(): - return ('' + - '' + return ( + '' + - 'Movement'+ - '' + - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - '
my_van.turn_right()'+ - '
my_van.wait()' + - 'Position' + - '' + - '
my_van.is_road_forward()' + - '
my_van.is_road_left()' + - '
my_van.at_red_traffic_light()' + - '
my_van.at_destination()' + + '' ) + def hint_level105(): return ( "For this you will have to use a combination of the while and if statements." @@ -2398,18 +2435,21 @@ def description_level106(): ) return build_description(title_level106(), message) + def commands_level106(): - return ('' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" + + "
my_van.wait()' + + "Position" + + "" + + '
my_van.is_road_forward()" + + "
my_van.is_road_left()" + + "
my_van.at_red_traffic_light()" + + "
my_van.at_destination()' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_right()' + - 'Position' + - '' + - '
my_van.at_destination()' + + '' ) + def hint_level106(): return ( """To use a variable to store the number of grid squares the van has to move you can do something like the following: @@ -2435,18 +2475,21 @@ def description_level107(): ) return build_description(title_level107(), message) + def commands_level107(): - return ('' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.at_destination()' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - 'Position' + - '' + - '
my_van.at_destination()' + + '' ) + def hint_level107(): return ( "To double the value of a variable you can do something like the following:' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()' + + "Position" + + "" + + '
my_van.at_destination()number *= 2" @@ -2462,18 +2505,21 @@ def description_level108(): message = "This time the straight sections of road decrease in length by 2 after each turn." return build_description(title_level108(), message) + def commands_level108(): - return ('' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_left()' + - 'Position' + - '' + - '
my_van.at_destination()' + + '' ) + def hint_level108(): return ( "To decrease the value of a variable by an amount you can do something like the " @@ -2492,17 +2538,19 @@ def description_level109(): ) return build_description(title_level109(), message) + def commands_level109(): - return ('' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()' + + "Position" + + "" + + '
my_van.at_destination()' + - '' + return ( + '' + - 'Movement'+ - ''+ - '
my_van.move_forwards()' + - '
my_van.turn_right()'+ - '
my_van.turn_left()' + - 'Position' + - '' + - '
my_van.at_destination()' + + '' ) @@ -2567,7 +2615,10 @@ def hint_level109(): "Can you remember how the Python was formed under the blocks in the previous levels? Take a look in the Py Commands for a quick reminder.", ), lambda: "Now it is your turn, you can click on the Py commands button for a reminder of the Python commands that you can use.", - lambda: 'Movement'+ '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_right()" + + "
my_van.turn_left()' + + "Position" + + "" + + '
my_van.at_destination()
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) ( @@ -2582,7 +2633,10 @@ def hint_level109(): "This route is just a bit longer. Make sure you type the Python code accurately!", ), lambda: "The most common errors here are missing the round brackets at the end of the commands or mistyping the commands, e.g. use my_van.move_fowards() and not my_van.move_foward()", - lambda: 'Movement'+ '
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) ( @@ -2597,7 +2651,10 @@ def hint_level109(): "Try to find the shortest route using Python code only. You are getting really good at this!", ), lambda: "If you are stuck on this one, check that you are using the Python commands accurately. Click the Py Commands button to help you.", - lambda: 'Movement'+ '
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) ( @@ -2651,7 +2708,10 @@ def hint_level109(): "Look for a pattern and then count how many times it repeats. Good luck!", ), lambda: "If you cannot solve this one, try creating a solution without a while loop and then looking for what is repeated...", - lambda: 'Movement'+ '
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) ( @@ -2666,7 +2726,10 @@ def hint_level109(): "There is a pattern of moves in this one too. Can you spot it?", ), lambda: "What if you go down the middle section?", - lambda: 'Movement'+ '
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) ( @@ -2681,7 +2744,10 @@ def hint_level109(): "Look for a pattern before you type any code. You can solve this one with a counted loop…", ), lambda: "Try that middle route...", - lambda: 'Movement'+ '
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) ( @@ -2696,7 +2762,10 @@ def hint_level109(): "The solution to this one is just a bit longer. Build it up slowly. Good luck!", ), lambda: "Don't try to solve this in one go. Work out the pattern for the top route and check that works. Then move on to the next part...", - lambda: 'Movement'+ '
my_van.move_forwards()' +'
my_van.turn_left()' +'
my_van.turn_right()', + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) @@ -3021,8 +3090,11 @@ def hint_level109(): hint_level1014, ) = ( lambda: "Too many cows", - lambda: build_description(title_level1014(), "This is a nice long straight road, but there are cows about!"), - lambda: "Make sure you sound the horn to get the cows off the road." + lambda: build_description( + title_level1014(), + "This is a nice long straight road, but there are cows about!", + ), + lambda: "Make sure you sound the horn to get the cows off the road.", ) ( @@ -3031,38 +3103,61 @@ def hint_level109(): hint_level1015, ) = ( lambda: "Stepping it up", - lambda: build_description(title_level1015(), "There are some bends in this road. Be careful!"), - lambda: "What do you need to count, how many times you move or how many times you move forwards?" + lambda: build_description( + title_level1015(), "There are some bends in this road. Be careful!" + ), + lambda: "What do you need to count, how many times you move or how many times you move forwards?", ) -( - title_level1016, - description_level1016, - hint_level1016, -) = ( +(title_level1016, description_level1016, hint_level1016, commands_level1016) = ( lambda: "Cows on the stairs", - lambda: build_description(title_level1016(), "Oh no! The farmer seems to have let their cows out again. Be careful."), - lambda: "Look for a pattern here..." -) - -( - title_level1017, - description_level1017, - hint_level1017, -) = ( + lambda: build_description( + title_level1016(), + "Oh no! The farmer seems to have let their cows out again. Be careful.", + ), + lambda: "Look for a pattern here...", + lambda: '' + + '', +) + +(title_level1017, description_level1017, hint_level1017, commands_level1017) = ( lambda: "Try stepping in Python!", - lambda: build_description(title_level1017(), "Keep going, you're getting the hang of the Python code."), - lambda: "So you are going forward unless...?" -) - -( - title_level1018, - description_level1018, - hint_level1018, -) = ( + lambda: build_description( + title_level1017(), "Keep going, you're getting the hang of the Python code." + ), + lambda: "So you are going forward unless...?", + lambda: '' + + "Movement" + + "" + + '
my_van.turn_left()" + + "
my_van.turn_right()" + + "
my_van.sound_horn()' + + "" + + '
my_van.is_animal_crossing()' + + '', +) + +(title_level1018, description_level1018, hint_level1018, commands_level1018) = ( lambda: "A long and winding road", lambda: build_description(title_level1018(), "Oh dear, you might get a bit dizzy!"), - lambda: "What are you counting here, straight roads or bends?" + lambda: "What are you counting here, straight roads or bends?", + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.is_road_forward()' + + '', ) ( @@ -3071,28 +3166,48 @@ def hint_level109(): hint_level1019, ) = ( lambda: "Try this level... or else!", - lambda: build_description(title_level1019(), "Have you noticed that there are more roads ahead than turns? Try checking if there is a road ahead and then otherwise making the turns you need..."), - lambda: "Remember to use if..else" + lambda: build_description( + title_level1019(), + "Have you noticed that there are more roads ahead than turns? Try checking if there is a road ahead and then otherwise making the turns you need...", + ), + lambda: "Remember to use if..else", ) -( - title_level1020, - description_level1020, - hint_level1020, -) = ( +(title_level1020, description_level1020, hint_level1020, commands_level1020) = ( lambda: "Now try one in Python!", - lambda: build_description(title_level1020(), "Use if..else in Python for this level"), - lambda: "Don't get distracted by the other roads. Look for a pattern you can repeat." -) - -( - title_level1021, - description_level1021, - hint_level1021, -) = ( + lambda: build_description( + title_level1020(), "Use if..else in Python for this level" + ), + lambda: "Don't get distracted by the other roads. Look for a pattern you can repeat.", + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()' + + "Position" + + "" + + '
my_van.is_road_left()' + + '', +) + +(title_level1021, description_level1021, hint_level1021, commands_level1021) = ( lambda: "What if there are multiple houses?", - lambda: build_description(title_level1021(), "This is a really busy road. Make sure that you don't miss any of the houses."), - lambda: "Did you get the last house? Think about what value the loop counter will have at that point in your code..." + lambda: build_description( + title_level1021(), + "This is a really busy road. Make sure that you don't miss any of the houses.", + ), + lambda: "Did you get the last house? Think about what value the loop counter will have at that point in your code...", + lambda: '' + + "Movement" + + "" + + '
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.is_road_left()' + + '', ) ( @@ -3101,8 +3216,10 @@ def hint_level109(): hint_level1022, ) = ( lambda: "Count and check", - lambda: build_description(title_level1022(), "There are lots of turns here, don't get distracted."), - lambda: "Think about the order of the questions you ask using your if and elif statements." + lambda: build_description( + title_level1022(), "There are lots of turns here, don't get distracted." + ), + lambda: "Think about the order of the questions you ask using your if and elif statements.", ) ( @@ -3112,38 +3229,54 @@ def hint_level109(): ) = ( lambda: "Another twisty trip", lambda: build_description(title_level1023(), "Don't go the long way around!"), - lambda: "Think carefully about the order in which you ask questions in your if..else if block" + lambda: "Think carefully about the order in which you ask questions in your if..else if block", ) -( - title_level1024, - description_level1024, - hint_level1024, -) = ( +(title_level1024, description_level1024, hint_level1024, commands_level1024) = ( lambda: "Give Python a go!", - lambda: build_description(title_level1024(), "Look carefully for the shortest route."), - lambda: "Think carefully about the order in which you ask questions in your if..elif statements." -) - -( - title_level1025, - description_level1025, - hint_level1025, -) = ( + lambda: build_description( + title_level1024(), "Look carefully for the shortest route." + ), + lambda: "Think carefully about the order in which you ask questions in your if..elif statements.", + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" + + "
my_van.deliver()' + + "Position" + + "" + + '
my_van.is_road_left()' + + '', +) + +(title_level1025, description_level1025, hint_level1025, commands_level1025) = ( lambda: "Now we've added a traffic light", - lambda: build_description(title_level1025(), "Look carefully for the shortest route."), - lambda: "Think carefully about the order in which you ask questions in your if..elif statements. Don't forget the traffic lights." + lambda: build_description( + title_level1025(), "Look carefully for the shortest route." + ), + lambda: "Think carefully about the order in which you ask questions in your if..elif statements. Don't forget the traffic lights.", + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.is_road_forward()" + + "
my_van.is_road_left()' + + '', ) ( title_level1026, description_level1026, hint_level1026, -) = ( - lambda: title_level85(), - lambda: description_level85(), - lambda: hint_level85() -) +) = (lambda: title_level85(), lambda: description_level85(), lambda: hint_level85()) ( title_level1027, @@ -3151,8 +3284,10 @@ def hint_level109(): hint_level1027, ) = ( lambda: "Full steam ahead", - lambda: build_description(title_level1027(), "Just keep going until you get there..."), - lambda: "You might find that the solution to this level is quite familiar..." + lambda: build_description( + title_level1027(), "Just keep going until you get there..." + ), + lambda: "You might find that the solution to this level is quite familiar...", ) ( @@ -3161,39 +3296,39 @@ def hint_level109(): hint_level1028, ) = ( lambda: "Another staircase...", - lambda: build_description(title_level1028(), "Well done, you did it! Now have a go at using the Repeat until block on a road with lots of turns."), - lambda: "This is another route you have seen before. Last time you counted how many times your instructions were repeated. This time, your program is going to repeat your commands until you reach the destination. What do you need to repeat?" + lambda: build_description( + title_level1028(), + "Well done, you did it! Now have a go at using the Repeat until block on a road with lots of turns.", + ), + lambda: "This is another route you have seen before. Last time you counted how many times your instructions were repeated. This time, your program is going to repeat your commands until you reach the destination. What do you need to repeat?", ) ( title_level1029, description_level1029, hint_level1029, -) = ( - lambda: title_level119(), - lambda: description_level119(), - lambda: hint_level119() -) +) = (lambda: title_level119(), lambda: description_level119(), lambda: hint_level119()) -( - title_level1030, - description_level1030, - hint_level1030, -) = ( +(title_level1030, description_level1030, hint_level1030, commands_level1030) = ( lambda: title_level84(), lambda: description_level84(), - lambda: hint_level84() + lambda: hint_level84(), + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" + + "
my_van.wait()' + + "Position" + + "" + + '
my_van.is_road_forward()" + + "
my_van.is_road_left()" + + "
my_van.at_red_traffic_light()' + + '', ) ( title_level1031, description_level1031, hint_level1031, -) = ( - lambda: title_level34(), - lambda: description_level34(), - lambda: hint_level34() -) +) = (lambda: title_level34(), lambda: description_level34(), lambda: hint_level34()) ( title_level1032, @@ -3201,118 +3336,146 @@ def hint_level109(): hint_level1032, ) = ( lambda: "Something isn't right", - lambda: build_description(title_level1032(), "You don't have a right turn block here, so plan your route carefully."), - lambda: "Think carefully about the order in which you ask questions in your if-statement here..." + lambda: build_description( + title_level1032(), + "You don't have a right turn block here, so plan your route carefully.", + ), + lambda: "Think carefully about the order in which you ask questions in your if-statement here...", ) -( - title_level1033, - description_level1033, - hint_level1033, -) = ( +(title_level1033, description_level1033, hint_level1033, commands_level1033) = ( lambda: "Looking both ways", lambda: build_description(title_level1033(), "Can you find the shortest route?"), - lambda: "In this level, you want to check for a left turn first. If there is no left turn, turn right. Notice what that looks like in Python." -) - -( - title_level1034, - description_level1034, - hint_level1034, -) = ( + lambda: "In this level, you want to check for a left turn first. If there is no left turn, turn right. Notice what that looks like in Python.", + lambda: '' + + "Movement" + + "" + + '
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.at_destination()' + + '', +) + +(title_level1034, description_level1034, hint_level1034, commands_level1034) = ( lambda: "The pond is nice but out of the way", - lambda: build_description(title_level1034(), "Can you find the shortest route? Don't take the scenic route."), - lambda: "Just look for the simplest route to the house." + lambda: build_description( + title_level1034(), + "Can you find the shortest route? Don't take the scenic route.", + ), + lambda: "Just look for the simplest route to the house.", + lambda: '' + + "Movement" + + "" + + '
my_van.turn_left()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.is_road_left()" + + "
my_van.at_destination()' + + '', ) ( title_level1035, description_level1035, hint_level1035, -) = ( - lambda: title_level99(), - lambda: description_level99(), - lambda: hint_level99() -) +) = (lambda: title_level99(), lambda: description_level99(), lambda: hint_level99()) ( title_level1036, description_level1036, hint_level1036, -) = ( - lambda: title_level38(), - lambda: description_level38(), - lambda: hint_level38() -) +) = (lambda: title_level38(), lambda: description_level38(), lambda: hint_level38()) -( - title_level1037, - description_level1037, - hint_level1037, -) = ( +(title_level1037, description_level1037, hint_level1037, commands_level1037) = ( lambda: title_level100(), lambda: description_level100(), - lambda: hint_level100() + lambda: hint_level100(), + lambda: commands_level100(), ) -( - title_level1038, - description_level1038, - hint_level1038, -) = ( +(title_level1038, description_level1038, hint_level1038, commands_level1038) = ( lambda: title_level39(), lambda: description_level39(), - lambda: hint_level39() -) - -( - title_level1039, - description_level1039, - hint_level1039, -) = ( + lambda: hint_level39(), + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_right()' + + "Position" + + "" + + '
my_van.is_road_right()" + + "
my_van.at_destination()' + + '', +) + +(title_level1039, description_level1039, hint_level1039, commands_level1039) = ( lambda: title_level47(), lambda: description_level47(), - lambda: hint_level47() -) - -( - title_level1040, - description_level1040, - hint_level1040, -) = ( + lambda: hint_level47(), + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_around()" + + "
my_van.turn_right()" + + "
my_van.sound_horn()' + + "Position" + + "" + + '
my_van.is_animal_crossing()" + + "
my_van.at_destination()" + + "
my_van.is_road_forward()" + + "
my_van.at_dead_end()' + + '', +) + +(title_level1040, description_level1040, hint_level1040, commands_level40) = ( lambda: title_level48(), lambda: description_level48(), - lambda: hint_level48() + lambda: hint_level48(), + lambda: '' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.sound_horn()' + + "Position" + + "" + + '
my_van.is_animal_crossing()" + + "
my_van.at_destination()" + + "
my_van.is_road_forward()' + + '', ) ( title_level1041, description_level1041, hint_level1041, -) = ( - lambda: title_level83(), - lambda: description_level83(), - lambda: hint_level83() -) +) = (lambda: title_level83(), lambda: description_level83(), lambda: hint_level83()) -( - title_level1042, - description_level1042, - hint_level1042, -) = ( +(title_level1042, description_level1042, hint_level1042, commands_level1042) = ( lambda: title_level95(), lambda: description_level95(), - lambda: hint_level95() + lambda: hint_level95(), + lambda: commands_level95(), ) -( - title_level1043, - description_level1043, - hint_level1043, -) = ( +(title_level1043, description_level1043, hint_level1043, commands_level1043) = ( lambda: title_level96(), lambda: description_level96(), - lambda: hint_level96() + lambda: hint_level96(), + lambda: commands_level96(), ) ( @@ -3322,167 +3485,138 @@ def hint_level109(): ) = ( lambda: title_level84(), lambda: description_level84(), - lambda: hint_level84() + lambda: hint_level84(), ) -( - title_level1045, - description_level1045, - hint_level1045, -) = ( +(title_level1045, description_level1045, hint_level1045, commands_level1045) = ( lambda: title_level97(), lambda: description_level97(), - lambda: hint_level97() + lambda: hint_level97(), + lambda: commands_level97(), ) -( - title_level1046, - description_level1046, - hint_level1046, -) = ( +(title_level1046, description_level1046, hint_level1046, commands_level1046) = ( lambda: title_level106(), lambda: description_level106(), - lambda: hint_level106() + lambda: hint_level106(), + lambda: commands_level106(), ) -( - title_level1047, - description_level1047, - hint_level1047, -) = ( +(title_level1047, description_level1047, hint_level1047, commands_level1047) = ( lambda: title_level107(), lambda: description_level107(), - lambda: hint_level107() + lambda: hint_level107(), + lambda: commands_level107(), ) -( - title_level1048, - description_level1048, - hint_level1048, -) = ( +(title_level1048, description_level1048, hint_level1048, commands_level1048) = ( lambda: title_level108(), lambda: description_level108(), - lambda: hint_level108() + lambda: hint_level108(), + lambda: commands_level108(), ) -( - title_level1049, - description_level1049, - hint_level1049, -) = ( +(title_level1049, description_level1049, hint_level1049, commands_level1049) = ( lambda: title_level109(), lambda: description_level109(), - lambda: hint_level109() + lambda: hint_level109(), + lambda: commands_level109(), ) ( title_level1050, description_level1050, hint_level1050, -) = ( - lambda: title_level61(), - lambda: description_level61(), - lambda: hint_level61() -) +) = (lambda: title_level61(), lambda: description_level61(), lambda: hint_level61()) ( title_level1051, description_level1051, hint_level1051, -) = ( - lambda: title_level62(), - lambda: description_level62(), - lambda: hint_level62() -) +) = (lambda: title_level62(), lambda: description_level62(), lambda: hint_level62()) -( - title_level1052, - description_level1052, - hint_level1052, -) = ( +(title_level1052, description_level1052, hint_level1052, commands_level1052) = ( lambda: title_level63(), lambda: description_level63(), - lambda: hint_level63() + lambda: hint_level63(), + lambda: "Movement" + + "' + + "Movement" + + "" + + '
my_van.move_forwards()" + + "
my_van.turn_around()" + + "
my_van.turn_left()" + + "
my_van.turn_right()" + + "
my_van.wait()' + + "Position" + + "" + + '
my_van.at_red_traffic_light()" + + "
my_van.at_destination()" + + "
my_van.is_road_forward()" + + "
my_van.is_road_left()" + + "
my_van.is_road_right()" + + "
my_van.at_dead_end()
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1053, - description_level1053, - hint_level1053, -) = ( +(title_level1053, description_level1053, hint_level1053, commands_level1053) = ( lambda: title_level64(), lambda: description_level64(), - lambda: hint_level64() + lambda: hint_level64(), + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1054, - description_level1054, - hint_level1054, -) = ( +(title_level1054, description_level1054, hint_level1054, commands_level1054) = ( lambda: title_level65(), lambda: description_level65(), - lambda: hint_level65() + lambda: hint_level65(), + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1055, - description_level1055, - hint_level1055, -) = ( +(title_level1055, description_level1055, hint_level1055, commands_level1055) = ( lambda: title_level66(), lambda: description_level66(), - lambda: hint_level66() + lambda: hint_level66(), + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1056, - description_level1056, - hint_level1056, -) = ( +(title_level1056, description_level1056, hint_level1056, commands_level1056) = ( lambda: title_level67(), lambda: description_level67(), - lambda: hint_level67() + lambda: hint_level67(), + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1057, - description_level1057, - hint_level1057, -) = ( +(title_level1057, description_level1057, hint_level1057, commands_level1057) = ( lambda: title_level90(), lambda: description_level90(), - lambda: hint_level90() + lambda: hint_level90(), + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1058, - description_level1058, - hint_level1058, -) = ( +(title_level1058, description_level1058, hint_level1058, commands_level1058) = ( lambda: title_level91(), lambda: description_level91(), - lambda: hint_level91() + lambda: hint_level91(), + lambda: "Movement" + + "
my_van.move_forwards()" + + "
my_van.turn_left()" + + "
my_van.turn_right()", ) -( - title_level1059, - description_level1059, - hint_level1059, -) = ( +(title_level1059, description_level1059, hint_level1059, commands_level1059) = ( lambda: title_level101(), lambda: description_level101(), - lambda: hint_level101() + lambda: hint_level101(), + lambda: commands_level101(), ) -( - title_level1060, - description_level1060, - hint_level1060, -) = ( +(title_level1060, description_level1060, hint_level1060, commands_level1060) = ( lambda: title_level102(), lambda: description_level102(), - lambda: hint_level102() + lambda: hint_level102(), + lambda: commands_level102(), ) @@ -3510,7 +3644,7 @@ def get_episode_title(episode_id): 19: "Complex Selection", 20: "String Manipulation", 21: "Lists", - 22: "Procedures" + 22: "Procedures", } return episode_titles[episode_id] diff --git a/game/migrations/0097_add_python_den_levels.py b/game/migrations/0097_add_python_den_levels.py index 34985573a..6b02f4849 100644 --- a/game/migrations/0097_add_python_den_levels.py +++ b/game/migrations/0097_add_python_den_levels.py @@ -4,6 +4,7 @@ from django.db import migrations, models from game.level_management import set_decor_inner, set_blocks_inner + def add_python_den_levels(apps, schema_editor): Level = apps.get_model("game", "Level") Episode = apps.get_model("game", "Episode") @@ -23,7 +24,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", default=True, destinations="[[9,4]]", - disable_algorithm_score=True, + disable_algorithm_score=False, direct_drive=False, fuel_gauge=True, max_fuel=50, @@ -37,7 +38,7 @@ def add_python_den_levels(apps, schema_editor): traffic_lights="[]", cows='[{"minCows":1,"maxCows":1,"potentialCoordinates":[{"x":2,"y":4},{"x":5,"y":4},{"x":7,"y":4}],"type":"WHITE"}]', lesson="This is a nice long straight road, but there are cows about!", - hint="Make sure you sound the horn to get the cows off the road." + hint="Make sure you sound the horn to get the cows off the road.", ) level1015 = Level( @@ -53,7 +54,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[11]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -62,7 +63,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="There are some bends in this road. Be careful!", hint="What do you need to count, how many times you move or how many times you move forwards?", - anonymous=False + anonymous=False, ) level1016 = Level( @@ -87,7 +88,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Oh no! The farmer seems to have let their cows out again. Be careful.", hint="Look for a pattern here...", - anonymous=False + anonymous=False, ) level1017 = Level( @@ -112,7 +113,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Keep going, you're getting the hang of the Python code.", hint="So you are going forward unless...?", - anonymous=False + anonymous=False, ) level1018 = Level( @@ -128,7 +129,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[10]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=False, pythonEnabled=True, @@ -137,7 +138,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Oh dear, you might get a bit dizzy!", hint="What are you counting here, straight roads or bends?", - anonymous=False + anonymous=False, ) level1019 = Level( @@ -153,7 +154,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[11]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -162,7 +163,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Have you noticed that there are more roads ahead than turns? Try checking if there is a road ahead and then otherwise making the turns you need...", hint="Remember to use if..else", - anonymous=False + anonymous=False, ) level1020 = Level( @@ -187,7 +188,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Use if..else in Python for this level", hint="Don't get distracted by the other roads. Look for a pattern you can repeat.", - anonymous=False + anonymous=False, ) level1021 = Level( @@ -212,7 +213,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="This is a really busy road. Make sure that you don't miss any of the houses.", hint="Did you get the last house? Think about what value the loop counter will have at that point in your code...", - anonymous=False + anonymous=False, ) level1022 = Level( @@ -228,7 +229,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[12]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -237,7 +238,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="There are lots of turns here, don't get distracted.", hint="Think about the order of the questions you ask using your if and elif statements.", - anonymous=False + anonymous=False, ) level1023 = Level( @@ -253,7 +254,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[12]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -262,7 +263,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Don't go the long way around!", hint="Think carefully about the order in which you ask questions in your if..else if block", - anonymous=False + anonymous=False, ) level1024 = Level( @@ -287,7 +288,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Look carefully for the shortest route.", hint="Think carefully about the order in which you ask questions in your if..elif statements.", - anonymous=False + anonymous=False, ) level1025 = Level( @@ -312,7 +313,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Look carefully for the shortest route.", hint="Think carefully about the order in which you ask questions in your if..elif statements. Don't forget the traffic lights.", - anonymous=False + anonymous=False, ) level1026 = Level.objects.get(name="85", default=True) @@ -320,7 +321,7 @@ def add_python_den_levels(apps, schema_editor): level1026._state.adding = True level1026.name = "1026" level1026.model_solution = "[4]" - level1026.disable_algorithm_score = True + level1026.disable_algorithm_score = False level1026.episode = episode14 level1027 = Level( @@ -335,7 +336,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[4]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -344,15 +345,15 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Just keep going until you get there...", hint="You might find that the solution to this level is quite familiar...", - anonymous=False + anonymous=False, ) level1028 = Level( name="1028", episode=episode14, path='[{"coordinate":[2,2],"connectedNodes":[1]},{"coordinate":[3,2],"connectedNodes":[0,2]},{"coordinate":[3,3],"connectedNodes":[3,1]},{"coordinate":[4,3],"connectedNodes":[2,4]},{"coordinate":[4,4],"connectedNodes":[5,3]},{"coordinate":[5,4],"connectedNodes":[4,6]},{"coordinate":[5,5],"connectedNodes":[7,5]},{"coordinate":[6,5],"connectedNodes":[6,8]},{"coordinate":[6,6],"connectedNodes":[9,7]},{"coordinate":[7,6],"connectedNodes":[8]}]', - traffic_lights='[]', - cows='[]', + traffic_lights="[]", + cows="[]", origin='{"coordinate":[2,2],"direction":"E"}', destinations="[[7,6]]", default=True, @@ -360,7 +361,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[5]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -369,7 +370,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Well done, you did it! Now have a go at using the Repeat until block on a road with lots of turns.", hint="This is another route you have seen before. Last time you counted how many times your instructions were repeated. This time, your program is going to repeat your commands until you reach the destination. What do you need to repeat?", - anonymous=False + anonymous=False, ) level1029 = Level.objects.get(name="119", default=True) @@ -380,6 +381,7 @@ def add_python_den_levels(apps, schema_editor): level1029.pythonEnabled = False level1029.pythonViewEnabled = True level1029.model_solution = "[7]" + level1029.disable_algorithm_score = False level1029.episode = episode14 level1030 = Level.objects.get(name="84", default=True) @@ -391,7 +393,7 @@ def add_python_den_levels(apps, schema_editor): level1030.pythonViewEnabled = False level1030.model_solution = "[]" level1030.disable_algorithm_score = True - level1030.episode=episode14 + level1030.episode = episode14 level1031 = Level.objects.get(name="34", default=True) level1031.pk = None @@ -401,15 +403,15 @@ def add_python_den_levels(apps, schema_editor): level1031.pythonEnabled = False level1031.pythonViewEnabled = True level1031.model_solution = "[7]" - level1031.disable_algorithm_score = True - level1031.episode=episode14 + level1031.disable_algorithm_score = False + level1031.episode = episode14 level1032 = Level( name="1032", episode=episode14, path='[{"coordinate":[5,0],"connectedNodes":[1]},{"coordinate":[5,1],"connectedNodes":[2,0]},{"coordinate":[5,2],"connectedNodes":[3,23,1]},{"coordinate":[5,3],"connectedNodes":[4,2]},{"coordinate":[5,4],"connectedNodes":[17,3]},{"coordinate":[4,5],"connectedNodes":[6,17]},{"coordinate":[3,5],"connectedNodes":[7,5]},{"coordinate":[2,5],"connectedNodes":[24,6,8]},{"coordinate":[2,4],"connectedNodes":[7,9]},{"coordinate":[2,3],"connectedNodes":[8,10]},{"coordinate":[2,2],"connectedNodes":[9,11]},{"coordinate":[2,1],"connectedNodes":[10,12]},{"coordinate":[3,1],"connectedNodes":[11,13]},{"coordinate":[4,1],"connectedNodes":[12,14]},{"coordinate":[4,2],"connectedNodes":[15,13]},{"coordinate":[4,3],"connectedNodes":[16,14]},{"coordinate":[4,4],"connectedNodes":[15]},{"coordinate":[5,5],"connectedNodes":[5,29,18,4]},{"coordinate":[6,5],"connectedNodes":[17,19]},{"coordinate":[7,5],"connectedNodes":[18,20]},{"coordinate":[7,4],"connectedNodes":[19,21]},{"coordinate":[7,3],"connectedNodes":[20,22]},{"coordinate":[7,2],"connectedNodes":[23,21,36]},{"coordinate":[6,2],"connectedNodes":[2,22]},{"coordinate":[1,5],"connectedNodes":[25,7]},{"coordinate":[1,6],"connectedNodes":[26,24]},{"coordinate":[2,6],"connectedNodes":[25,27]},{"coordinate":[3,6],"connectedNodes":[26,28]},{"coordinate":[4,6],"connectedNodes":[27,29]},{"coordinate":[5,6],"connectedNodes":[28,30,17]},{"coordinate":[6,6],"connectedNodes":[29,31]},{"coordinate":[7,6],"connectedNodes":[30,32]},{"coordinate":[8,6],"connectedNodes":[31,33]},{"coordinate":[8,5],"connectedNodes":[32,34]},{"coordinate":[8,4],"connectedNodes":[33,35]},{"coordinate":[8,3],"connectedNodes":[34,36]},{"coordinate":[8,2],"connectedNodes":[22,35]}]', - traffic_lights='[]', - cows='[]', + traffic_lights="[]", + cows="[]", origin='{"coordinate":[5,0],"direction":"N"}', destinations="[[4,4]]", default=True, @@ -417,7 +419,7 @@ def add_python_den_levels(apps, schema_editor): max_fuel=50, direct_drive=False, model_solution="[7]", - disable_algorithm_score=True, + disable_algorithm_score=False, threads=1, blocklyEnabled=True, pythonEnabled=False, @@ -426,7 +428,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="You don't have a right turn block here, so plan your route carefully.", hint="Think carefully about the order in which you ask questions in your if-statement here...", - anonymous=False + anonymous=False, ) level1033 = Level( @@ -447,11 +449,11 @@ def add_python_den_levels(apps, schema_editor): blocklyEnabled=False, pythonEnabled=True, pythonViewEnabled=False, - theme_name="grass", + theme_name="snow", character_name="Van", lesson="Can you find the shortest route?", hint="In this level, you want to check for a left turn first. If there is no left turn, turn right. Notice what that looks like in Python.", - anonymous=False + anonymous=False, ) level1034 = Level( @@ -476,7 +478,7 @@ def add_python_den_levels(apps, schema_editor): character_name="Van", lesson="Can you find the shortest route? Don't take the scenic route.", hint="Just look for the simplest route to the house.", - anonymous=False + anonymous=False, ) level1035 = Level.objects.get(name="99", default=True) @@ -486,7 +488,7 @@ def add_python_den_levels(apps, schema_editor): level1035.blocklyEnabled = True level1035.pythonEnabled = False level1035.pythonViewEnabled = True - level1035.episode=episode14 + level1035.episode = episode14 level1036 = Level.objects.get(name="38", default=True) level1036.pk = None @@ -494,14 +496,14 @@ def add_python_den_levels(apps, schema_editor): level1036.name = "1036" level1036.pythonViewEnabled = True level1036.model_solution = "[11]" - level1036.disable_algorithm_score = True - level1036.episode=episode14 + level1036.disable_algorithm_score = False + level1036.episode = episode14 level1037 = Level.objects.get(name="100", default=True) level1037.pk = None level1037._state.adding = True level1037.name = "1037" - level1037.episode=episode14 + level1037.episode = episode14 level1038 = Level.objects.get(name="39", default=True) level1038.pk = None @@ -512,7 +514,7 @@ def add_python_den_levels(apps, schema_editor): level1038.model_solution = "[]" level1038.disable_route_score = False level1038.disable_algorithm_score = True - level1038.episode=episode14 + level1038.episode = episode14 level1039 = Level.objects.get(name="47", default=True) level1039.pk = None @@ -522,7 +524,7 @@ def add_python_den_levels(apps, schema_editor): level1039.pythonEnabled = True level1039.model_solution = "[]" level1039.disable_algorithm_score = True - level1039.episode=episode14 + level1039.episode = episode14 level1040 = Level.objects.get(name="48", default=True) level1040.pk = None @@ -532,7 +534,7 @@ def add_python_den_levels(apps, schema_editor): level1040.pythonEnabled = True level1040.model_solution = "[]" level1040.disable_algorithm_score = True - level1040.episode=episode14 + level1040.episode = episode14 level1041 = Level.objects.get(name="83", default=True) level1041.pk = None @@ -789,6 +791,13 @@ def save_all_levels(): save_all_levels() +def delete_python_den_levels(apps, schema_editor): + Level = apps.get_model("game", "Level") + for i in range(1014, 1061): + deleted_level = Level.objects.get(name=i, default=True) + deleted_level.delete() + + def add_python_den_blocks(apps, schema_editor): Level = apps.get_model("game", "Level") LevelBlock = apps.get_model("game", "LevelBlock") @@ -830,7 +839,7 @@ def set_blocks(level, blocks): + '{"type": "sound_horn"},' + '{"type": "move_forwards"},' + '{"type": "variables_increment"}]' - ) + ), ) set_blocks( @@ -847,7 +856,7 @@ def set_blocks(level, blocks): + '{"type": "turn_right"},' + '{"type": "move_forwards"},' + '{"type": "variables_increment"}]' - ) + ), ) set_blocks( @@ -864,7 +873,7 @@ def set_blocks(level, blocks): + '{"type": "turn_right"},' + '{"type": "move_forwards"},' + '{"type": "variables_increment"}]' - ) + ), ) set_blocks( @@ -881,7 +890,7 @@ def set_blocks(level, blocks): + '{"type": "turn_right"},' + '{"type": "move_forwards"},' + '{"type": "variables_increment"}]' - ) + ), ) set_blocks( @@ -898,7 +907,7 @@ def set_blocks(level, blocks): + '{"type": "turn_right"},' + '{"type": "move_forwards"},' + '{"type": "variables_increment"}]' - ) + ), ) set_blocks( @@ -910,7 +919,7 @@ def set_blocks(level, blocks): + '{"type": "at_destination"},' + '{"type": "logic_negate"},' + '{"type": "controls_repeat_while"}]' - ) + ), ) set_blocks( @@ -920,7 +929,7 @@ def set_blocks(level, blocks): + '{"type": "logic_negate"},' + '{"type": "at_destination"},' + '{"type": "move_forwards"}]' - ) + ), ) set_blocks( @@ -931,7 +940,7 @@ def set_blocks(level, blocks): + '{"type": "at_destination"},' + '{"type": "turn_left"},' + '{"type": "turn_right"}]' - ) + ), ) set_blocks( @@ -943,7 +952,7 @@ def set_blocks(level, blocks): + '{"type": "turn_left"},' + '{"type": "turn_right"},' + '{"type": "move_forwards"}]' - ) + ), ) set_blocks( @@ -956,7 +965,7 @@ def set_blocks(level, blocks): + '{"type": "road_exists"},' + '{"type": "turn_left"},' + '{"type": "move_forwards"}]' - ) + ), ) set_blocks( @@ -969,7 +978,7 @@ def set_blocks(level, blocks): + '{"type": "road_exists"},' + '{"type": "turn_left"},' + '{"type": "move_forwards"}]' - ) + ), ) set_blocks( @@ -983,7 +992,7 @@ def set_blocks(level, blocks): + '{"type": "move_forwards"},' + '{"type": "turn_left"},' + '{"type": "turn_right"}]' - ) + ), ) set_blocks( @@ -999,7 +1008,7 @@ def set_blocks(level, blocks): + '{"type": "move_forwards"},' + '{"type": "turn_left"},' + '{"type": "turn_right"}]' - ) + ), ) set_blocks( @@ -1009,7 +1018,7 @@ def set_blocks(level, blocks): + '{"type": "turn_left"},' + '{"type": "turn_right"},' + '{"type": "controls_repeat"}]' - ) + ), ) set_blocks( @@ -1019,7 +1028,7 @@ def set_blocks(level, blocks): + '{"type": "turn_left"},' + '{"type": "turn_right"},' + '{"type": "controls_repeat"}]' - ) + ), ) set_blocks( @@ -1031,7 +1040,7 @@ def set_blocks(level, blocks): + '{"type": "turn_left"},' + '{"type": "turn_right"},' + '{"type": "controls_repeat"}]' - ) + ), ) set_blocks( @@ -1044,7 +1053,7 @@ def set_blocks(level, blocks): + '{"type": "wait"},' + '{"type": "controls_repeat_until"},' + '{"type": "traffic_light"}]' - ) + ), ) set_blocks( @@ -1072,6 +1081,16 @@ def set_blocks(level, blocks): ) +def delete_python_den_blocks(apps, schema_editor): + Level = apps.get_model("game", "Level") + LevelBlock = apps.get_model("game", "LevelBlock") + + for i in range(1014, 1061): + deleted_level_blocks = LevelBlock.objects.filter(level_id=i) + for block in deleted_level_blocks: + block.delete() + + def add_python_den_decor(apps, schema_editor): Level = apps.get_model("game", "Level") LevelDecor = apps.get_model("game", "LevelDecor") @@ -1088,7 +1107,10 @@ def bulk_copy_decor(new_level_name, old_level_name): for decor in decor_to_copy: new_level_decor.append( LevelDecor( - level_id = new_level.pk, x = decor["x"], y = decor["y"], decorName = decor["decorName"] + level_id=new_level.pk, + x=decor["x"], + y=decor["y"], + decorName=decor["decorName"], ) ) LevelDecor.objects.bulk_create(new_level_decor) @@ -1098,6 +1120,7 @@ def bulk_copy_decor(new_level_name, old_level_name): level1016 = Level.objects.get(name="1016", default=True) level1017 = Level.objects.get(name="1017", default=True) level1018 = Level.objects.get(name="1018", default=True) + level1019 = Level.objects.get(name="1019", default=True) level1020 = Level.objects.get(name="1020", default=True) level1021 = Level.objects.get(name="1021", default=True) level1022 = Level.objects.get(name="1022", default=True) @@ -1117,7 +1140,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 311, "y": 309, "decorName": "tree2"},' + '{"x": 568, "y": 516, "decorName": "tree1"},' + '{"x": 654, "y": 512, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1133,7 +1156,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 486, "y": 318, "decorName": "tree1"},' + '{"x": 286, "y": 327, "decorName": "tree1"},' + '{"x": 252, "y": 256, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1144,7 +1167,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 611, "y": 469, "decorName": "bush"},' + '{"x": 610, "y": 427, "decorName": "bush"},' + '{"x": 613, "y": 505, "decorName": "tree2"}]' - ) + ), ) set_decor( @@ -1153,7 +1176,7 @@ def bulk_copy_decor(new_level_name, old_level_name): '[{"x": 461, "y": 314, "decorName": "pond"},' + '{"x": 428, "y": 371, "decorName": "tree1"},' + '{"x": 500, "y": 179, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1164,7 +1187,21 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 529, "y": 600, "decorName": "tree1"},' + '{"x": 120, "y": 415, "decorName": "tree2"},' + '{"x": 93, "y": 300, "decorName": "tree2"}]' - ) + ), + ) + + set_decor( + level1019, + json.loads( + '[{"x": 562, "y": 42, "decorName": "pond"},' + + '{"x": 551, "y": 501, "decorName": "bush"},' + + '{"x": 551, "y": 562, "decorName": "bush"},' + + '{"x": 602, "y": 299, "decorName": "tree2"},' + + '{"x": 618, "y": 500, "decorName": "tree1"},' + + '{"x": 460, "y": 495, "decorName": "tree1"},' + + '{"x": 145, "y": 364, "decorName": "tree1"},' + + '{"x": 145, "y": 269, "decorName": "tree1"}]' + ), ) set_decor( @@ -1177,7 +1214,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 694, "y": 341, "decorName": "tree1"},' + '{"x": 516, "y": 651, "decorName": "tree2"},' + '{"x": 412, "y": 648, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1186,7 +1223,7 @@ def bulk_copy_decor(new_level_name, old_level_name): '[{"x": 149, "y": 292, "decorName": "pond"},' + '{"x": 300, "y": 507, "decorName": "tree1"},' + '{"x": 308, "y": 583, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1197,7 +1234,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 463, "y": 317, "decorName": "tree2"},' + '{"x": 367, "y": 237, "decorName": "tree1"},' + '{"x": 250, "y": 391, "decorName": "tree2"}]' - ) + ), ) set_decor( @@ -1214,7 +1251,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 602, "y": 418, "decorName": "tree2"},' + '{"x": 646, "y": 483, "decorName": "tree1"},' + '{"x": 678, "y": 426, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1229,7 +1266,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 553, "y": 354, "decorName": "bush"},' + '{"x": 546, "y": 318, "decorName": "bush"},' + '{"x": 230, "y": 317, "decorName": "tree2"}]' - ) + ), ) set_decor( @@ -1244,7 +1281,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 548, "y": 411, "decorName": "tree1"},' + '{"x": 617, "y": 407, "decorName": "tree2"},' + '{"x": 669, "y": 199, "decorName": "tree2"}]' - ) + ), ) set_decor( @@ -1257,7 +1294,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 694, "y": 341, "decorName": "tree1"},' + '{"x": 516, "y": 651, "decorName": "tree2"},' + '{"x": 412, "y": 648, "decorName": "tree1"}]' - ) + ), ) set_decor( @@ -1268,7 +1305,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 692, "y": 688, "decorName": "tree1"},' + '{"x": 717, "y": 620, "decorName": "tree1"},' + '{"x": 686, "y": 530, "decorName": "tree2"}]' - ) + ), ) set_decor( @@ -1279,7 +1316,7 @@ def bulk_copy_decor(new_level_name, old_level_name): + '{"x": 200, "y": 342, "decorName": "tree1"},' + '{"x": 405, "y": 443, "decorName": "tree2"},' + '{"x": 400, "y": 514, "decorName": "tree1"}]' - ) + ), ) bulk_copy_decor("85", "1026") @@ -1314,6 +1351,16 @@ def bulk_copy_decor(new_level_name, old_level_name): bulk_copy_decor("102", "1060") +def delete_python_den_decor(apps, schema_editor): + Level = apps.get_model("game", "Level") + LevelDecor = apps.get_model("game", "LevelDecor") + + for i in range(1014, 1061): + deleted_level_decor = LevelDecor.objects.filter(level_id=i) + for decor_element in deleted_level_decor: + decor_element.delete() + + def create_python_den_episodes(apps, schema_editor): Episode = apps.get_model("game", "Episode") @@ -1368,10 +1415,22 @@ def create_python_den_episodes(apps, schema_editor): episode15.next_episode = episode22 +def delete_python_den_episodes(apps, schema_editor): + Episode = apps.get_model("game", "Episode") + for i in range(16, 23): + deleted_episode = Episode.objects.get(pk=i) + deleted_episode.delete() + + episode14 = Episode.objects.get(pk=14) + episode15 = Episode.objects.get(pk=15) + episode14.next_episode = episode15 + episode15.next_episode = None + + def set_first_and_last_levels(apps, schema_editor): Episode = apps.get_model("game", "Episode") Level = apps.get_model("game", "Level") - + episode13 = Episode.objects.get(pk=13) level1014 = Level.objects.get(name="1014", default=True) episode13.first_level = level1014 @@ -1392,6 +1451,27 @@ def set_first_and_last_levels(apps, schema_editor): episode22.first_level = level1050 episode22.save() + +def reset_first_and_last_levels(apps, schema_editor): + Episode = apps.get_model("game", "Episode") + + episode13 = Episode.objects.get(pk=13) + episode13.first_level = None + episode13.save() + + episode14 = Episode.objects.get(pk=14) + episode14.first_level = None + episode14.save() + + episode15 = Episode.objects.get(pk=15) + episode15.first_level = None + episode15.save() + + episode22 = Episode.objects.get(pk=22) + episode22.first_level = None + episode22.save() + + def delete_old_loop_levels(apps, schema_editor): Level = apps.get_model("game", "Level") for i in range(123, 154): @@ -1399,16 +1479,194 @@ def delete_old_loop_levels(apps, schema_editor): deleted_level.delete() +def recreate_old_loop_levels(apps, schema_editor): + Episode = apps.get_model("game", "Episode") + Level = apps.get_model("game", "Level") + + episode_15 = Episode.objects.get(pk=15) + episode_14 = Episode.objects.get(pk=14) + episode_13 = Episode.objects.get(pk=13) + + level_153 = Level.objects.create( + name="153", + episode=episode_15, + ) + level_152 = Level.objects.create( + name="152", + episode=episode_15, + next_level=level_153, + ) + level_151 = Level.objects.create( + name="151", + episode=episode_15, + next_level=level_152, + ) + level_150 = Level.objects.create( + name="150", + episode=episode_15, + next_level=level_151, + ) + level_149 = Level.objects.create( + name="149", + episode=episode_15, + next_level=level_150, + ) + + # Episode 14, Levels 141 - 148 + level_148 = Level.objects.create( + name="148", + episode=episode_14, + next_level=level_149, + ) + level_147 = Level.objects.create( + name="147", + episode=episode_14, + next_level=level_148, + ) + level_146 = Level.objects.create( + name="146", + episode=episode_14, + next_level=level_147, + ) + level_145 = Level.objects.create( + name="145", + episode=episode_14, + next_level=level_146, + ) + level_144 = Level.objects.create( + name="144", + episode=episode_14, + next_level=level_145, + ) + level_143 = Level.objects.create( + name="143", + episode=episode_14, + next_level=level_144, + ) + level_142 = Level.objects.create( + name="142", + episode=episode_14, + next_level=level_143, + ) + level_141 = Level.objects.create( + name="141", + episode=episode_14, + next_level=level_142, + ) + + # Episode 13, Levels 123 - 140 + level_140 = Level.objects.create( + name="140", + episode=episode_13, + next_level=level_141, + ) + level_139 = Level.objects.create( + name="139", + episode=episode_13, + next_level=level_140, + ) + level_138 = Level.objects.create( + name="138", + episode=episode_13, + next_level=level_139, + ) + level_137 = Level.objects.create( + name="137", + episode=episode_13, + next_level=level_138, + ) + level_136 = Level.objects.create( + name="136", + episode=episode_13, + next_level=level_137, + ) + level_135 = Level.objects.create( + name="135", + episode=episode_13, + next_level=level_136, + ) + level_134 = Level.objects.create( + name="134", + episode=episode_13, + next_level=level_135, + ) + level_133 = Level.objects.create( + name="133", + episode=episode_13, + next_level=level_134, + ) + level_132 = Level.objects.create( + name="132", + episode=episode_13, + next_level=level_133, + ) + level_131 = Level.objects.create( + name="131", + episode=episode_13, + next_level=level_132, + ) + level_130 = Level.objects.create( + name="130", + episode=episode_13, + next_level=level_131, + ) + level_129 = Level.objects.create( + name="129", + episode=episode_13, + next_level=level_130, + ) + level_128 = Level.objects.create( + name="128", + episode=episode_13, + next_level=level_129, + ) + level_127 = Level.objects.create( + name="127", + episode=episode_13, + next_level=level_128, + ) + level_126 = Level.objects.create( + name="126", + episode=episode_13, + next_level=level_127, + ) + level_125 = Level.objects.create( + name="125", + episode=episode_13, + next_level=level_126, + ) + level_124 = Level.objects.create( + name="124", + episode=episode_13, + next_level=level_125, + ) + level_123 = Level.objects.create( + name="123", + episode=episode_13, + next_level=level_124, + ) + + class Migration(migrations.Migration): - dependencies = [ - ('game', '0096_alter_level_commands') - ] + dependencies = [("game", "0096_alter_level_commands")] operations = [ - migrations.RunPython(code=delete_old_loop_levels), - migrations.RunPython(code=create_python_den_episodes), - migrations.RunPython(code=add_python_den_levels), - migrations.RunPython(code=add_python_den_blocks), - migrations.RunPython(code=add_python_den_decor), - migrations.RunPython(code=set_first_and_last_levels) + migrations.RunPython( + code=delete_old_loop_levels, reverse_code=recreate_old_loop_levels + ), + migrations.RunPython( + code=create_python_den_episodes, reverse_code=delete_python_den_episodes + ), + migrations.RunPython( + code=add_python_den_levels, reverse_code=delete_python_den_levels + ), + migrations.RunPython( + code=add_python_den_blocks, reverse_code=delete_python_den_blocks + ), + migrations.RunPython( + code=add_python_den_decor, reverse_code=delete_python_den_decor + ), + migrations.RunPython( + code=set_first_and_last_levels, reverse_code=reset_first_and_last_levels + ), ] diff --git a/game/static/game/js/game.js b/game/static/game/js/game.js index 70a3efdef..f760b80df 100644 --- a/game/static/game/js/game.js +++ b/game/static/game/js/game.js @@ -114,7 +114,7 @@ ocargo.Game.prototype.setup = function () { titlePrefix = gettext('Level %(level_name)s') } - var adjusted_level_name = '' + let adjusted_level_name = '' if (LEVEL_NAME > 1000) { adjusted_level_name = LEVEL_NAME - 1000 } else { diff --git a/game/tests/test_level_selection.py b/game/tests/test_level_selection.py index e8f904a2f..c0c1fdbbc 100644 --- a/game/tests/test_level_selection.py +++ b/game/tests/test_level_selection.py @@ -84,7 +84,10 @@ def test_list_episodes(self): assert response.status_code == 200 assert response.context["blocklyEpisodes"][0]["name"] == "Getting Started" - assert response.context["blocklyEpisodes"][0]["levels"][0]["title"] == "Can you help the van get to the house?" + assert ( + response.context["blocklyEpisodes"][0]["levels"][0]["title"] + == "Can you help the van get to the house?" + ) def test_custom_levels_access(self): email1, password1 = signup_teacher_directly() @@ -100,8 +103,12 @@ def test_custom_levels_access(self): # Create a class and a student for each teacher _, class_name1, access_code1 = create_class_directly(email1) _, class_name2, access_code2 = create_class_directly(email2) - student_name1, student_password1, student1 = create_school_student_directly(access_code1) - student_name2, student_password2, student2 = create_school_student_directly(access_code2) + student_name1, student_password1, student1 = create_school_student_directly( + access_code1 + ) + student_name2, student_password2, student2 = create_school_student_directly( + access_code2 + ) save_url = "save_level_for_editor" @@ -110,7 +117,9 @@ def test_custom_levels_access(self): teacher2_level = create_save_level(teacher2) save_level_url = reverse(save_url) - response = self.client.post(save_level_url, {"data": self.level_data(teacher2_level.id)}) + response = self.client.post( + save_level_url, {"data": self.level_data(teacher2_level.id)} + ) assert response.status_code == 200 @@ -120,7 +129,9 @@ def test_custom_levels_access(self): student1_level = create_save_level(student1) - response = self.client.post(save_level_url, {"data": self.level_data(student1_level.id)}) + response = self.client.post( + save_level_url, {"data": self.level_data(student1_level.id)} + ) assert response.status_code == 200 @@ -130,7 +141,9 @@ def test_custom_levels_access(self): student2_level = create_save_level(student2) - response = self.client.post(save_level_url, {"data": self.level_data(student2_level.id)}) + response = self.client.post( + save_level_url, {"data": self.level_data(student2_level.id)} + ) assert response.status_code == 200 @@ -143,11 +156,19 @@ def test_custom_levels_access(self): assert response.status_code == 200 assert len(response.context["directly_shared_levels"]) == 1 - assert response.context["directly_shared_levels"][0]["owner"] == student1.new_user + assert ( + response.context["directly_shared_levels"][0]["owner"] == student1.new_user + ) assert response.context["indirectly_shared_levels"][teacher2.new_user] assert len(response.context["indirectly_shared_levels"][teacher2.new_user]) == 2 - assert response.context["indirectly_shared_levels"][teacher2.new_user][0]["owner"] == teacher2.new_user - assert response.context["indirectly_shared_levels"][teacher2.new_user][1]["owner"] == student2.new_user + assert ( + response.context["indirectly_shared_levels"][teacher2.new_user][0]["owner"] + == teacher2.new_user + ) + assert ( + response.context["indirectly_shared_levels"][teacher2.new_user][1]["owner"] + == student2.new_user + ) # Login as second teacher again and check they have access to only their student's level self.logout() @@ -158,7 +179,9 @@ def test_custom_levels_access(self): assert response.status_code == 200 assert len(response.context["directly_shared_levels"]) == 1 - assert response.context["directly_shared_levels"][0]["owner"] == student2.new_user + assert ( + response.context["directly_shared_levels"][0]["owner"] == student2.new_user + ) assert response.context["indirectly_shared_levels"] == {} def test_cannot_access_locked_level(self): @@ -231,26 +254,53 @@ def test_next_level_for_locked_levels(self): prev_level_url = _prev_level_url(level1016, student.new_user, False) assert prev_level_url == f"/rapidrouter/{level1014.name}/" - @patch("game.views.level.datetime", side_effect=lambda *args, **kw: datetime(*args, **kw)) + @patch( + "game.views.level.datetime", + side_effect=lambda *args, **kw: datetime(*args, **kw), + ) def test_xmas_theme(self, mock_datetime): november = datetime(2023, 11, 1, 0, 0, 0, 0) mock_datetime.now.return_value = november response = self.client.get(f"{reverse('home')}/rapidrouter/1/") assert """CHARACTER_NAME = "Van"\n""" in response.content.decode("utf-8") - assert """CHARACTER_URL = "characters/top_view/Van.svg"\n""" in response.content.decode("utf-8") - assert """WRECKAGE_URL = "van_wreckage.svg"\n""" in response.content.decode("utf-8") - assert """BACKGROUND_URL = "decor/grass/tile1.svg"\n""" in response.content.decode("utf-8") - assert """HOUSE_URL = "decor/grass/house.svg"\n""" in response.content.decode("utf-8") - assert """CFC_URL = "decor/grass/cfc.svg"\n""" in response.content.decode("utf-8") + assert ( + """CHARACTER_URL = "characters/top_view/Van.svg"\n""" + in response.content.decode("utf-8") + ) + assert """WRECKAGE_URL = "van_wreckage.svg"\n""" in response.content.decode( + "utf-8" + ) + assert ( + """BACKGROUND_URL = "decor/grass/tile1.svg"\n""" + in response.content.decode("utf-8") + ) + assert """HOUSE_URL = "decor/grass/house.svg"\n""" in response.content.decode( + "utf-8" + ) + assert """CFC_URL = "decor/grass/cfc.svg"\n""" in response.content.decode( + "utf-8" + ) december = datetime(2023, 12, 1, 0, 0, 0, 0) mock_datetime.now.return_value = december response = self.client.get(f"{reverse('home')}/rapidrouter/1/") assert """CHARACTER_NAME = "Van"\n""" in response.content.decode("utf-8") - assert """CHARACTER_URL = "characters/top_view/Sleigh.svg"\n""" in response.content.decode("utf-8") - assert """WRECKAGE_URL = "sleigh_wreckage.svg"\n""" in response.content.decode("utf-8") - assert """BACKGROUND_URL = "decor/snow/tile1.svg"\n""" in response.content.decode("utf-8") - assert """HOUSE_URL = "decor/snow/house.svg"\n""" in response.content.decode("utf-8") - assert """CFC_URL = "decor/snow/cfc.svg"\n""" in response.content.decode("utf-8") + assert ( + """CHARACTER_URL = "characters/top_view/Sleigh.svg"\n""" + in response.content.decode("utf-8") + ) + assert """WRECKAGE_URL = "sleigh_wreckage.svg"\n""" in response.content.decode( + "utf-8" + ) + assert ( + """BACKGROUND_URL = "decor/snow/tile1.svg"\n""" + in response.content.decode("utf-8") + ) + assert """HOUSE_URL = "decor/snow/house.svg"\n""" in response.content.decode( + "utf-8" + ) + assert """CFC_URL = "decor/snow/cfc.svg"\n""" in response.content.decode( + "utf-8" + ) diff --git a/game/views/level.py b/game/views/level.py index 4cf97a8da..483fa3b15 100644 --- a/game/views/level.py +++ b/game/views/level.py @@ -89,7 +89,9 @@ def _next_level_url(level, user, night_mode): is_next_level_locked = klass in next_level.locked_for_class.all() if is_next_level_locked: - while is_next_level_locked and (int(next_level.name) < 109 or 1001 < int(next_level.name) < 1060): + while is_next_level_locked and ( + int(next_level.name) < 122 or 1001 < int(next_level.name) < 1060 + ): next_level = next_level.next_level is_next_level_locked = klass in next_level.locked_for_class.all() @@ -161,11 +163,9 @@ def play_level(request, level, from_editor=False): if level.default else level.hint ) - commands_attr = 'commands_level' + str(level.name) + commands_attr = "commands_level" + str(level.name) commands = ( - getattr(messages, commands_attr, None) - if level.default - else level.commands + getattr(messages, commands_attr, None) if level.default else level.commands ) character = level.character character_url = character.top_down diff --git a/game/views/level_solutions.py b/game/views/level_solutions.py index 988fbfa21..bd400dcea 100644 --- a/game/views/level_solutions.py +++ b/game/views/level_solutions.py @@ -406,7 +406,7 @@ def big(): count = 0 while count < 3: - if my_van.is_road("LEFT"): + if my_van.is_road_left(): my_van.turn_left() my_van.turn_right() my_van.move_forwards() @@ -418,7 +418,7 @@ def big(): count = 0 while count < 19: - if my_van.is_road("LEFT"): + if my_van.is_road_left(): my_van.turn_left() my_van.move_forwards() count = count + 1""" @@ -429,7 +429,7 @@ def big(): count = 0 while count < 8: - if my_van.is_road("LEFT"): + if my_van.is_road_left(): my_van.turn_left() else: my_van.turn_right() @@ -441,7 +441,7 @@ def big(): count = 0 while count < 6: - if my_van.is_road("LEFT"): + if my_van.is_road_left(): my_van.turn_left() my_van.deliver() my_van.turn_right() @@ -457,9 +457,9 @@ def big(): count = 0 while count < 8: - if my_van.is_road("FORWARD"): + if my_van.is_road_forward(): my_van.move_forwards() - elif my_van.is_road("LEFT"): + elif my_van.is_road_left(): my_van.turn_left() else: my_van.turn_right() @@ -473,9 +473,9 @@ def big(): while count < 16: if my_van.at_red_traffic_light(): my_van.wait() - elif my_van.is_road("LEFT"): + elif my_van.is_road_left(): my_van.turn_left() - elif my_van.is_road("FORWARD"): + elif my_van.is_road_forward(): my_van.move_forwards() else: my_van.turn_right() @@ -496,7 +496,7 @@ def big(): my_van = Van() while not my_van.at_destination(): - if my_van.is_road("LEFT"): + if my_van.is_road_left(): my_van.turn_left() else: my_van.turn_right()""" @@ -506,7 +506,7 @@ def big(): my_van = Van() while not my_van.at_destination(): - if my_van.is_road("RIGHT"): + if my_van.is_road_right(): my_van.turn_right() else: my_van.move_forwards()""" @@ -518,7 +518,7 @@ def big(): while not my_van.at_destination(): if my_van.is_animal_crossing(): my_van.sound_horn() - elif my_van.is_road("FORWARD"): + elif my_van.is_road_forward(): my_van.move_forwards() elif my_van.at_dead_end(): my_van.turn_around() @@ -531,7 +531,7 @@ def big(): while not my_van.at_destination(): if my_van.is_animal_crossing(): my_van.sound_horn() - elif my_van.is_road("FORWARD"): + elif my_van.is_road_forward(): my_van.move_forwards() else: my_van.turn_left()""" @@ -542,17 +542,17 @@ def big(): for count in range(4): while not my_van.at_destination(): - if my_van.at_traffic_light("RED"): + if my_van.at_red_traffic_light(): my_van.wait() - elif my_van.is_road("LEFT"): + elif my_van.is_road_left(): my_van.turn_left() - elif my_van.is_road("FORWARD"): + elif my_van.is_road_forward(): my_van.move_forwards() - elif my_van.is_road("RIGHT"): + elif my_van.is_road_right(): my_van.turn_right() elif my_van.at_dead_end(): my_van.turn_around() - my_van.deliver()"""# + my_van.deliver()""" # python_lvl_52 = """from van import Van @@ -850,19 +850,6 @@ def bend(): "120": lvl_120, "121": lvl_121, "122": lvl_122, - "1001": '', - "1002": ' ', - "1003": ' ', - "1004": lvl_113, - "1005": lvl_114, - "1006": lvl_115, - "1007": ' ', - "1008": ' count 0 LT count 4 count 1 ', - "1009": ' count 0 LT count 4 count 1 ', - "1010": lvl_119, - "1011": lvl_120, - "1012": lvl_121, - "1013": lvl_122, "1014": ' count 0 LT count 3 count 1 ', "1015": ' count 0 LT count 8 count 1 ', "1016": python_lvl_16, @@ -909,6 +896,5 @@ def bend(): "1057": python_lvl_57, "1058": python_lvl_58, "1059": lvl_101, - "1060": lvl_102 - + "1060": lvl_102, } count 0 LT count 4 LEFT count 1