Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/pillow-10.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 authored Oct 18, 2023
2 parents c2e6a6d + daec981 commit 9eeb16a
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 23 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

<!--next-version-placeholder-->

## v5.12.3 (2023-10-17)

### Fix

* Update level 47 title ([#1501](https://github.com/ocadotechnology/rapid-router/issues/1501)) ([`aea6c46`](https://github.com/ocadotechnology/rapid-router/commit/aea6c460a5d34f02368bab7e0912c1052a9f7a57))

## v5.12.2 (2023-10-17)

### Fix

* Add space in level 39 hint ([#1500](https://github.com/ocadotechnology/rapid-router/issues/1500)) ([`d31a41a`](https://github.com/ocadotechnology/rapid-router/commit/d31a41a33cde09b921704a4529d08834f0a7836c))

## v5.12.1 (2023-10-17)

### Fix

* Update level 39 hint ([#1499](https://github.com/ocadotechnology/rapid-router/issues/1499)) ([`b8a4e1f`](https://github.com/ocadotechnology/rapid-router/commit/b8a4e1f2a68fc988e7215417b789bbc190ea147c))

## v5.12.0 (2023-10-16)

### Feature

* Add cows to existing levels ([#1492](https://github.com/ocadotechnology/rapid-router/issues/1492)) ([`a57c0b3`](https://github.com/ocadotechnology/rapid-router/commit/a57c0b38eba666abd393c4b5d3a4196b37a756d6))

## v5.11.3 (2023-08-31)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion game/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.11.3"
__version__ = "5.12.3"
2 changes: 1 addition & 1 deletion game/end_to_end_tests/test_play_through.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_level_038(self):
self._complete_level(38)

def test_level_039(self):
self._complete_level(39)
self._complete_level(39, check_route_score=False)

def test_level_040(self):
self._complete_level(40)
Expand Down
44 changes: 27 additions & 17 deletions game/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,22 +905,29 @@ def hint_level37():


def title_level38():
return "Third time lucky!"
return "Where did the cows come from?"


def description_level38():
message = (
"Well done! You've got so far. <br> Can you apply the knowledge you "
"gained going through this part of the game to this level?"
"Well done! You've got so far."
"<br>"
"Can you apply the knowledge you gained going through this part of the "
"game to this level? This time there are some hidden cows that you "
"need to get out of the road! Can you work out what to do?"
"<br><br>"
"Hint: Cows don't like noise"
)
return build_description(title_level38(), message)


def hint_level38():
return (
"This is a really long route. With a counted loop, your program would be quite "
"long but is this program going to be any longer than your solution to the "
"last level?"
"This is a really long route. With a counted loop, your program would "
"be quite long but is this program going to be any longer than your "
"solution to the last level?"
"<br><br>"
"Hint: Cows don't like noise"
)


Expand All @@ -930,19 +937,20 @@ def title_level39():

def description_level39():
message = (
"Can you use the 'general algorithm' here so that the van takes a "
"shorter route? Or maybe there's a more efficient way? <br><br>Keep "
"an eye on the fuel level - try to use as little as possible."
"It looks like the cows have escaped when you get to the side roads, "
"so be careful not to hit them!"
"<br><br>"
"Hint: Cows don't like noise"
)
return build_description(title_level39(), message)


# TODO: Update when we update this level
def hint_level39():
return (
"Uh oh, moving around the blocks in your 'general algorithm' might not "
"be the most efficient solution. How about creating a simple solution "
"without 'if statements' that will help the van reach the house?"
"You'll need to modify your general algorithm here so you can get back "
"on track if you hit a dead end."
"<br><br>"
"Hint: Cows don't like noise"
)


Expand Down Expand Up @@ -1098,16 +1106,18 @@ def title_level47():
def description_level47():
message = (
"Put your knowledge to test. Create an algorithm to lead the van to the "
"house. <br> Don't forget to add a turn and to make the van wait at a "
"traffic light."
"house. <br> Don't forget to add a turn block and this time, you "
"need to avoid cows instead of waiting at traffic lights."
)
return build_description(title_level47(), message)


def hint_level47():
return (
"This route is similar to the last one but the turn is in the other direction. "
"Can you adapt your program?"
"This route is similar to the last one but the turn is in a different "
"direction, and there are now cows instead of traffic lights!!"
"<br><br>"
"Do you remember what to do?"
)


Expand Down
195 changes: 195 additions & 0 deletions game/migrations/0083_add_cows_to_existing_levels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
from django.apps.registry import Apps
from django.db import migrations


def add_cows_to_existing_levels(apps: Apps, *args):
Level = apps.get_model("game", "Level")
Block = apps.get_model("game", "Block")
LevelBlock = apps.get_model("game", "LevelBlock")
LevelDecor = apps.get_model("game", "LevelDecor")

level_38 = Level.objects.get(name="38", default=1)
level_38.cows = '[{"minCows":1,"maxCows":1,"potentialCoordinates":[{"x":2,"y":6},{"x":3,"y":4},{"x":3,"y":1}],"type":"WHITE"}]'
level_38.theme_name = "farm"
level_38.model_solution = "[10]"
level_38.save()

level_39 = Level.objects.get(name="39", default=1)
level_39.cows = '[{"minCows":1,"maxCows":1,"potentialCoordinates":[{"x":4,"y":4},{"x":8,"y":4},{"x":8,"y":6}],"type":"WHITE"}]'
level_39.theme_name = "farm"
level_39.model_solution = "[10]"
level_39.disable_route_score = True
level_39.save()

level_47 = Level.objects.get(name="47", default=1)
level_47.traffic_lights = "[]"
level_47.cows = '[{"minCows":1,"maxCows":1,"potentialCoordinates":[{"x":6,"y":4},{"x":4,"y":6},{"x":2,"y":4}],"type":"WHITE"}]'
level_47.theme_name = "farm"
level_47.model_solution = "[8]"
level_47.save()

block_sound_horn = Block.objects.get(type="sound_horn")
block_cow_crossing = Block.objects.get(type="cow_crossing")

LevelBlock.objects.filter(
level=level_47,
type__type__in=["traffic_light", "wait"],
).delete()

LevelBlock.objects.bulk_create(
[
LevelBlock(level=level_38, type=block_sound_horn),
LevelBlock(level=level_38, type=block_cow_crossing),
LevelBlock(level=level_39, type=block_sound_horn),
LevelBlock(level=level_39, type=block_cow_crossing),
LevelBlock(level=level_47, type=block_sound_horn),
LevelBlock(level=level_47, type=block_cow_crossing),
]
)

LevelDecor.objects.filter(
level_id__in=[
level_47.id,
]
).delete()

LevelDecor.objects.bulk_create(
[
LevelDecor(
x=570,
y=296,
decorName="pond",
level=level_39,
),
LevelDecor(
x=570,
y=408,
decorName="pond",
level=level_39,
),
LevelDecor(
x=570,
y=514,
decorName="pond",
level=level_39,
),
LevelDecor(
x=293,
y=300,
decorName="tree1",
level=level_39,
),
LevelDecor(
x=711,
y=101,
decorName="tree1",
level=level_39,
),
LevelDecor(
x=897,
y=604,
decorName="tree1",
level=level_39,
),
LevelDecor(
x=114,
y=315,
decorName="tree1",
level=level_39,
),
LevelDecor(
x=37,
y=502,
decorName="pond",
level=level_47,
),
LevelDecor(
x=39,
y=400,
decorName="pond",
level=level_47,
),
LevelDecor(
x=39,
y=296,
decorName="pond",
level=level_47,
),
LevelDecor(
x=720,
y=657,
decorName="bush",
level=level_47,
),
LevelDecor(
x=720,
y=556,
decorName="bush",
level=level_47,
),
LevelDecor(
x=720,
y=455,
decorName="bush",
level=level_47,
),
LevelDecor(
x=720,
y=343,
decorName="bush",
level=level_47,
),
LevelDecor(
x=720,
y=220,
decorName="bush",
level=level_47,
),
LevelDecor(
x=403,
y=378,
decorName="tree1",
level=level_47,
),
LevelDecor(
x=440,
y=471,
decorName="tree1",
level=level_47,
),
LevelDecor(
x=132,
y=649,
decorName="tree1",
level=level_47,
),
LevelDecor(
x=620,
y=689,
decorName="tree1",
level=level_47,
),
LevelDecor(
x=500,
y=149,
decorName="tree1",
level=level_47,
),
LevelDecor(
x=550,
y=483,
decorName="tree2",
level=level_47,
),
]
)


class Migration(migrations.Migration):
dependencies = [("game", "0082_level_43_solution")]
operations = [
migrations.RunPython(
add_cows_to_existing_levels,
reverse_code=migrations.RunPython.noop,
)
]
1 change: 0 additions & 1 deletion game/static/game/js/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ ocargo.Model.prototype.isCowCrossing = function(type) {
var thisNode = this.van.getPosition().currentNode;
this.observe('cow crossing');
var nodes = thisNode.connectedNodes;
nodes.push(thisNode);
for(var i = 0; i < nodes.length; i++){
var node = nodes[i];
var cow = this.getCowForNode(node, [ocargo.Cow.ACTIVE, ocargo.Cow.READY]);
Expand Down
Loading

0 comments on commit 9eeb16a

Please sign in to comment.